Module: Panacea::Rails::ArgumentsParser

Included in:
Runner
Defined in:
lib/panacea/rails/arguments_parser.rb

Overview

Panacea::Rails::ArgumentsParser

This module is in charge Parsing Slop Arguments.

Instance Method Summary collapse

Instance Method Details

#parse_arguments(arguments) ⇒ Object

This method builds an arguments String from the Slop args Hash.

The string will be passed to the ‘rails new` command and it will be also tracked if the end user agrees to share Panacea’s usage information



15
16
17
18
19
20
21
22
23
24
# File 'lib/panacea/rails/arguments_parser.rb', line 15

def parse_arguments(arguments)
  arguments.each_with_object([]) do |arg, parsed_args|
    case arg.last.class.to_s
    when "String"
      parsed_args << "--#{arg.first}=#{arg.last}"
    when "TrueClass"
      parsed_args << "--#{arg.first}"
    end
  end.join(" ")
end