language-ruby 0.6.2 → 0.7.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 +13 -13
- data/lib/language/atom/then.rb +6 -1
- data/lib/language/output.rb +5 -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: 2a0b46ff49cc73bcc48eb25f7fa860a81c583e1e91aafe2f516f513fc8767bf9
|
4
|
+
data.tar.gz: 92f1a797e930eb4e8ac58eab7f68555b300a1dc4c4647eeaad0e7e23cdaec827
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f33665548899da00449b1c8337637f781cab829f43a30aec5b45414074990155df54bfe85b54d7288b586f090ace07ca2b9f7209eebc74bf148f6c5f921d33e5
|
7
|
+
data.tar.gz: 55c660ccc01502110c37e99aacb188543c99d83e746c0b21a46cb22893d1830dc27e98df10fa2ec679f126c723891a87f578d9a634481971564a4bc7ca7014f3
|
data/Gemfile.lock
CHANGED
@@ -7,21 +7,21 @@ PATH
|
|
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,10 @@ class Language
|
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
|
+
def nil?
|
22
|
+
raw.nil?
|
23
|
+
end
|
24
|
+
|
21
25
|
def to_raw
|
22
26
|
if raw.is_a?(Array)
|
23
27
|
raw.map(&:to_raw)
|
@@ -33,7 +37,7 @@ class Language
|
|
33
37
|
end
|
34
38
|
|
35
39
|
def present?
|
36
|
-
|
40
|
+
!nil?
|
37
41
|
end
|
38
42
|
|
39
43
|
def ==(other)
|
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.7.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-02
|
11
|
+
date: 2024-03-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: zeitwerk
|