Class: Parser
- Inherits:
-
Object
- Object
- Parser
- Defined in:
- lib/ngi/parser.rb
Overview
This class is just a wrapper for the main process of ngi
Defined Under Namespace
Classes: ComponentChooser
Constant Summary collapse
- CURRENT_DIR =
File.dirname(__FILE__)
- COMPONENTS_FILE =
"#{CURRENT_DIR}/../config/config.components.yml"
- COMPONENTS_HASH =
Delegate::Configure .new(COMPONENTS_FILE) .to_ruby(from: 'yaml')
- COMPONENTS =
COMPONENTS_HASH.collect { |c| c['name'] }
- CONFIG_FILE =
"#{CURRENT_DIR}/../config/config.yml"
- CONFIG_HASH =
Delegate::Configure.new(CONFIG_FILE).to_ruby(from: 'yaml')
- CONFIGURABLE_FILE =
"#{CURRENT_DIR}/../config/config.configurable.yml"
- CONFIGURABLE =
Delegate::Configure .new(CONFIGURABLE_FILE).to_ruby(from: 'yaml')
- LANGUAGES_FILE =
"#{CURRENT_DIR}/../config/config.languages.yml"
- LANGUAGES_HASH =
Delegate::Configure.new(LANGUAGES_FILE).to_ruby(from: 'yaml')
Class Method Summary collapse
Class Method Details
.parse(args) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/ngi/parser.rb', line 58 def self.parse(args) p = Utils::CommandParser.new do |parser| components = Utils::UserInput.new(valid_inputs: COMPONENTS) parser.name, parser.version = 'ngi', Ngi::VERSION parser. << "\n(<command> can be one of the following)" parser.on(components.valid_inputs, 'Create a new component') do |type| component = ComponentChooser .new( type: type, components_hash: COMPONENTS_HASH, config_hash: CONFIG_HASH ) .component Delegate::Generator.run( type: type, config: CONFIG_HASH, component: component ) end parser.on(['-o', '--options'], 'Configure ngi') do Delegate::Configure.run( write: true, to: 'yaml', destination: CONFIG_FILE, languages: LANGUAGES_HASH, config: CONFIG_HASH, components: COMPONENTS, components_hash: COMPONENTS_HASH, configurable: CONFIGURABLE ) end end p.parse(args) end |