Class: Shaf::Command::Generate

Inherits:
Base
  • Object
show all
Defined in:
lib/shaf/command/generate.rb

Constant Summary

Constants included from Utils

Utils::SHAF_VERSION_FILE

Instance Attribute Summary

Attributes inherited from Base

#args, #options

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

exit_with_error, identified_by, identifier, inherited, #initialize, usage

Methods included from Utils

#bootstrap, deep_symbolize_keys, deep_transform_keys, deep_transform_values, environment, gem_root, iana_link_relations, #in_project_root, #in_project_root?, #is_project_root?, model_name, pluralize, #project_root, #project_root!, rackify_header, read_config, #read_shaf_file, #read_shaf_file!, #read_shaf_upgrade_failure_version, #read_shaf_version, singularize, symbol_or_quoted_string, symbol_string, #write_shaf_file, #write_shaf_file!, #write_shaf_upgrade_failure, #write_shaf_version

Constructor Details

This class inherits a constructor from Shaf::Command::Base

Class Method Details

.options(parser, options) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/shaf/command/generate.rb', line 11

def self.options(parser, options)
  parser.on("-s", "--[no-]specs", "generate specs") do |s|
    options[:specs] = s
  end

  Generator::Factory.each do |clazz|
    clazz.options(parser, options)
  end
end

Instance Method Details

#callObject



21
22
23
24
25
26
27
28
29
# File 'lib/shaf/command/generate.rb', line 21

def call
  in_project_root do
    FileTransactions.transaction do
      Generator::Factory.create(*args, **options).call
    end
  end
rescue StandardError => e
  raise Command::ArgumentError, e.message
end