flex_console 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/flex_console.rb +71 -0
- metadata +43 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a7a7956f4562526bc47d90eafa21f04b8b74494d
|
4
|
+
data.tar.gz: 4cd37f6e709fedb67b493db443d0f7fa657df30f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2a4edf69cf510eacbe558c7830a4b9ea67f96fd3c34a6f655a7b70fc9bdac21d034f105547ce1cd6b391179aa05009d7e729839f5c99401052479a47eae0ae15
|
7
|
+
data.tar.gz: 2ccf8ebf4c152fe0a52e2d49ec6c0ba157e28f8d38e990fb78d4b5482124fbff173470343a8b128595060d75d5dd410f5179ce89d5e4f8b8a8c1c1442c47dfb6
|
data/lib/flex_console.rb
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
module FlexConsole
|
2
|
+
|
3
|
+
class << self
|
4
|
+
attr_reader :plain_loop, :bound_obj, :test_object, :test_method,
|
5
|
+
:test_args
|
6
|
+
|
7
|
+
def bind(obj, binding)
|
8
|
+
@plain_loop = ->(message) {
|
9
|
+
begin
|
10
|
+
puts message
|
11
|
+
quit = false
|
12
|
+
counter = 0
|
13
|
+
until quit
|
14
|
+
response = gets.chomp
|
15
|
+
if response == ''
|
16
|
+
counter += 1
|
17
|
+
if counter == 2
|
18
|
+
quit = true
|
19
|
+
end
|
20
|
+
elsif response == 'exit'
|
21
|
+
quit = true
|
22
|
+
else
|
23
|
+
binding.eval(response.strip.gsub("\n", ''))
|
24
|
+
puts '------------------'
|
25
|
+
counter = 0
|
26
|
+
end
|
27
|
+
end
|
28
|
+
rescue Exception => e
|
29
|
+
puts e
|
30
|
+
puts e.message
|
31
|
+
puts e.backtrace
|
32
|
+
puts '---------------'
|
33
|
+
retry
|
34
|
+
end
|
35
|
+
}
|
36
|
+
@binding = binding
|
37
|
+
@bound_obj = obj
|
38
|
+
end
|
39
|
+
|
40
|
+
def bind_lib
|
41
|
+
file = @binding.eval('__FILE__')
|
42
|
+
file_name = file.split('/')[-1]
|
43
|
+
@lib_file = file.split('/')[0..-3].join('/') + "/lib/#{file_name}"
|
44
|
+
end
|
45
|
+
|
46
|
+
def set (test_object, test_method, *test_args)
|
47
|
+
@test_object = test_object
|
48
|
+
@test_method = test_method
|
49
|
+
@test_args = test_args
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
|
54
|
+
def loop_eval(message)
|
55
|
+
FlexConsole.bound_obj.instance_exec(message, &FlexConsole.plain_loop)
|
56
|
+
end
|
57
|
+
|
58
|
+
def reload_lib
|
59
|
+
FlexConsole.binding.eval("load '#{FlexConsole.lib_file}'")
|
60
|
+
end
|
61
|
+
|
62
|
+
def run
|
63
|
+
obj = FlexConsole.test_object
|
64
|
+
method = FlexConsole.test_method
|
65
|
+
args = FlexConsole.test_args
|
66
|
+
|
67
|
+
obj.send(method, *args)
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
|
metadata
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: flex_console
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Eugene Lai
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-26 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: To do
|
14
|
+
email: ejt.lai@gmail.com
|
15
|
+
executables: []
|
16
|
+
extensions: []
|
17
|
+
extra_rdoc_files: []
|
18
|
+
files:
|
19
|
+
- lib/flex_console.rb
|
20
|
+
homepage:
|
21
|
+
licenses: []
|
22
|
+
metadata: {}
|
23
|
+
post_install_message:
|
24
|
+
rdoc_options: []
|
25
|
+
require_paths:
|
26
|
+
- lib
|
27
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
28
|
+
requirements:
|
29
|
+
- - ">="
|
30
|
+
- !ruby/object:Gem::Version
|
31
|
+
version: '0'
|
32
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - ">="
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '0'
|
37
|
+
requirements: []
|
38
|
+
rubyforge_project:
|
39
|
+
rubygems_version: 2.5.2
|
40
|
+
signing_key:
|
41
|
+
specification_version: 4
|
42
|
+
summary: A powerful testing and debugging utility
|
43
|
+
test_files: []
|