Class: PicoApi::Generators::Generator

Inherits:
Object
  • Object
show all
Defined in:
lib/pico_api/generators/generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_name, commands = []) ⇒ Generator

Returns a new instance of Generator.



29
30
31
32
33
34
# File 'lib/pico_api/generators/generator.rb', line 29

def initialize(project_name, commands = [])
  raise 'Missing project name' unless project_name

  @project_name = project_name
  @commands = commands
end

Class Method Details

.call(project_name) ⇒ Object



7
8
9
# File 'lib/pico_api/generators/generator.rb', line 7

def call(project_name)
  new(project_name, loaded_commands).call
end

.loaded_commandsObject



11
12
13
14
15
16
# File 'lib/pico_api/generators/generator.rb', line 11

def loaded_commands
  command_files.sort.map do |file_path|
    file_name = camelized_file_name(file_path)
    "PicoApi::Generators::Commands::#{file_name}".constantize
  end.compact
end

Instance Method Details

#callObject



36
37
38
# File 'lib/pico_api/generators/generator.rb', line 36

def call
  commands.each { |command| command.call(project_name) }
end