superscript 0.4.2 → 0.5.0
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/e2e/dsls/go.rb +9 -1
- data/e2e/test.rb +0 -2
- data/lib/superscript/runner.rb +38 -10
- data/lib/superscript/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2b7dee019db4e0c13b9a654eac37c84d4e736254709b2423726ecc8e559ecbe
|
4
|
+
data.tar.gz: 7b7e43e336d1c7ab0a2a60eb1947efcc0afcdc3115f5b5de3f61a950b1dbd4fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51d7792af18af63fe4f37a18f99d60faa1a231e36c11ae778c11045b568b541ee4d920e63d757344a9e82b551b3969fbc5a24691afdefdb092d6f466ca90ed4b
|
7
|
+
data.tar.gz: 24c1e948e23287751a7a33f6905cba77c20b6ec8672b2b468e4148d5766362a9f220aa07b4e29b461de7802cdab828ad30c24bc9d90b50312227347071465563
|
data/Gemfile.lock
CHANGED
data/e2e/dsls/go.rb
CHANGED
data/e2e/test.rb
CHANGED
data/lib/superscript/runner.rb
CHANGED
@@ -8,6 +8,8 @@ module Superscript
|
|
8
8
|
pp exception
|
9
9
|
pp exception.backtrace_locations
|
10
10
|
error_message = exception
|
11
|
+
when :tp_call_superscript
|
12
|
+
error_message = "Can't touch this"
|
11
13
|
when :ctx_method_missing, :tp_singleton_method_added, :tp_command_not_found
|
12
14
|
error_message = args.first
|
13
15
|
when :tp_class_define, :tp_module_define
|
@@ -26,6 +28,7 @@ module Superscript
|
|
26
28
|
end
|
27
29
|
class Runner
|
28
30
|
def initialize path=nil
|
31
|
+
@armed = false
|
29
32
|
@path = if path
|
30
33
|
path
|
31
34
|
else
|
@@ -33,25 +36,38 @@ module Superscript
|
|
33
36
|
end
|
34
37
|
end
|
35
38
|
|
39
|
+
def arm!(reason=nil)
|
40
|
+
p [:arm!, reason] if ENV["SUPERSCRIPT_DEBUG"]
|
41
|
+
@armed = true
|
42
|
+
end
|
43
|
+
def disarm!(reason=nil)
|
44
|
+
p [:disarm!, reason] if ENV["SUPERSCRIPT_DEBUG"]
|
45
|
+
@armed = false
|
46
|
+
end
|
47
|
+
|
36
48
|
def run!(ctx, contents:nil)
|
37
49
|
contents = File.read(@path) unless contents
|
38
50
|
|
39
|
-
|
51
|
+
disarm! :at_start
|
40
52
|
trace = TracePoint.new do |tp|
|
41
53
|
if ENV["SUPERSCRIPT_DEBUG"]
|
42
54
|
p [@armed, tp.path, tp.lineno, tp.method_id, tp.event, tp.defined_class]
|
43
55
|
end
|
44
56
|
|
57
|
+
if tp.event == :line && tp.path == @path && !@armed
|
58
|
+
arm!
|
59
|
+
end
|
60
|
+
|
45
61
|
if tp.defined_class&.name == "BasicObject" && tp.method_id == :instance_eval
|
46
62
|
if tp.event == :script_compiled
|
47
|
-
|
63
|
+
arm! :script_compiled
|
48
64
|
elsif tp.event == :c_return
|
49
|
-
|
65
|
+
disarm! :script_done
|
50
66
|
end
|
51
67
|
end
|
52
68
|
|
53
|
-
if tp.event == :return && tp.defined_class.ancestors.include?(Superscript::Ctx)
|
54
|
-
|
69
|
+
if tp.path == @path && tp.event == :return && tp.defined_class.ancestors.include?(Superscript::Ctx)
|
70
|
+
arm! :return_to_script_from_dsl_calling_another_dsl_method
|
55
71
|
end
|
56
72
|
|
57
73
|
next unless @armed
|
@@ -71,7 +87,10 @@ module Superscript
|
|
71
87
|
puts line
|
72
88
|
when :c_call
|
73
89
|
# allow calls to these classes
|
74
|
-
|
90
|
+
if ["Array", "String","Float", "Integer"].include? tp.defined_class.name
|
91
|
+
disarm! :safe_class
|
92
|
+
next
|
93
|
+
end
|
75
94
|
|
76
95
|
case tp.method_id
|
77
96
|
when :singleton_method_added
|
@@ -106,13 +125,22 @@ module Superscript
|
|
106
125
|
end
|
107
126
|
end
|
108
127
|
when :call
|
128
|
+
if tp.defined_class.ancestors.first.to_s == "#<Class:Superscript>"
|
129
|
+
tp.disable
|
130
|
+
::Superscript.error :tp_call_superscript
|
131
|
+
end
|
109
132
|
# disable if calling some other file
|
110
|
-
|
111
|
-
|
133
|
+
# but do not allow call to Superscript.error etc
|
134
|
+
if tp.path != @path
|
135
|
+
disarm! :calling_other_file
|
112
136
|
end
|
113
|
-
|
114
|
-
|
137
|
+
tp.defined_class.ancestors.each do |ancestor|
|
138
|
+
if ancestor.to_s == "Superscript::Dsl"
|
139
|
+
disarm! :dsl_method
|
140
|
+
break
|
141
|
+
end
|
115
142
|
end
|
143
|
+
|
116
144
|
end
|
117
145
|
end
|
118
146
|
|
data/lib/superscript/version.rb
CHANGED