Module: InfinityTest::Builder

Included in:
TestFramework
Defined in:
lib/infinity_test/builder.rb

Instance Method Summary collapse

Instance Method Details

#construct_command(options) ⇒ Object

TODO: Refactoring this Ugly Code



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/infinity_test/builder.rb', line 8

def construct_command(options)
  binary_name, ruby_version, command, file, environment, specific_options = resolve_options(options)

  unless have_binary?(binary_name) || options[:skip_binary?]
    print_message(binary_name, ruby_version)
  else
    command = "#{command} #{decide_files(file)}"
    rvm_ruby_version = "rvm #{ruby_version} ruby #{specific_options}"

   if application.have_gemfile? and not application.skip_bundler?
      run_with_bundler!(rvm_ruby_version, command, environment)
    else
      run_without_bundler!(rvm_ruby_version, command)
    end
  end
end

#construct_commands(file = nil) ⇒ Object

Contruct all the Commands for each ruby instance variable If don’t want to run with many rubies, add the current ruby to the rubies instance and create the command with current ruby



45
46
47
48
# File 'lib/infinity_test/builder.rb', line 45

def construct_commands(file=nil)
  @rubies << RVM::Environment.current.environment_name if @rubies.empty?
  construct_rubies_commands(file)
end

#resolve_options(options) ⇒ Object

TODO: Refactoring this Ugly Code



54
55
56
57
58
59
60
61
62
63
# File 'lib/infinity_test/builder.rb', line 54

def resolve_options(options)
  ruby_version = options[:for]
  binary_name = options[:skip_binary?] ? '' : options[:binary]
  load_path = %{-I"#{options[:load_path]}"} if options[:load_path]
  environment = options[:environment]
  file = options[:file]
  specific_options = options[:specific_options]
  command = [ binary_name, load_path].compact.join(' ')
  [binary_name, ruby_version, command, file, environment, specific_options]
end

#run_with_bundler!(rvm_ruby_version, command, environment) ⇒ Object



26
27
28
29
30
31
32
33
# File 'lib/infinity_test/builder.rb', line 26

def run_with_bundler!(rvm_ruby_version, command, environment)
  bundle_binary = search_bundle(environment)
  unless have_binary?(bundle_binary)
    print_message('bundle', environment.expanded_name)
  else
    %{#{bundle_binary} exec #{rvm_ruby_version} #{command}}
  end
end

#run_without_bundler!(rvm_ruby_version, command) ⇒ Object



36
37
38
# File 'lib/infinity_test/builder.rb', line 36

def run_without_bundler!(rvm_ruby_version, command)
  %{#{rvm_ruby_version} #{command}}
end