Class: Deploy::CLI::Config
- Inherits:
-
Object
- Object
- Deploy::CLI::Config
- Defined in:
- lib/deploy/cli.rb
Constant Summary collapse
- AVAILABLE_CONFIG =
[:account, :username, :api_key, :project]
Instance Method Summary collapse
-
#initialize(config_file = nil) ⇒ Config
constructor
A new instance of Config.
- #method_missing(meth, *args, &block) ⇒ Object
Constructor Details
#initialize(config_file = nil) ⇒ Config
Returns a new instance of Config.
17 18 19 20 21 22 23 |
# File 'lib/deploy/cli.rb', line 17 def initialize(config_file=nil) @config_file_path = config_file || File.join(Dir.pwd, 'Deployfile') @config = JSON.parse(File.read(@config_file_path)) rescue Errno::ENOENT => e puts "Couldn't find configuration file at #{@config_file_path}" exit 1 end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/deploy/cli.rb', line 25 def method_missing(meth, *args, &block) if AVAILABLE_CONFIG.include?(meth.to_sym) @config[meth.to_s] else super end end |