require 'yaml'

module Parity
  class Backup
    def initialize(from: from, to: to)
      @from = from
      @to = to
    end

    def restore
      if to == 'development'
        restore_to_development
      else
        restore_to_pass_through
      end
    end

    private

    attr_reader :from, :to

    def restore_to_development
      Kernel.system "#{curl} | #{pg_restore}"
    end

    def curl
      "curl -s `#{db_backup_url}`"
    end

    def pg_restore
      "pg_restore --verbose --clean --no-acl --no-owner -d #{development_db}"
    end

    def restore_to_pass_through
      Kernel.system "heroku pgbackups:restore #{backup_from} --remote #{to}"
    end

    def backup_from
      "DATABASE `#{db_backup_url}`"
    end

    def db_backup_url
      "heroku pgbackups:url --remote #{from}"
    end

    def development_db
      yaml_file = IO.read(Parity.config.database_config_path)
      YAML.load(yaml_file)['development']['database']
    end
  end
end

require 'yaml'

module Parity
  class Backup
    def initialize(args)
      @from, @to = args.values_at(:from, :to)
    end

    def restore
      if to == 'development'
        restore_to_development
      else
        restore_to_pass_through
      end
    end

    private

    attr_reader :from, :to

    def restore_to_development
      Kernel.system "#{curl} | #{pg_restore}"
    end

    def curl
      "curl -s `#{db_backup_url}`"
    end

    def pg_restore
      "pg_restore --verbose --clean --no-acl --no-owner -d #{development_db}"
    end

    def restore_to_pass_through
      Kernel.system "heroku pgbackups:restore #{backup_from} --remote #{to}"
    end

    def backup_from
      "DATABASE `#{db_backup_url}`"
    end

    def db_backup_url
      "heroku pgbackups:url --remote #{from}"
    end

    def development_db
      yaml_file = IO.read(Parity.config.database_config_path)
      YAML.load(yaml_file)['development']['database']
    end
  end
end

Remove keyword args to support Ruby 1.9
Remove keyword args to support Ruby 1.9

The current implementation only uses keyword args at one point, so Ruby
2.0 is not really needed.

Also, a lot of projects still uses Ruby 1.9, so the loaded ruby will be
the 1.9 (to run tests, app etc).

So I think that is a good idea to support the 1.9 series.
