module Lucent::API
Public Instance Methods
all_output()
click to toggle source
# File lib/lucent/api.rb, line 46 def all_output all_stdout << all_stderr end
all_stderr()
click to toggle source
# File lib/lucent/api.rb, line 55 def all_stderr stop_processes only_processes.inject('') { |out, ps| out << ps.stderr } end
all_stdout()
click to toggle source
# File lib/lucent/api.rb, line 50 def all_stdout stop_processes only_processes.inject('') { |out, ps| out << ps.stdout } end
assert_exact_output(expected, actual)
click to toggle source
# File lib/lucent/assert.rb, line 33 def assert_exact_output(expected, actual) unescape(actual).should == unescape(expected) end
assert_exit_status(value)
click to toggle source
# File lib/lucent/assert.rb, line 37 def assert_exit_status(value) last_exit_status.should eq(value), "Exit status was #{last_exit_status} but expected it to be #{value}." end
assert_exit_status_and_output(expect_pass, expected, expect_exact)
click to toggle source
# File lib/lucent/assert.rb, line 7 def assert_exit_status_and_output(expect_pass, expected, expect_exact) assert_success(expect_pass) if expect_exact assert_exact_output(expected, all_output) else assert_partial_output(expected, all_output) end end
assert_failing_with(expected)
click to toggle source
# File lib/lucent/assert.rb, line 16 def assert_failing_with(expected) assert_success(false) assert_output(expected, all_output) end
assert_not_exit_status(value)
click to toggle source
# File lib/lucent/assert.rb, line 41 def assert_not_exit_status(value) last_exit_status.should_not eq(value), "Exit status was #{last_exit_status} which was not expected." end
assert_output(expected, actual)
click to toggle source
# File lib/lucent/assert.rb, line 25 def assert_output(expected, actual) actual.should include(expected) end
assert_partial_output(expected, actual)
click to toggle source
# File lib/lucent/assert.rb, line 29 def assert_partial_output(expected, actual) unescape(actual).should include(unescape(expected)) end
assert_success(expect_success)
click to toggle source
# File lib/lucent/assert.rb, line 21 def assert_success(expect_success) expect_success ? assert_exit_status(0) : assert_not_exit_status(0) end
create_file(name, content)
click to toggle source
# File lib/lucent/cli.rb, line 8 def create_file(name, content) in_lucent_directory do create_path_for(File.dirname(name)) File.open(name, 'w') { |f| f << content } end end
create_path_for(name)
click to toggle source
@was _mkdir
# File lib/lucent/api.rb, line 100 def create_path_for(name) FileUtils.mkdir_p(name) unless File.directory?(name) end
create_ruby_command(command)
click to toggle source
# File lib/lucent/api.rb, line 109 def create_ruby_command(command) if command =~ /^ruby\s/ command.gsub(/^ruby\s/, "#{system_ruby} ") else command end end
in_lucent_directory(&block)
click to toggle source
@was in_current_dir
# File lib/lucent/api.rb, line 83 def in_lucent_directory(&block) create_path_for(lucent_directory) Dir.chdir(lucent_directory, &block) end
last_exit_status()
click to toggle source
# File lib/lucent/api.rb, line 40 def last_exit_status return @last_exit_status if @last_exit_status stop_processes @last_exit_status end
lucent_directory()
click to toggle source
@was current_dir
# File lib/lucent/api.rb, line 89 def lucent_directory File.join(*lucent_path) end
lucent_path()
click to toggle source
@was dirs Note: @path was @dirs
# File lib/lucent/api.rb, line 95 def lucent_path @path ||= %w(tmp lucent) end
only_processes()
click to toggle source
# File lib/lucent/api.rb, line 78 def only_processes processes.collect { |command, process| process } end
processes()
click to toggle source
# File lib/lucent/api.rb, line 60 def processes @processes ||= [] end
register_process(command, process)
click to toggle source
# File lib/lucent/api.rb, line 64 def register_process(command, process) processes << [command, process] end
run(command) { |process| ... }
click to toggle source
# File lib/lucent/api.rb, line 16 def run(command) @commands ||= [] @commands << command puts "DEBUG: @commands = #{@commands}" command = create_ruby_command(command) puts "DEBUG: (ruby) command = #{command}" puts "DEBUG: Lucent.process = #{Lucent.process}" in_lucent_directory do process = Lucent.process.new(command) puts "DEBUG: Process = #{process.inspect}" register_process(command, process) process.run puts "DEBUG: Block given for run standard? #{block_given?}" block_given? ? yield(process) : process end end
run_standard(command)
click to toggle source
# File lib/lucent/api.rb, line 10 def run_standard(command) run(command) do |process| stop_process(process) end end
stop_process(process)
click to toggle source
# File lib/lucent/api.rb, line 68 def stop_process(process) @last_exit_status = process.stop end
stop_processes()
click to toggle source
# File lib/lucent/api.rb, line 72 def stop_processes processes.each do |command, process| stop_process(process) end end
system_ruby()
click to toggle source
# File lib/lucent/api.rb, line 117 def system_ruby File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) end
unescape(string)
click to toggle source
# File lib/lucent/api.rb, line 104 def unescape(string) string = string.gsub(/\e\[\d+(?>(;\d+)*)m/, '') string end
write_file(name, content)
click to toggle source
# File lib/lucent/cli.rb, line 4 def write_file(name, content) create_file(name, content) end