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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 03fa28470be7d3daf81b57dfd9e87fd02a9a43980f3ef09dde087e044e39de6e
4
- data.tar.gz: aa3102b743ef7c70aa6fa87d51536ba47303f5dbed871e8d50aadbf9b9109b94
3
+ metadata.gz: 985880499b7960ca7ce77fd0b1d04b8e214079100dc85cbd875ac05fc36d8301
4
+ data.tar.gz: 26b71fdd07f5ce9ec9ddf9673b03c03ce9c909cf6e70782589b39c798d1cfdf8
5
5
  SHA512:
6
- metadata.gz: 300c1faf4ce94007f9d6bb4077414dcef9d5c5ed2d477027d22c531c7c948913d7969fa6151fa7d0c02b69b08f76f48b7445b4ecbfc5fda58b4e635df3e6c80b
7
- data.tar.gz: e0e8aeeb413a3cb079fe11ac30e9933a8770d1e9bea483256951319e92c25ada09bacbda7c9937146672c8e754e5a10707abb643b4833df732edbaa0f8df094b
6
+ metadata.gz: 8edd895405c1e8bcb48dda3647207ad4c36206027ef4073d38dcf89c8cb6803e28bbaad46df41af780d6111b4acfd781587e5512d1e67ffea562f5ff39d8bce3
7
+ data.tar.gz: 131c83897b35170fa1636dcc107302fdd85fb7424e97c2bd39b339cbccec05296a42efee3a138d58745cbe68eed9298db2f653b6876f06c1e7fd6b1418ec5c82
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- superscript (0.6.0)
4
+ superscript (0.10.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -3,6 +3,17 @@ class Go < Superscript::Dsl
3
3
  self.say "Go #{args.join(" ")}!"
4
4
  end
5
5
 
6
+ def loop &block
7
+ ::Kernel.loop do
8
+ block.call
9
+ sleep 1
10
+ end
11
+ end
12
+
13
+ def hang
14
+ sleep 9999
15
+ end
16
+
6
17
  def say(message)
7
18
  puts message
8
19
  end
@@ -1,5 +1,2 @@
1
- def muna
2
-
3
- end
4
-
5
- muna
1
+ a = struct
2
+ go a.name
@@ -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
- print "> "
38
- contents = STDIN.gets
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
@@ -1,7 +1,4 @@
1
1
  module Superscript
2
2
  class Ctx
3
- def method_missing(*args)
4
- ::Superscript.error :ctx_method_missing, "No such command or variable '#{args.first}'"
5
- end
6
3
  end
7
4
  end
@@ -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
- if @on_error_exec
37
- system("#{@on_error_exec} #{error_message}")
38
+
39
+ caller.each do |c|
40
+ puts c
38
41
  end
39
- exit 1
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
@@ -1,3 +1,3 @@
1
1
  module Superscript
2
- VERSION = "0.6.0"
2
+ VERSION = "0.10.0"
3
3
  end
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.6.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: 2020-05-21 00:00:00.000000000 Z
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: []