class Bane::CommandLineConfiguration

Public Class Methods

new(makeables) click to toggle source
# File lib/bane/command_line_configuration.rb, line 12
def initialize(makeables)
  @behavior_maker = BehaviorMaker.new(makeables)
  @arguments_parser = ArgumentsParser.new(makeables.keys)
end

Public Instance Methods

process(args, &error_policy) click to toggle source
# File lib/bane/command_line_configuration.rb, line 17
def process(args, &error_policy)
  arguments = @arguments_parser.parse(args)
  create(arguments.behaviors, arguments.port, arguments.host)
rescue ConfigurationError => ce
  error_policy.call([ce.message, @arguments_parser.usage].join("\n"))
end

Private Instance Methods

create(behaviors, port, host) click to toggle source
# File lib/bane/command_line_configuration.rb, line 26
def create(behaviors, port, host)
  if behaviors.any?
    @behavior_maker.create(behaviors, port, host)
  else
    @behavior_maker.create_all(port, host)
  end
rescue UnknownBehaviorError => ube
  raise ConfigurationError, ube.message
end