superscript 0.6.0 → 0.10.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 +11 -0
- data/e2e/test.rb +2 -5
- data/exe/superscript +12 -2
- data/lib/superscript/ctx.rb +0 -3
- data/lib/superscript/runner.rb +27 -6
- data/lib/superscript/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 985880499b7960ca7ce77fd0b1d04b8e214079100dc85cbd875ac05fc36d8301
|
4
|
+
data.tar.gz: 26b71fdd07f5ce9ec9ddf9673b03c03ce9c909cf6e70782589b39c798d1cfdf8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8edd895405c1e8bcb48dda3647207ad4c36206027ef4073d38dcf89c8cb6803e28bbaad46df41af780d6111b4acfd781587e5512d1e67ffea562f5ff39d8bce3
|
7
|
+
data.tar.gz: 131c83897b35170fa1636dcc107302fdd85fb7424e97c2bd39b339cbccec05296a42efee3a138d58745cbe68eed9298db2f653b6876f06c1e7fd6b1418ec5c82
|
data/Gemfile.lock
CHANGED
data/e2e/dsls/go.rb
CHANGED
data/e2e/test.rb
CHANGED
data/exe/superscript
CHANGED
@@ -32,10 +32,20 @@ if ARGV[1]
|
|
32
32
|
runner = Superscript::Runner.new ARGV[1], options
|
33
33
|
runner.run! ctx
|
34
34
|
else
|
35
|
+
require "readline"
|
36
|
+
|
35
37
|
runner = Superscript::Runner.new nil, options
|
36
38
|
loop do
|
37
|
-
|
38
|
-
contents
|
39
|
+
contents = Readline.readline "> ", true
|
40
|
+
next if contents == ""
|
41
|
+
|
42
|
+
if contents == nil
|
43
|
+
puts "\n-- press ^D to end input"
|
44
|
+
contents = $stdin.readlines.join("\n")
|
45
|
+
end
|
46
|
+
|
47
|
+
next if contents == ""
|
48
|
+
|
39
49
|
value = runner.run! ctx, contents: contents
|
40
50
|
puts " => #{value.inspect}"
|
41
51
|
end
|
data/lib/superscript/ctx.rb
CHANGED
data/lib/superscript/runner.rb
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
Signal.trap "TERM" do
|
2
|
+
exit 0
|
3
|
+
end
|
4
|
+
|
1
5
|
module Superscript
|
2
6
|
class Runner
|
3
7
|
def initialize path=nil, opts={}
|
@@ -18,10 +22,8 @@ module Superscript
|
|
18
22
|
case where
|
19
23
|
when :exception
|
20
24
|
exception = args.first
|
21
|
-
pp exception
|
22
|
-
pp exception.backtrace_locations
|
23
25
|
error_message = exception
|
24
|
-
when :tp_call_superscript
|
26
|
+
when :tp_call_superscript, :tp_call_superscript_global
|
25
27
|
error_message = "Can't touch this"
|
26
28
|
when :ctx_method_missing, :tp_singleton_method_added, :tp_command_not_found
|
27
29
|
error_message = args.first
|
@@ -33,10 +35,13 @@ module Superscript
|
|
33
35
|
end
|
34
36
|
|
35
37
|
puts error_message
|
36
|
-
|
37
|
-
|
38
|
+
|
39
|
+
caller.each do |c|
|
40
|
+
puts c
|
38
41
|
end
|
39
|
-
|
42
|
+
system @on_error_exec, error_message if @on_error_exec
|
43
|
+
|
44
|
+
exit 1 unless @path == "<interactive>"
|
40
45
|
end
|
41
46
|
|
42
47
|
def arm!(reason=nil)
|
@@ -50,6 +55,10 @@ module Superscript
|
|
50
55
|
|
51
56
|
def run!(ctx, contents:nil)
|
52
57
|
contents = File.read(@path) unless contents
|
58
|
+
$__superscript_none_of_yer_business = self
|
59
|
+
ctx.define_singleton_method "method_missing" do |*args|
|
60
|
+
$__superscript_none_of_yer_business.error! :ctx_method_missing, "No such command or variable '#{args.first}'"
|
61
|
+
end
|
53
62
|
|
54
63
|
disarm! :at_start
|
55
64
|
trace = TracePoint.new do |tp|
|
@@ -88,6 +97,11 @@ module Superscript
|
|
88
97
|
line = lines[tp.lineno-1].lstrip
|
89
98
|
puts "< #{tp.path}:#{tp.lineno-1}"
|
90
99
|
puts line
|
100
|
+
|
101
|
+
if line.match(/\$__superscript_none_of_yer_business/)
|
102
|
+
tp.disable
|
103
|
+
error! :tp_call_superscript_global
|
104
|
+
end
|
91
105
|
when :c_call
|
92
106
|
# allow calls to these instances
|
93
107
|
if tp.defined_class.ancestors.at(1) == Struct
|
@@ -106,6 +120,8 @@ module Superscript
|
|
106
120
|
end
|
107
121
|
trace.disable
|
108
122
|
error! :tp_singleton_method_added, "Deffining methods is not allowed"
|
123
|
+
when :method_missing
|
124
|
+
trace.disable
|
109
125
|
else
|
110
126
|
trace.disable
|
111
127
|
case tp.defined_class.name
|
@@ -135,6 +151,11 @@ module Superscript
|
|
135
151
|
end
|
136
152
|
end
|
137
153
|
when :call
|
154
|
+
if tp.method_id == :method_missing
|
155
|
+
tp.disable
|
156
|
+
next
|
157
|
+
end
|
158
|
+
|
138
159
|
if tp.defined_class.ancestors.first.to_s == "#<Class:Superscript>"
|
139
160
|
tp.disable
|
140
161
|
error! :tp_call_superscript
|
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.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matti Paksula
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -85,7 +85,7 @@ homepage: https://github.com/matti/superscript
|
|
85
85
|
licenses:
|
86
86
|
- MIT
|
87
87
|
metadata: {}
|
88
|
-
post_install_message:
|
88
|
+
post_install_message:
|
89
89
|
rdoc_options: []
|
90
90
|
require_paths:
|
91
91
|
- lib
|
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
101
|
version: '0'
|
102
102
|
requirements: []
|
103
103
|
rubygems_version: 3.0.8
|
104
|
-
signing_key:
|
104
|
+
signing_key:
|
105
105
|
specification_version: 4
|
106
106
|
summary: superscript
|
107
107
|
test_files: []
|