Class: CommandLine::ComponentGenerator::Commands::Component

Inherits:
Thor::Group
  • Object
show all
Includes:
Thor::Actions
Defined in:
lib/command_line/component_generator/commands/component.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args = [], options = {}, config = {}) ⇒ Component

Returns a new instance of Component.



41
42
43
44
# File 'lib/command_line/component_generator/commands/component.rb', line 41

def initialize(args=[], options={}, config={})
  super
  self.destination_root = component_root_dir_name
end

Class Method Details

.source_rootObject



37
38
39
# File 'lib/command_line/component_generator/commands/component.rb', line 37

def self.source_root
  File.dirname(__FILE__) + '/../../../../source'
end

Instance Method Details

#assign_executable_attributeObject



50
51
52
53
54
55
# File 'lib/command_line/component_generator/commands/component.rb', line 50

def assign_executable_attribute
  chmod './install-gems.sh', 0755
  chmod './test.sh', 0755
  chmod 'script/test-database-connection', 0755
  chmod 'script/start', 0755
end

#component_constant_nameObject



17
18
19
# File 'lib/command_line/component_generator/commands/component.rb', line 17

def component_constant_name
  @component_constant_name ||= Casing::Pascal.(component_name)
end

#component_nameObject



9
10
11
# File 'lib/command_line/component_generator/commands/component.rb', line 9

def component_name
  @component_name ||= name.end_with?('_component') ? name : "#{name}_component"
end

#component_root_dir_nameObject



13
14
15
# File 'lib/command_line/component_generator/commands/component.rb', line 13

def component_root_dir_name
  @component_dir_name ||= component_name.gsub('_','-')
end

#entity_constant_nameObject



29
30
31
# File 'lib/command_line/component_generator/commands/component.rb', line 29

def entity_constant_name
  @entity_constant_name ||= Casing::Pascal.(component_name.gsub('_component', ''))
end

#entity_nameObject



21
22
23
# File 'lib/command_line/component_generator/commands/component.rb', line 21

def entity_name
  @entity_name ||= Casing::Underscore.(entity_constant_name)
end

#entity_stream_nameObject



25
26
27
# File 'lib/command_line/component_generator/commands/component.rb', line 25

def entity_stream_name
  @entity_stream_name ||= Casing::Camel.(entity_name)
end

#generate_componentObject



46
47
48
# File 'lib/command_line/component_generator/commands/component.rb', line 46

def generate_component
  directory('./')
end

#service_nameObject



33
34
35
# File 'lib/command_line/component_generator/commands/component.rb', line 33

def service_name
  @service_name ||= entity_name.gsub('_', '-')
end