superscript 0.2.2 → 0.3.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: f8ee74f474a6c2d61f6857e930622f3d3d76ce060c1297ea712003968866d590
4
- data.tar.gz: f8a73eb6186f97335d3cb7c8ae8965849b6a8757434c7aa533dd53832899698c
3
+ metadata.gz: 4e880e75866984c952744fd389d4f8e797ccb6d147701d7502d873485365418d
4
+ data.tar.gz: de70c26e01c79a11282ed7e06827942e41589abbb85e6bdeb6873efde73b131b
5
5
  SHA512:
6
- metadata.gz: f1433a68ef5e25ae46ab53b5d8e5061196d55eabc03efd6dc13309ab77981685ce2ba33cdede1a65080e8669d2762e71e911ba91677db142c500ecba55f28802
7
- data.tar.gz: 9bd505f00036a61ece2489021f6836c00e0f83611ad866aa02e0b9bb25a32a4c185f55692a6308377f72057fea2c559c2b5bc993c8435bfe4788c3090c602cdc
6
+ metadata.gz: 71fc81b5cd8b5bf8a33e4c03087996622d7d6c243c32c750210881bd8768c60a6627456308e8a4597edb70e8c3a10ff9c9cc6a372bd27ee1c9ee8982f052be08
7
+ data.tar.gz: 102c7edaa32df3137ede0c88686071727192022e4b5528329841ea2d9910fef2d7d8126bb7fc26f3364146e4805cc1aa4e0f221cfa8ad7dadc66b47691ceb417
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- superscript (0.2.2)
4
+ superscript (0.3.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/e2e/dsls/go.rb ADDED
@@ -0,0 +1,13 @@
1
+ class Go < Superscript::Dsl
2
+ def go(*args)
3
+ puts "Go #{args.join(" ")}"
4
+ end
5
+
6
+ def exit
7
+ Kernel.exit
8
+ end
9
+
10
+ def quit
11
+ exit
12
+ end
13
+ end
data/exe/superscript CHANGED
@@ -3,16 +3,24 @@
3
3
  require "bundler/setup"
4
4
  require "superscript"
5
5
 
6
- if ARGV[0]
7
- runner = Superscript::Runner.new ARGV[0]
8
- runner.run!
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: ctx, contents: contents
23
+ value = runner.run! ctx, contents: contents
16
24
  puts " => #{value.inspect}"
17
25
  end
18
26
  end
data/lib/superscript.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require_relative "superscript/version"
2
2
  require_relative "superscript/ctx"
3
+ require_relative "superscript/dsl"
3
4
  require_relative "superscript/runner"
4
5
 
5
6
  module Superscript
@@ -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
@@ -0,0 +1,4 @@
1
+ module Superscript
2
+ class Dsl < Superscript::Ctx
3
+ end
4
+ end
@@ -8,9 +8,8 @@ module Superscript
8
8
  end
9
9
  end
10
10
 
11
- def run!(ctx:nil, contents:nil)
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.name == "Superscript::Ctx"
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.name == "Superscript::Ctx"
50
+ if tp.defined_class.ancestors.include? Superscript::Ctx
52
51
  @armed = false
53
52
  end
54
53
  end
@@ -1,3 +1,3 @@
1
1
  module Superscript
2
- VERSION = "0.2.2"
2
+ VERSION = "0.3.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.2.2
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