language-ruby 0.6.2 → 0.8.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 +14 -14
- data/lib/language/atom/then.rb +6 -1
- data/lib/language/output.rb +18 -1
- data/lib/language/parser.rb +1 -1
- data/lib/language/version.rb +1 -1
- data/spec/language_spec.rb +33 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1fa93a1100450c8e70de898e1de91c49194fe5f140f5a72bcccf63617dba9c31
|
4
|
+
data.tar.gz: 2c91243be68269482a432d1d41469019f74e2e6c1b20746c4ea70f83fee90216
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: abd34ca928437348691865067cf26f3735bb4e89b49589dd44e448f8a300b3bdb41f9a0108fa7abc0d81b6c1edb29f7afc46d52c88939528a6932e86c047322c
|
7
|
+
data.tar.gz: 281b2d88b13acbab58914bdbb5bacefc00307b8b68f83d27bc7bee83f4408bb3e6ad355f3ac691847fef953560b83628e5206b0a1576e5d3315d0dabf4b12ac7
|
data/Gemfile.lock
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
language-ruby (0.
|
4
|
+
language-ruby (0.7.0)
|
5
5
|
zeitwerk (~> 2)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
diff-lcs (1.5.
|
11
|
-
rspec (3.
|
12
|
-
rspec-core (~> 3.
|
13
|
-
rspec-expectations (~> 3.
|
14
|
-
rspec-mocks (~> 3.
|
15
|
-
rspec-core (3.
|
16
|
-
rspec-support (~> 3.
|
17
|
-
rspec-expectations (3.
|
10
|
+
diff-lcs (1.5.1)
|
11
|
+
rspec (3.13.0)
|
12
|
+
rspec-core (~> 3.13.0)
|
13
|
+
rspec-expectations (~> 3.13.0)
|
14
|
+
rspec-mocks (~> 3.13.0)
|
15
|
+
rspec-core (3.13.0)
|
16
|
+
rspec-support (~> 3.13.0)
|
17
|
+
rspec-expectations (3.13.0)
|
18
18
|
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
-
rspec-support (~> 3.
|
20
|
-
rspec-mocks (3.
|
19
|
+
rspec-support (~> 3.13.0)
|
20
|
+
rspec-mocks (3.13.0)
|
21
21
|
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
-
rspec-support (~> 3.
|
23
|
-
rspec-support (3.
|
24
|
-
zeitwerk (2.6.
|
22
|
+
rspec-support (~> 3.13.0)
|
23
|
+
rspec-support (3.13.1)
|
24
|
+
zeitwerk (2.6.13)
|
25
25
|
|
26
26
|
PLATFORMS
|
27
27
|
arm64-darwin-22
|
data/lib/language/atom/then.rb
CHANGED
@@ -10,7 +10,12 @@ class Language
|
|
10
10
|
|
11
11
|
def parse(parser)
|
12
12
|
@parent.parse(parser)
|
13
|
-
|
13
|
+
|
14
|
+
if parser.output.nil?
|
15
|
+
parser.buffer = @block.call(parser.buffer)
|
16
|
+
else
|
17
|
+
parser.output = Output.from_raw(@block.call(parser.output.to_raw))
|
18
|
+
end
|
14
19
|
end
|
15
20
|
|
16
21
|
def to_s
|
data/lib/language/output.rb
CHANGED
@@ -18,6 +18,23 @@ class Language
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
def nil?
|
22
|
+
raw.nil?
|
23
|
+
end
|
24
|
+
|
25
|
+
def empty?
|
26
|
+
case @raw
|
27
|
+
when NilClass
|
28
|
+
true
|
29
|
+
when String
|
30
|
+
raw.empty?
|
31
|
+
when Array
|
32
|
+
raw.empty?
|
33
|
+
when Hash
|
34
|
+
raw.empty?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
21
38
|
def to_raw
|
22
39
|
if raw.is_a?(Array)
|
23
40
|
raw.map(&:to_raw)
|
@@ -33,7 +50,7 @@ class Language
|
|
33
50
|
end
|
34
51
|
|
35
52
|
def present?
|
36
|
-
|
53
|
+
!nil? && !empty?
|
37
54
|
end
|
38
55
|
|
39
56
|
def ==(other)
|
data/lib/language/parser.rb
CHANGED
data/lib/language/version.rb
CHANGED
data/spec/language_spec.rb
CHANGED
@@ -11,11 +11,43 @@ class Code
|
|
11
11
|
nothing_keyword.aka(:nothing)
|
12
12
|
end
|
13
13
|
end
|
14
|
+
|
15
|
+
class ThenWithBuffer < Language
|
16
|
+
def root
|
17
|
+
any.repeat(1).then { "something-else" }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class ThenWithBufferTransformed < Language
|
22
|
+
def root
|
23
|
+
any.repeat(1).then { |buffer| buffer.upcase }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class ThenWithOutput < Language
|
28
|
+
def root
|
29
|
+
any.repeat(1).aka(:something).then do |output|
|
30
|
+
output[:something].upcase
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
14
34
|
end
|
15
35
|
end
|
16
36
|
|
17
37
|
RSpec.describe Language do
|
18
|
-
it "works" do
|
38
|
+
it "works with nothing" do
|
19
39
|
expect(Code::Parser::Nothing.parse("nothing")).to eq({ nothing: "nothing" })
|
20
40
|
end
|
41
|
+
|
42
|
+
it "works with then with buffer" do
|
43
|
+
expect(Code::Parser::ThenWithBuffer.parse("something")).to eq("something-else")
|
44
|
+
end
|
45
|
+
|
46
|
+
it "works with then with buffer transformed" do
|
47
|
+
expect(Code::Parser::ThenWithBufferTransformed.parse("something")).to eq("SOMETHING")
|
48
|
+
end
|
49
|
+
|
50
|
+
it "works with then with output" do
|
51
|
+
expect(Code::Parser::ThenWithOutput.parse("value")).to eq("VALUE")
|
52
|
+
end
|
21
53
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: language-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dorian Marié
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-03-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zeitwerk
|