Sha256: 48545b49b8152ace8aa0c05bde8ef000df02b91ea325ed2179ad5a03b89dd1a9

Contents?: true

Size: 798 Bytes

Versions: 1

Compression:

Stored size: 798 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.valid_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.5.0 lib/pansophy_authenticator/remote/fetcher.rb