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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4baad3490a61d7414a3010ae28d7ebe15678cf7155d6fa733d6db38e69a6f15
4
- data.tar.gz: 498e238afd5c1fdee3eb7d43d6416deda5c4af0a7ea3e7be7b16b3c52f35fc08
3
+ metadata.gz: 2a0b46ff49cc73bcc48eb25f7fa860a81c583e1e91aafe2f516f513fc8767bf9
4
+ data.tar.gz: 92f1a797e930eb4e8ac58eab7f68555b300a1dc4c4647eeaad0e7e23cdaec827
5
5
  SHA512:
6
- metadata.gz: b51659b87522dbe212304842b3d8af561e6caf86ce78cef0ed0bfd732123736961736750fe603073398e50150b03d4be328c858754a7d4d2e6bd3926377878da
7
- data.tar.gz: 740130b9f8e3a5c5e6ac8e09b8adbb5c0bd75074fbc0c94b1bac6a58276bed37b818a82d98e4cfe6953bb3e6f318a222790ddfe6089ffe6c01aae97f4ea605d1
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.0)
11
- rspec (3.12.0)
12
- rspec-core (~> 3.12.0)
13
- rspec-expectations (~> 3.12.0)
14
- rspec-mocks (~> 3.12.0)
15
- rspec-core (3.12.2)
16
- rspec-support (~> 3.12.0)
17
- rspec-expectations (3.12.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.12.0)
20
- rspec-mocks (3.12.6)
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.12.0)
23
- rspec-support (3.12.1)
24
- zeitwerk (2.6.12)
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
@@ -10,7 +10,12 @@ class Language
10
10
 
11
11
  def parse(parser)
12
12
  @parent.parse(parser)
13
- parser.output = Output.from_raw(@block.call(parser.output.to_raw))
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
@@ -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
- @raw != nil
40
+ !nil?
37
41
  end
38
42
 
39
43
  def ==(other)
@@ -2,4 +2,4 @@
2
2
 
3
3
  require_relative "../language"
4
4
 
5
- Language::Version = Gem::Version.new("0.6.2")
5
+ Language::Version = Gem::Version.new("0.7.0")
@@ -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.6.2
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-08 00:00:00.000000000 Z
11
+ date: 2024-03-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: zeitwerk