Class: Thor::Actions::Resource
- Inherits:
-
Object
- Object
- Thor::Actions::Resource
- Includes:
- Angus::FileHandler, Angus::HelperMethods
- Defined in:
- lib/angus/generator/thor/resource.rb
Overview
:nodoc:
Constant Summary collapse
- FILE_MAPPINGS =
{ 'resources/resource.rb.erb' => -> command, name { "#{command.underscore(command.classify(name))}.rb" }, 'definitions/operations.yml.erb' => -> command, _ { File.join(command.underscore(command.resource_name), 'operations.yml') } }
Instance Attribute Summary collapse
-
#actions ⇒ Object
Returns the value of attribute actions.
-
#base ⇒ Object
Returns the value of attribute base.
-
#config ⇒ Object
Returns the value of attribute config.
-
#definition_directory ⇒ Object
Returns the value of attribute definition_directory.
-
#resource_directory ⇒ Object
Returns the value of attribute resource_directory.
-
#resource_name ⇒ Object
Returns the value of attribute resource_name.
-
#service_directory ⇒ Object
Returns the value of attribute service_directory.
Instance Method Summary collapse
-
#initialize(base, name, actions, config) ⇒ Resource
constructor
Creates a new resource.
- #invoke! ⇒ Object
- #revoke! ⇒ Object
Methods included from Angus::FileHandler
#copy_erb_file, #filename_resolver, #is_erb?
Methods included from Angus::HelperMethods
#classify, #pluralize, #underscore
Constructor Details
#initialize(base, name, actions, config) ⇒ Resource
Creates a new resource.
35 36 37 38 39 40 41 42 43 |
# File 'lib/angus/generator/thor/resource.rb', line 35 def initialize(base, name, actions, config) @base, @config = base, { :verbose => true }.merge(config) self.resource_name = pluralize(name) self.actions = actions self.resource_directory = File.join(Dir.pwd, Angus::CommandProcessor::RESOURCES_DIR) self.definition_directory = File.join(Dir.pwd, Angus::CommandProcessor::DEFINITIONS_DIR) self.service_directory = File.join(Dir.pwd, Angus::CommandProcessor::SERVICES_DIR) end |
Instance Attribute Details
#actions ⇒ Object
Returns the value of attribute actions.
29 30 31 |
# File 'lib/angus/generator/thor/resource.rb', line 29 def actions @actions end |
#base ⇒ Object
Returns the value of attribute base.
29 30 31 |
# File 'lib/angus/generator/thor/resource.rb', line 29 def base @base end |
#config ⇒ Object
Returns the value of attribute config.
29 30 31 |
# File 'lib/angus/generator/thor/resource.rb', line 29 def config @config end |
#definition_directory ⇒ Object
Returns the value of attribute definition_directory.
29 30 31 |
# File 'lib/angus/generator/thor/resource.rb', line 29 def definition_directory @definition_directory end |
#resource_directory ⇒ Object
Returns the value of attribute resource_directory.
29 30 31 |
# File 'lib/angus/generator/thor/resource.rb', line 29 def resource_directory @resource_directory end |
#resource_name ⇒ Object
Returns the value of attribute resource_name.
29 30 31 |
# File 'lib/angus/generator/thor/resource.rb', line 29 def resource_name @resource_name end |
#service_directory ⇒ Object
Returns the value of attribute service_directory.
29 30 31 |
# File 'lib/angus/generator/thor/resource.rb', line 29 def service_directory @service_directory end |
Instance Method Details
#invoke! ⇒ Object
45 46 47 48 49 50 51 52 |
# File 'lib/angus/generator/thor/resource.rb', line 45 def invoke! base.empty_directory(resource_directory) base.empty_directory(definition_directory) copy_erb_file('resources/resource.rb.erb', underscore(resource_name), resource_directory) copy_erb_file('definitions/operations.yml.erb', underscore(resource_name), definition_directory) insert_into_services(" register :#{underscore(resource_name)}\n") end |
#revoke! ⇒ Object
54 55 56 |
# File 'lib/angus/generator/thor/resource.rb', line 54 def revoke! end |