Class: Hypercuke::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/hypercuke/cli.rb,
lib/hypercuke/cli/parser.rb,
lib/hypercuke/cli/builder.rb

Defined Under Namespace

Classes: Builder, Parser

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv, output = nil, environment = ENV, kernel = Kernel) ⇒ CLI

Returns a new instance of CLI.



17
18
19
20
21
22
# File 'lib/hypercuke/cli.rb', line 17

def initialize(argv, output = nil, environment = ENV, kernel = Kernel)
  @argv        = argv
  @output      = output
  @environment = environment
  @kernel      = kernel
end

Class Method Details

.bundler_present?Boolean

NB: .bundler_present? is not covered by tests, because I can’t think of a reasonable way to test it. PRs welcome. :)

Returns:

  • (Boolean)


13
14
15
# File 'lib/hypercuke/cli.rb', line 13

def self.bundler_present?
  !! (`which bundle` =~ /\wbundle\w/) # parens are significant
end

.exec(argv, opts = {}) ⇒ Object



6
7
8
9
# File 'lib/hypercuke/cli.rb', line 6

def self.exec(argv, opts = {})
  cli = new(argv, opts[:output_to])
  cli.run!
end

Instance Method Details

#cucumber_commandObject



34
35
36
# File 'lib/hypercuke/cli.rb', line 34

def cucumber_command
  builder.cucumber_command_line(self.class.bundler_present?)
end

#cucumber_command_for_displayObject



38
39
40
# File 'lib/hypercuke/cli.rb', line 38

def cucumber_command_for_display
  "HYPERCUKE_LAYER=#{layer_name} #{cucumber_command}"
end

#layer_nameObject



30
31
32
# File 'lib/hypercuke/cli.rb', line 30

def layer_name
  parser.layer_name
end

#run!Object



24
25
26
27
28
# File 'lib/hypercuke/cli.rb', line 24

def run!
  output && output.puts(cucumber_command_for_display)
  new_env = environment.to_hash.merge({ Hypercuke::LAYER_NAME_ENV_VAR => layer_name })
  kernel.exec new_env, cucumber_command
end