Module: FlexConsole
- Defined in:
- lib/flex_console.rb
Class Attribute Summary collapse
-
.bound_obj ⇒ Object
readonly
Returns the value of attribute bound_obj.
-
.plain_loop ⇒ Object
readonly
Returns the value of attribute plain_loop.
-
.test_args ⇒ Object
readonly
Returns the value of attribute test_args.
-
.test_method ⇒ Object
readonly
Returns the value of attribute test_method.
-
.test_object ⇒ Object
readonly
Returns the value of attribute test_object.
Class Method Summary collapse
Instance Method Summary collapse
Class Attribute Details
.bound_obj ⇒ Object (readonly)
Returns the value of attribute bound_obj.
4 5 6 |
# File 'lib/flex_console.rb', line 4 def bound_obj @bound_obj end |
.plain_loop ⇒ Object (readonly)
Returns the value of attribute plain_loop.
4 5 6 |
# File 'lib/flex_console.rb', line 4 def plain_loop @plain_loop end |
.test_args ⇒ Object (readonly)
Returns the value of attribute test_args.
4 5 6 |
# File 'lib/flex_console.rb', line 4 def test_args @test_args end |
.test_method ⇒ Object (readonly)
Returns the value of attribute test_method.
4 5 6 |
# File 'lib/flex_console.rb', line 4 def test_method @test_method end |
.test_object ⇒ Object (readonly)
Returns the value of attribute test_object.
4 5 6 |
# File 'lib/flex_console.rb', line 4 def test_object @test_object end |
Class Method Details
.bind(obj, binding) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/flex_console.rb', line 7 def bind(obj, binding) @plain_loop = ->() { begin puts quit = false counter = 0 until quit response = gets.chomp if response == '' counter += 1 if counter == 2 quit = true end elsif response == 'exit' quit = true else binding.eval(response.strip.gsub("\n", '')) puts '------------------' counter = 0 end end rescue Exception => e puts e puts e. puts e.backtrace puts '---------------' retry end } @binding = binding @bound_obj = obj end |
.bind_lib ⇒ Object
40 41 42 43 44 |
# File 'lib/flex_console.rb', line 40 def bind_lib file = @binding.eval('__FILE__') file_name = file.split('/')[-1] @lib_file = file.split('/')[0..-3].join('/') + "/lib/#{file_name}" end |
.set(test_object, test_method, *test_args) ⇒ Object
46 47 48 49 50 |
# File 'lib/flex_console.rb', line 46 def set (test_object, test_method, *test_args) @test_object = test_object @test_method = test_method @test_args = test_args end |
Instance Method Details
#loop_eval(message) ⇒ Object
54 55 56 |
# File 'lib/flex_console.rb', line 54 def loop_eval() FlexConsole.bound_obj.instance_exec(, &FlexConsole.plain_loop) end |
#reload_lib ⇒ Object
58 59 60 |
# File 'lib/flex_console.rb', line 58 def reload_lib FlexConsole.binding.eval("load '#{FlexConsole.lib_file}'") end |
#run ⇒ Object
62 63 64 65 66 67 68 |
# File 'lib/flex_console.rb', line 62 def run obj = FlexConsole.test_object method = FlexConsole.test_method args = FlexConsole.test_args obj.send(method, *args) end |