Sha256: ec7ede187a926926e9db3299ad5830e28f0fb972de59a8aebc4b4afd04295223

Contents?: true

Size: 792 Bytes

Versions: 1

Compression:

Stored size: 792 Bytes

Contents

require 'pansophy'

module PansophyAuthenticator
  module Remote
    class Fetcher
      include Memoizable

      def keys
        fetch
      end
      memoize :keys

      private

      def fetch
        fail_for_invalid_format! unless parsed_content.is_a? Hash
        parsed_content
      end

      def parsed_content
        YAML.load remote_content
      rescue Psych::SyntaxError
        fail_for_invalid_format!
      end
      memoize :parsed_content

      def remote_content
        Pansophy.read(configuration.bucket_name, configuration.file_path)
      end

      def configuration
        PansophyAuthenticator.configuration
      end

      def fail_for_invalid_format!
        fail Error, 'Remote application keys file is not in a valid format'
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pansophy_authenticator-0.4.3 lib/pansophy_authenticator/remote/fetcher.rb