Class: TestBuffer
- Inherits:
-
Array
- Object
- Array
- TestBuffer
- Defined in:
- lib/orb/test_buffer.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
4 5 6 |
# File 'lib/orb/test_buffer.rb', line 4 def name @name end |
Instance Method Details
#edit_contents! ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/orb/test_buffer.rb', line 6 def edit_contents! path = "#{Dir::tmpdir}/orb-#{Kernel.rand 1000000}.rb" begin File.open(path, "w") do |f| f.write(join("\n")) f.flush system("#{ENV['EDITOR'] || '/usr/bin/vim'} #{f.path}") replace(File.read(f.path).lines.map(&:chomp)) end ensure File.unlink(path) end end |
#run ⇒ Object
20 21 22 23 24 |
# File 'lib/orb/test_buffer.rb', line 20 def run each do |line| eval(line) end end |
#write ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/orb/test_buffer.rb', line 26 def write str = "".tap do |test| test << "test \"#{name}\" do\n" each do |line| test << " " << line << "\n" end test << "end\n" end puts str end |