class Pleiades::CommandGenerator

Public Instance Methods

drow_route() click to toggle source
# File lib/pleiades/generators/pleiades/command/command_generator.rb, line 39
def drow_route
  @names.each do |name|
    arg =
      [
        Pleiades::Constants::File::ROUTER,
        event_with_option(name),
        { after: /^Pleiades::Command::Router.route do/ }
      ]
    inject_into_file(*arg)
  end
end
generate_command() click to toggle source
# File lib/pleiades/generators/pleiades/command/command_generator.rb, line 31
def generate_command
  commands_path = Pleiades::Config.command.commands_path
  @names.each do |name|
    @command_name = name
    template 'command.erb', "#{commands_path}/#{options['dir']}/#{name}.rb"
  end
end
setup() click to toggle source
# File lib/pleiades/generators/pleiades/command/command_generator.rb, line 27
def setup
  @names.unshift @name
end

Private Instance Methods

dirs() click to toggle source
# File lib/pleiades/generators/pleiades/command/command_generator.rb, line 70
def dirs
  options['dir'].split('/')
end
event_specific_options() click to toggle source
# File lib/pleiades/generators/pleiades/command/command_generator.rb, line 64
def event_specific_options
  EventOption.const_get options['event_type'].capitalize
rescue NameError => _e
  nil
end
event_with_option(name) click to toggle source
# File lib/pleiades/generators/pleiades/command/command_generator.rb, line 53
def event_with_option(name)
  option = event_specific_options

  str =  "\n  #{options['event_type']}"
  str += " action: '#{name}'"
  str += ", scope: '#{options['dir']}'" if options['dir']
  str += ", #{option}" if option

  str
end