language-ruby 0.6.1 → 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: fe75dad140254848b0688e73fc0361003867abf259e3efd57eb8709072808461
4
- data.tar.gz: 592c2cf305d38613461981802bb63a9288b2a7bac862220cb818c4e1b9e1922c
3
+ metadata.gz: 2a0b46ff49cc73bcc48eb25f7fa860a81c583e1e91aafe2f516f513fc8767bf9
4
+ data.tar.gz: 92f1a797e930eb4e8ac58eab7f68555b300a1dc4c4647eeaad0e7e23cdaec827
5
5
  SHA512:
6
- metadata.gz: b61958d200d6d2e2f1a0ed41e93a992320e3b224c8e65f0cfb3e3ff35ad78f07b930234d2ec190cad4384b1127a347d7651597831033bf1b14bda18a488f6f41
7
- data.tar.gz: eb44f9c8522a461b4b40e7b369a9ac0653ff30c710c2c5395840e3e5b8181596ce4553fa7033370636e6974dd79e2e326e0e7bf6d0f2061be84468d30b670b49
6
+ metadata.gz: f33665548899da00449b1c8337637f781cab829f43a30aec5b45414074990155df54bfe85b54d7288b586f090ace07ca2b9f7209eebc74bf148f6c5f921d33e5
7
+ data.tar.gz: 55c660ccc01502110c37e99aacb188543c99d83e746c0b21a46cb22893d1830dc27e98df10fa2ec679f126c723891a87f578d9a634481971564a4bc7ca7014f3
data/Gemfile.lock CHANGED
@@ -1,27 +1,27 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- language-ruby (0.6.0)
4
+ language-ruby (0.6.2)
5
5
  zeitwerk (~> 2)
6
6
 
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
@@ -35,4 +35,4 @@ RUBY VERSION
35
35
  ruby 3.3.0p0
36
36
 
37
37
  BUNDLED WITH
38
- 2.4.21
38
+ 2.5.6
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.email = "dorian@dorianmarie.fr"
13
13
  s.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
14
14
  s.require_paths = ["lib"]
15
- s.homepage = "https://github.com/dorianmariefr/language-ruby"
15
+ s.homepage = "https://github.com/dorianmariecom/language-ruby"
16
16
  s.license = "MIT"
17
17
 
18
18
  s.add_dependency "zeitwerk", "~> 2"
@@ -8,7 +8,9 @@ class Language
8
8
  end
9
9
 
10
10
  def parse(parser)
11
- raise Parser::Str::NotFound.new(parser, @string) unless parser.next?(@string)
11
+ unless parser.next?(@string)
12
+ raise Parser::Str::NotFound.new(parser, @string)
13
+ end
12
14
 
13
15
  parser.consume(@string.size)
14
16
  end
@@ -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.1")
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.1
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-01-31 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
@@ -63,7 +63,7 @@ files:
63
63
  - lib/language/version.rb
64
64
  - spec/language_spec.rb
65
65
  - spec/spec_helper.rb
66
- homepage: https://github.com/dorianmariefr/language-ruby
66
+ homepage: https://github.com/dorianmariecom/language-ruby
67
67
  licenses:
68
68
  - MIT
69
69
  metadata: {}