Class: JScrambler::Config
- Inherits:
-
Object
- Object
- JScrambler::Config
- Defined in:
- lib/jscrambler/config.rb
Constant Summary collapse
- DEFAULT_CONFIG_FILE =
'config/jscrambler_config.json'
Instance Method Summary collapse
-
#initialize(config_file_path = nil) ⇒ Config
constructor
A new instance of Config.
- #to_hash ⇒ Object
Constructor Details
#initialize(config_file_path = nil) ⇒ Config
Returns a new instance of Config.
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/jscrambler/config.rb', line 6 def initialize(config_file_path=nil) begin config_file_path ||= DEFAULT_CONFIG_FILE @config = JSON.parse(File.open(config_file_path, 'rb').read) if @config['keys']['accessKey'].empty? || @config['keys']['secretKey'].empty? raise JScrambler::MissingKeys, 'Missing Access Key or Secret Key' end rescue JSON::ParserError raise JScrambler::ConfigError, "Could not process config file #{config_file_path}" rescue Errno::ENOENT, Errno::EISDIR raise JScrambler::ConfigError, "Could not find config file #{config_file_path}" end end |
Instance Method Details
#to_hash ⇒ Object
20 21 22 |
# File 'lib/jscrambler/config.rb', line 20 def to_hash @config end |