superscript 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e12ad2456097931fa8ae7d7ceb5870ded64f9f13d4602568e3696b9af55b1ae8
4
- data.tar.gz: 920979e9fce25c924a51e83c2b830bafb50532659f2a7fbcb70216dc4e226fa6
3
+ metadata.gz: b2b7dee019db4e0c13b9a654eac37c84d4e736254709b2423726ecc8e559ecbe
4
+ data.tar.gz: 7b7e43e336d1c7ab0a2a60eb1947efcc0afcdc3115f5b5de3f61a950b1dbd4fa
5
5
  SHA512:
6
- metadata.gz: 59c7e83257e769ae2456305fb3c25ae16decc905314a931a1cbf156575775eec38c1ea0c6e30a959868ab58dae48f5e70aa262494e3b75c566bf6b5e3abd9ae6
7
- data.tar.gz: da64fb8f666dd4ff92ddc2d54b7cd4940435f4c8f5bbae5729b23b424feab31d98548fa7cc04ead529963b3a78660c0839b9ee343c880c618a0404ccdd222e59
6
+ metadata.gz: 51d7792af18af63fe4f37a18f99d60faa1a231e36c11ae778c11045b568b541ee4d920e63d757344a9e82b551b3969fbc5a24691afdefdb092d6f466ca90ed4b
7
+ data.tar.gz: 24c1e948e23287751a7a33f6905cba77c20b6ec8672b2b468e4148d5766362a9f220aa07b4e29b461de7802cdab828ad30c24bc9d90b50312227347071465563
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- superscript (0.4.2)
4
+ superscript (0.5.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/e2e/dsls/go.rb CHANGED
@@ -1,6 +1,14 @@
1
1
  class Go < Superscript::Dsl
2
2
  def go(*args)
3
- puts "Go #{args.join(" ")}"
3
+ self.say "Go #{args.join(" ")}!"
4
+ end
5
+
6
+ def say(message)
7
+ puts message
8
+ end
9
+
10
+ def now
11
+ Time.now
4
12
  end
5
13
 
6
14
  def explode!
data/e2e/test.rb CHANGED
@@ -1,3 +1 @@
1
1
  go "gators"
2
-
3
- explode!
@@ -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
- @armed = false
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
- @armed = true
63
+ arm! :script_compiled
48
64
  elsif tp.event == :c_return
49
- @armed = false
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
- @armed = true
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
- next if ["Array", "String","Float", "Integer"].include? tp.defined_class.name
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
- unless tp.path == @path
111
- @armed = false
133
+ # but do not allow call to Superscript.error etc
134
+ if tp.path != @path
135
+ disarm! :calling_other_file
112
136
  end
113
- if tp.defined_class.ancestors.include? Superscript::Ctx
114
- @armed = false
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
 
@@ -1,3 +1,3 @@
1
1
  module Superscript
2
- VERSION = "0.4.2"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: superscript
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.2
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matti Paksula