code-ruby 2.0.1 → 2.0.2

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: 289eba7ee8807b4660bba3a8df2458d5d7b615deea52b66b3475eb2c306aa9e9
4
- data.tar.gz: 6394f2e3a44499cdf85ecb315d1a303a52df7784f8c385c76b170702298d7d3c
3
+ metadata.gz: 26d4b2a42933e4c3b408c6363ecbd343c106e117d469e196f5088c5db5ecfb8f
4
+ data.tar.gz: a888fd3dc5f2987dae06dffe0df43f00ca3c031404e48390d53d201078224808
5
5
  SHA512:
6
- metadata.gz: 1bb7bf8488694f407300e3a18258601ada0eba25cd54ab8e0184a05889ac1171c87f5c62de341a26bae7876372cec80e194c82a993277b85fc8bc11d2bba10ef
7
- data.tar.gz: bf4b7f896dc52eb6afabcc25e863d96fbf71a801bd469344887f7cff95d3879442757b3d0723a5d0594ee11aff671d78da4abdcfad0d889672f0e407c040fa95
6
+ metadata.gz: 1c3f838b4cdd9a17c18ad194dd035e281b64d8ff9c536e935f903dfbd8d6a82e64fcb04ae37d8ed0f49e764269f4d70d8f0ca44d3d6314c9bd5fe13864cb88df
7
+ data.tar.gz: 42435bd8fafc85bdfb3b4fd6af6b033942f7bb4e03e49e6ddc93079e2caeb6bbd08dc33214d79e2324abfb528be1debe6c82600ffebf84601a21e6a54c997e77
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- code-ruby (2.0.1)
4
+ code-ruby (2.0.2)
5
5
  activesupport
6
6
  base64
7
7
  bigdecimal
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.0.1
1
+ 2.0.2
@@ -7,6 +7,10 @@ class Code
7
7
  Name
8
8
  end
9
9
 
10
+ def label_name
11
+ LabelName
12
+ end
13
+
10
14
  def whitespace
11
15
  Whitespace
12
16
  end
@@ -88,7 +92,7 @@ class Code
88
92
  end
89
93
 
90
94
  def keyword_argument
91
- name.aka(:name) << whitespace? << colon << code.aka(:value)
95
+ label_name.aka(:name) << whitespace? << colon << code.aka(:value)
92
96
  end
93
97
 
94
98
  def regular_argument
@@ -114,7 +118,7 @@ class Code
114
118
  end
115
119
 
116
120
  def keyword_parameter
117
- name.aka(:name) << whitespace? << colon.aka(:keyword) <<
121
+ label_name.aka(:name) << whitespace? << colon.aka(:keyword) <<
118
122
  code_present.aka(:default).maybe
119
123
  end
120
124
 
@@ -15,6 +15,10 @@ class Code
15
15
  Name
16
16
  end
17
17
 
18
+ def label_name
19
+ LabelName
20
+ end
21
+
18
22
  def whitespace
19
23
  Whitespace
20
24
  end
@@ -48,7 +52,7 @@ class Code
48
52
  end
49
53
 
50
54
  def key_value
51
- (name.aka(:name) << colon << code_present.aka(:code).maybe).aka(
55
+ (label_name.aka(:name) << colon << code_present.aka(:code).maybe).aka(
52
56
  :name_code
53
57
  ) |
54
58
  (
@@ -7,6 +7,10 @@ class Code
7
7
  Name
8
8
  end
9
9
 
10
+ def label_name
11
+ LabelName
12
+ end
13
+
10
14
  def code
11
15
  Code
12
16
  end
@@ -90,7 +94,7 @@ class Code
90
94
  end
91
95
 
92
96
  def keyword_parameter
93
- name.aka(:name) << whitespace? << colon.aka(:keyword) <<
97
+ label_name.aka(:name) << whitespace? << colon.aka(:keyword) <<
94
98
  code_present.aka(:default).maybe
95
99
  end
96
100
 
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Code
4
+ class Parser
5
+ class LabelName < Name
6
+ def root
7
+ (
8
+ (special_name << separator.ignore) |
9
+ (special_characters.absent << character.repeat(1))
10
+ )
11
+ end
12
+ end
13
+ end
14
+ end
@@ -11,6 +11,10 @@ class Code
11
11
  Name
12
12
  end
13
13
 
14
+ def label_name
15
+ LabelName
16
+ end
17
+
14
18
  def single_quote
15
19
  str("'")
16
20
  end
@@ -69,7 +73,7 @@ class Code
69
73
  end
70
74
 
71
75
  def symbol
72
- (colon.ignore << name).aka(:text).repeat(1, 1)
76
+ (colon.ignore << label_name).aka(:text).repeat(1, 1)
73
77
  end
74
78
 
75
79
  def root
@@ -1,3 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "spec_helper"
4
+
5
+ RSpec.describe Code::Parser::Call do
6
+ [
7
+ "f(end: 2)"
8
+ ].each do |input|
9
+ it "parses #{input}" do
10
+ Code::Parser.parse(input)
11
+ end
12
+ end
13
+ end
@@ -8,7 +8,8 @@ RSpec.describe Code::Parser::Dictionary do
8
8
  "{ }",
9
9
  "{/* comment */}",
10
10
  "{ a: 1, b: 2, c: 3 }",
11
- '{ "first_name": "Dorian" }'
11
+ '{ "first_name": "Dorian" }',
12
+ "{ end: 2 }"
12
13
  ].each do |input|
13
14
  it "parses #{input}" do
14
15
  Code::Parser.parse(input)
@@ -6,7 +6,8 @@ RSpec.describe Code::Parser::Function do
6
6
  [
7
7
  "() => {}",
8
8
  "(a, b) => { add(a, b) }",
9
- "(a:, b:) => { add(a, b) }"
9
+ "(a:, b:) => { add(a, b) }",
10
+ "(end:) => { nothing }"
10
11
  ].each do |input|
11
12
  it "parses #{input}" do
12
13
  Code::Parser.parse(input)
data/spec/code_spec.rb CHANGED
@@ -173,6 +173,7 @@ RSpec.describe Code do
173
173
  "(user = { name: :Dorian, age: 31 }).transform_values { user.name }.age",
174
174
  ":Dorian"
175
175
  ],
176
+ ["{ end: 2 }.keys.first", ":end"],
176
177
  %w[!!1 true],
177
178
  %w[!!true true],
178
179
  %w[!false true],
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Marié
@@ -306,6 +306,7 @@ files:
306
306
  - lib/code/parser/group.rb
307
307
  - lib/code/parser/if.rb
308
308
  - lib/code/parser/if_modifier.rb
309
+ - lib/code/parser/label_name.rb
309
310
  - lib/code/parser/left_operation.rb
310
311
  - lib/code/parser/list.rb
311
312
  - lib/code/parser/multiplication.rb