superscript 0.3.3 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/e2e/dsls/go.rb +4 -0
- data/e2e/test.rb +2 -0
- data/lib/superscript/ctx.rb +1 -2
- data/lib/superscript/runner.rb +75 -7
- data/lib/superscript/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b9eb09b767191fff8dbd2b482c5b39ed0fe6a05d58604544e0e6c8d3db05660
|
4
|
+
data.tar.gz: 7a4e5dbb72eaa3c7e663ece42ca090116ae58f222309fb5d900408873bf7cb6e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ad60a7b3cbfea6f5f45438afa190dd8dbe2be4f200355f345486643ba3368f3133e5639cd74b0728ba5ab7be20a8ac0eadfa94b7bf8555d174db0bf570f13b42
|
7
|
+
data.tar.gz: 5d539f831d963e171ab9d6d4e7050b6ccf5af35c0358e46d188d27a3953e872b43adb9760c615d7ed73ad5d9472adbb76450167956d58d62306acb59550f8836
|
data/Gemfile.lock
CHANGED
data/e2e/dsls/go.rb
CHANGED
data/e2e/test.rb
CHANGED
data/lib/superscript/ctx.rb
CHANGED
data/lib/superscript/runner.rb
CHANGED
@@ -1,4 +1,29 @@
|
|
1
1
|
module Superscript
|
2
|
+
def self.error(where, *args)
|
3
|
+
puts "-- [ superscript error ] --"
|
4
|
+
error_message = ""
|
5
|
+
case where
|
6
|
+
when :exception
|
7
|
+
exception = args.first
|
8
|
+
pp exception
|
9
|
+
pp exception.backtrace_locations
|
10
|
+
error_message = exception
|
11
|
+
when :ctx_method_missing, :tp_singleton_method_added, :tp_command_not_found
|
12
|
+
error_message = args.first
|
13
|
+
when :tp_class_define, :tp_module_define
|
14
|
+
error_message = args.first
|
15
|
+
else
|
16
|
+
pp [:unknown_where, where, args]
|
17
|
+
error_message = args.join(" ")
|
18
|
+
end
|
19
|
+
|
20
|
+
puts error_message
|
21
|
+
if ENV["SUPERSCRIPT_ERROR_EXEC"]
|
22
|
+
error_exec_pid = spawn ENV["SUPERSCRIPT_ERROR_EXEC"], error_message
|
23
|
+
Process.wait error_exec_pid
|
24
|
+
end
|
25
|
+
exit 1
|
26
|
+
end
|
2
27
|
class Runner
|
3
28
|
def initialize path=nil
|
4
29
|
@path = if path
|
@@ -29,24 +54,67 @@ module Superscript
|
|
29
54
|
@armed = true
|
30
55
|
end
|
31
56
|
|
57
|
+
# when returns to execute our script, always force armed
|
58
|
+
if tp.path == @path
|
59
|
+
@armed = true
|
60
|
+
end
|
61
|
+
|
32
62
|
next unless @armed
|
33
63
|
|
34
64
|
case tp.event
|
65
|
+
when :class
|
66
|
+
::Superscript.error :tp_module_define, "Defining modules is not allowed"
|
35
67
|
when :line
|
36
|
-
|
68
|
+
lines = if tp.path == "<interactive>"
|
69
|
+
contents.split("\n")
|
70
|
+
else
|
71
|
+
File.read(tp.path).split("\n")
|
72
|
+
end
|
73
|
+
|
74
|
+
line = lines[tp.lineno-1].lstrip
|
75
|
+
puts "< #{tp.path}:#{tp.lineno-1}"
|
76
|
+
puts line
|
37
77
|
when :c_call
|
38
|
-
|
78
|
+
# allow calls to these classes
|
79
|
+
next if ["Array", "String","Float", "Integer"].include? tp.defined_class.name
|
80
|
+
|
39
81
|
case tp.method_id
|
40
82
|
when :singleton_method_added
|
41
|
-
puts "Error: Deffining methods is not allowed"
|
42
83
|
trace.disable
|
43
|
-
|
84
|
+
::Superscript.error :tp_singleton_method_added, "Deffining methods is not allowed"
|
44
85
|
else
|
45
|
-
puts "Error: Command not found '#{tp.method_id}'"
|
46
86
|
trace.disable
|
47
|
-
|
87
|
+
case tp.defined_class.name
|
88
|
+
when "Class"
|
89
|
+
::Superscript.error :tp_class_define, "Defining classes is not allowed"
|
90
|
+
else
|
91
|
+
class_name = case tp.defined_class.inspect
|
92
|
+
when "Kernel"
|
93
|
+
"Kernel"
|
94
|
+
when "Module"
|
95
|
+
"Module"
|
96
|
+
when "Exception"
|
97
|
+
"Exception"
|
98
|
+
else
|
99
|
+
class_name_matches = tp.defined_class.inspect.match(/^#<.*:(.*)>$/)
|
100
|
+
class_name_matches[1]
|
101
|
+
end
|
102
|
+
|
103
|
+
command_name = case class_name
|
104
|
+
when "Kernel", "Module", "Exception"
|
105
|
+
tp.method_id
|
106
|
+
else
|
107
|
+
"#{class_name}.#{tp.method_id}"
|
108
|
+
end
|
109
|
+
|
110
|
+
::Superscript.error :tp_command_not_found, "Command not found '#{command_name}'"
|
111
|
+
end
|
48
112
|
end
|
49
113
|
when :call
|
114
|
+
# disable if calling some other file
|
115
|
+
unless tp.path == @path
|
116
|
+
@armed = false
|
117
|
+
end
|
50
118
|
if tp.defined_class.ancestors.include? Superscript::Ctx
|
51
119
|
@armed = false
|
52
120
|
end
|
@@ -66,7 +134,7 @@ module Superscript
|
|
66
134
|
print "#{@path}:#{ex.backtrace_locations.first.lineno} "
|
67
135
|
puts ex.message.split(" for ").first
|
68
136
|
else
|
69
|
-
|
137
|
+
::Superscript.error :exception, ex
|
70
138
|
end
|
71
139
|
ensure
|
72
140
|
trace.disable
|
data/lib/superscript/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: superscript
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matti Paksula
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-05-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -100,7 +100,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
100
100
|
- !ruby/object:Gem::Version
|
101
101
|
version: '0'
|
102
102
|
requirements: []
|
103
|
-
rubygems_version: 3.0.
|
103
|
+
rubygems_version: 3.0.8
|
104
104
|
signing_key:
|
105
105
|
specification_version: 4
|
106
106
|
summary: superscript
|