quick 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/quick +2 -6
- data/lib/quick.rb +13 -5
- metadata +1 -1
data/bin/quick
CHANGED
@@ -61,12 +61,8 @@ class QuickCLI < Thor
|
|
61
61
|
desc 'eval CODE', "evaluate some code in an instance of the current module"
|
62
62
|
option :module, type: :boolean, aliases: :m
|
63
63
|
def eval(code)
|
64
|
-
|
65
|
-
|
66
|
-
puts "=> #{result}"
|
67
|
-
else
|
68
|
-
puts "error: #{result}"
|
69
|
-
end
|
64
|
+
result = Quick.eval_here code, !options.module?
|
65
|
+
puts "=> #{result}"
|
70
66
|
end
|
71
67
|
end
|
72
68
|
|
data/lib/quick.rb
CHANGED
@@ -5,7 +5,7 @@ require_relative 'quick/service'
|
|
5
5
|
module Quick
|
6
6
|
extend self
|
7
7
|
|
8
|
-
VERSION = '0.2.
|
8
|
+
VERSION = '0.2.2'
|
9
9
|
|
10
10
|
def brb_service
|
11
11
|
@brb_service ||=
|
@@ -35,18 +35,26 @@ module Quick
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def eval_here(code, instance=true)
|
38
|
-
brb_service.eval_block pwd_from_root, code, instance
|
38
|
+
success, result = brb_service.eval_block pwd_from_root, code, instance
|
39
|
+
if success
|
40
|
+
result
|
41
|
+
else
|
42
|
+
raise result
|
43
|
+
end
|
39
44
|
end
|
40
45
|
|
41
46
|
def module_here(name)
|
42
|
-
|
47
|
+
const_defined? name
|
43
48
|
brb_service.new_mod_block pwd_from_root, name
|
49
|
+
rescue NameError
|
50
|
+
raise "invalid module name"
|
44
51
|
end
|
45
52
|
|
46
53
|
def class_here(name, super_path='Object')
|
47
|
-
|
48
|
-
p [pwd_from_root, name, from_root(super_path)]
|
54
|
+
const_defined? name
|
49
55
|
brb_service.new_mod_block pwd_from_root, name, from_root(super_path)
|
56
|
+
rescue NameError
|
57
|
+
raise "invalid class name"
|
50
58
|
end
|
51
59
|
|
52
60
|
def pwd_from_root
|