Sha256: f6b762e9f12cee28e88d8e2b22ff524238a4aca9cde04ce58a850b9643a80a3e

Contents?: true

Size: 1.02 KB

Versions: 18

Compression:

Stored size: 1.02 KB

Contents

module Spreedly
  module TestCredentials

    def remote_test_environment_key
      remote_creds["environment_key"]
    end

    def remote_test_access_secret
      remote_creds["access_secret"]
    end

    private
    def remote_creds
      @@remote_creds ||= load_creds
    end

    def load_creds
      load_default_creds.merge(load_personal_creds)
    end

    def load_default_creds
      YAML.load(File.read(default_creds_file))
    end

    def load_personal_creds
      return {} unless File.exists?(personal_creds_file)

      personal_creds = YAML.load(File.read(personal_creds_file))
      return {} unless personal_creds
      raise("The file '#{personal_creds_file}' has an invalid format.\nIt should have the same format as '#{default_creds_file}'.") unless personal_creds.kind_of?(Hash)
      personal_creds
    end

    def default_creds_file
      File.join(File.dirname(__FILE__), 'credentials.yml')
    end

    def personal_creds_file
      File.join(File.dirname(__FILE__), 'personal_credentials.yml')
    end

  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
spreedly-2.0.18 test/credentials/test_credentials.rb
spreedly-2.0.17 test/credentials/test_credentials.rb
spreedly-2.0.16 test/credentials/test_credentials.rb
spreedly-2.0.15 test/credentials/test_credentials.rb
spreedly-2.0.14 test/credentials/test_credentials.rb
spreedly-2.0.13 test/credentials/test_credentials.rb
spreedly-2.0.11 test/credentials/test_credentials.rb
spreedly-2.0.10 test/credentials/test_credentials.rb
spreedly-2.0.9 test/credentials/test_credentials.rb
spreedly-2.0.8 test/credentials/test_credentials.rb
spreedly-2.0.7 test/credentials/test_credentials.rb
spreedly-2.0.6 test/credentials/test_credentials.rb
spreedly-2.0.5 test/credentials/test_credentials.rb
spreedly-2.0.4 test/credentials/test_credentials.rb
spreedly-2.0.3 test/credentials/test_credentials.rb
spreedly-2.0.2 test/credentials/test_credentials.rb
spreedly-2.0.1 test/credentials/test_credentials.rb
spreedly-2.0.0 test/credentials/test_credentials.rb