Module: Scaffolder::BinaryHelper

Includes:
ToolIndex
Defined in:
lib/scaffolder/binary_helper.rb

Constant Summary collapse

DEFAULT_TOOL =
Scaffolder::Tool::Help

Instance Method Summary collapse

Instance Method Details

#determine_tool(settings) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/scaffolder/binary_helper.rb', line 16

def determine_tool(settings)
  name = remove_first_argument(settings)

  tool_class = select_tool(name)

  if name.nil?
    settings[:empty_args] = true
  elsif not tool_exists?(name)
    settings[:unknown_tool] = name
  end

  [tool_class,settings]
end

#remove_first_argument(settings) ⇒ Object



12
13
14
# File 'lib/scaffolder/binary_helper.rb', line 12

def remove_first_argument(settings)
  name = settings.rest.shift
end

#select_tool(name) ⇒ Object



8
9
10
# File 'lib/scaffolder/binary_helper.rb', line 8

def select_tool(name)
  tool_exists?(name) ? get_tool(name) : DEFAULT_TOOL
end