Class: Localeapp::CLI::Command
- Inherits:
-
Object
- Object
- Localeapp::CLI::Command
- Defined in:
- lib/localeapp/cli/command.rb
Instance Method Summary collapse
-
#initialize(args = {}) ⇒ Command
constructor
A new instance of Command.
-
#initialize_config(args = {}) ⇒ Object
requires the Localeapp configuration.
- #load_config_file ⇒ Object
- #set_command_line_arguments(args = {}) ⇒ Object
Constructor Details
#initialize(args = {}) ⇒ Command
Returns a new instance of Command.
4 5 6 7 |
# File 'lib/localeapp/cli/command.rb', line 4 def initialize(args = {}) initialize_config(args) @output = args[:output] || $stdout end |
Instance Method Details
#initialize_config(args = {}) ⇒ Object
requires the Localeapp configuration
10 11 12 13 14 |
# File 'lib/localeapp/cli/command.rb', line 10 def initialize_config(args = {}) Localeapp.configure # load defaults load_config_file set_command_line_arguments(args) end |
#load_config_file ⇒ Object
26 27 28 29 30 31 |
# File 'lib/localeapp/cli/command.rb', line 26 def load_config_file Localeapp.default_config_file_paths.each do |path| next unless File.exist? path require path end end |
#set_command_line_arguments(args = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/localeapp/cli/command.rb', line 16 def set_command_line_arguments(args = {}) sanitized_args = {} if args[:k] sanitized_args[:api_key] = args[:k] end sanitized_args.each do |setting, value| Localeapp.configuration.send("#{setting}=", value) end end |