Module: MercuryParser::Configuration
- Included in:
- MercuryParser
- Defined in:
- lib/mercury_parser/configuration.rb
Constant Summary collapse
- VALID_CONNECTION_KEYS =
[:api_endpoint, :user_agent].freeze
- VALID_OPTIONS_KEYS =
[:api_key].freeze
- VALID_CONFIG_KEYS =
VALID_CONNECTION_KEYS + VALID_OPTIONS_KEYS
- DEFAULT_API_ENDPOINT =
"https://mercury.postlight.com/parser"
- DEFAULT_USER_AGENT =
"MercuryParser Ruby Gem #{MercuryParser::VERSION}".freeze
- DEFAULT_API_TOKEN =
nil
Class Method Summary collapse
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block.
- #options ⇒ Object
- #reset! ⇒ Object
Class Method Details
.extended(base) ⇒ Object
15 16 17 |
# File 'lib/mercury_parser/configuration.rb', line 15 def self.extended(base) base.reset! end |
Instance Method Details
#configure {|_self| ... } ⇒ Object
Convenience method to allow configuration options to be set in a block
20 21 22 |
# File 'lib/mercury_parser/configuration.rb', line 20 def configure yield self end |
#options ⇒ Object
24 25 26 |
# File 'lib/mercury_parser/configuration.rb', line 24 def Hash[ * VALID_CONFIG_KEYS.map { |key| [key, send(key)] }.flatten ] end |
#reset! ⇒ Object
28 29 30 31 32 33 34 35 |
# File 'lib/mercury_parser/configuration.rb', line 28 def reset! self.api_endpoint = DEFAULT_API_ENDPOINT self.user_agent = DEFAULT_USER_AGENT self.api_key = DEFAULT_API_TOKEN return true end |