superscript 0.2.2 → 0.3.0
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 +13 -0
- data/exe/superscript +13 -5
- data/lib/superscript.rb +1 -0
- data/lib/superscript/ctx.rb +0 -21
- data/lib/superscript/dsl.rb +4 -0
- data/lib/superscript/runner.rb +3 -4
- data/lib/superscript/version.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e880e75866984c952744fd389d4f8e797ccb6d147701d7502d873485365418d
|
4
|
+
data.tar.gz: de70c26e01c79a11282ed7e06827942e41589abbb85e6bdeb6873efde73b131b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71fc81b5cd8b5bf8a33e4c03087996622d7d6c243c32c750210881bd8768c60a6627456308e8a4597edb70e8c3a10ff9c9cc6a372bd27ee1c9ee8982f052be08
|
7
|
+
data.tar.gz: 102c7edaa32df3137ede0c88686071727192022e4b5528329841ea2d9910fef2d7d8126bb7fc26f3364146e4805cc1aa4e0f221cfa8ad7dadc66b47691ceb417
|
data/Gemfile.lock
CHANGED
data/e2e/dsls/go.rb
ADDED
data/exe/superscript
CHANGED
@@ -3,16 +3,24 @@
|
|
3
3
|
require "bundler/setup"
|
4
4
|
require "superscript"
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
6
|
+
unless ARGV.length == 2
|
7
|
+
puts "USAGE: superscript dsl.rb script.rb"
|
8
|
+
exit 1
|
9
|
+
end
|
10
|
+
require "./#{ARGV[0]}"
|
11
|
+
|
12
|
+
ctx_classname = File.basename(ARGV[0]).split(".").first.capitalize
|
13
|
+
ctx = (eval "#{ctx_classname}").new
|
14
|
+
|
15
|
+
if ARGV[1]
|
16
|
+
runner = Superscript::Runner.new ARGV[1]
|
17
|
+
runner.run! ctx
|
9
18
|
else
|
10
|
-
ctx = Superscript::Ctx.new
|
11
19
|
runner = Superscript::Runner.new
|
12
20
|
loop do
|
13
21
|
print "> "
|
14
22
|
contents = gets
|
15
|
-
value = runner.run! ctx
|
23
|
+
value = runner.run! ctx, contents: contents
|
16
24
|
puts " => #{value.inspect}"
|
17
25
|
end
|
18
26
|
end
|
data/lib/superscript.rb
CHANGED
data/lib/superscript/ctx.rb
CHANGED
@@ -4,26 +4,5 @@ module Superscript
|
|
4
4
|
puts "Error: No such command or variable '#{args.first}'"
|
5
5
|
exit 1
|
6
6
|
end
|
7
|
-
|
8
|
-
def go *args
|
9
|
-
puts "Go #{args.join(" ")}!"
|
10
|
-
end
|
11
|
-
|
12
|
-
def wait seconds_or_random_range
|
13
|
-
amount = if seconds_or_random_range.is_a? Range
|
14
|
-
rand(seconds_or_random_range)
|
15
|
-
else
|
16
|
-
seconds_or_random_range
|
17
|
-
end
|
18
|
-
|
19
|
-
sleep amount
|
20
|
-
end
|
21
|
-
|
22
|
-
def exit
|
23
|
-
Kernel.exit
|
24
|
-
end
|
25
|
-
def quit
|
26
|
-
exit
|
27
|
-
end
|
28
7
|
end
|
29
8
|
end
|
data/lib/superscript/runner.rb
CHANGED
@@ -8,9 +8,8 @@ module Superscript
|
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
|
-
def run!(ctx
|
11
|
+
def run!(ctx, contents:nil)
|
12
12
|
contents = File.read(@path) unless contents
|
13
|
-
ctx = Superscript::Ctx.new unless ctx
|
14
13
|
|
15
14
|
@armed = false
|
16
15
|
trace = TracePoint.new do |tp|
|
@@ -26,7 +25,7 @@ module Superscript
|
|
26
25
|
end
|
27
26
|
end
|
28
27
|
|
29
|
-
if tp.event == :return && tp.defined_class.
|
28
|
+
if tp.event == :return && tp.defined_class.ancestors.include?(Superscript::Ctx)
|
30
29
|
@armed = true
|
31
30
|
end
|
32
31
|
|
@@ -48,7 +47,7 @@ module Superscript
|
|
48
47
|
exit 1
|
49
48
|
end
|
50
49
|
when :call
|
51
|
-
if tp.defined_class.
|
50
|
+
if tp.defined_class.ancestors.include? Superscript::Ctx
|
52
51
|
@armed = false
|
53
52
|
end
|
54
53
|
end
|
data/lib/superscript/version.rb
CHANGED
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
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matti Paksula
|
@@ -72,10 +72,12 @@ files:
|
|
72
72
|
- Rakefile
|
73
73
|
- bin/console
|
74
74
|
- bin/setup
|
75
|
+
- e2e/dsls/go.rb
|
75
76
|
- e2e/test.rb
|
76
77
|
- exe/superscript
|
77
78
|
- lib/superscript.rb
|
78
79
|
- lib/superscript/ctx.rb
|
80
|
+
- lib/superscript/dsl.rb
|
79
81
|
- lib/superscript/runner.rb
|
80
82
|
- lib/superscript/version.rb
|
81
83
|
- superscript.gemspec
|