code-ruby-parser 0.1.1 → 0.1.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: 32cb9a8a8f8c5a8e0094282f299aac29f658dff93cde750d082a379a50e740e4
4
- data.tar.gz: 17d8de30653fd59b4f0772fd9123aab8bbbf1c891aa4b7c87aa11eafe1ca4dcd
3
+ metadata.gz: e0b771db0340e7e46f375f056056480d1b92ec6210fae8aa91025b3b10cdccad
4
+ data.tar.gz: 71fff0149a4e017fc03e0b4b9798d23fb94c874c937f51b8ee89a3c752619cc9
5
5
  SHA512:
6
- metadata.gz: cd2f019703431f38c529646697b0ea369d616ae81493f5987c7deda64bb816af05dcd7b21765fb8f0053bd0d8f04f0eb96173ec8a6677811446db6bfe234c029
7
- data.tar.gz: 6028c01692f95c52d83f58023bedc2a97f7c056776fc373b4fe8ff1c2e8cd900fbd5a7264d826bbf5f255029298c190086c5728d17b8beb943e9b1aa52948f02
6
+ metadata.gz: 6480f03895aa2958809b4d7cf849b2720de2d8eba33af43e2999db8d6609cb83936a4649e931da459dd376c489f9c8d4f0671cdb56a6a45706c931adc0fd9cff
7
+ data.tar.gz: 3a51ac65786932de2ed2bd1c64f022e7a498e78233aea3085ffb6acd4f26970bcfb7ef3520078c7a94bdc7bf7f2c6e7d4d72a95155cac6e3b2c9d3ba9d84a6a8
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 0.1.2 - November 12, 2022
2
+
3
+ - Fix parsing `&:even?`
4
+
1
5
  ### 0.1.1 - November 12, 2022
2
6
 
3
7
  - Fix `:even?` and `:update?` strings
data/bin/push ADDED
@@ -0,0 +1,16 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+
5
+ rm -f *.gem
6
+ git pull
7
+ git push
8
+ gem build template-ruby-parser.gemspec
9
+ gem build code-ruby-parser.gemspec
10
+
11
+ for file in *.gem
12
+ do
13
+ gem push $file
14
+ done
15
+
16
+ rm *.gem
@@ -38,7 +38,7 @@ class Code
38
38
 
39
39
  {
40
40
  call: {
41
- **identifier,
41
+ identifier: identifier,
42
42
  arguments: arguments,
43
43
  block: block,
44
44
  comments: comments
@@ -117,7 +117,7 @@ class Code
117
117
  comments_after: comments_after,
118
118
  default: default,
119
119
  keyword: true,
120
- **key
120
+ identifier: key
121
121
  }.compact
122
122
  else
123
123
  @cursor = previous_cursor
@@ -140,13 +140,13 @@ class Code
140
140
  comments_before: comments_before,
141
141
  comments_after: comments_after,
142
142
  default: default,
143
- **identifier
143
+ identifier: identifier
144
144
  }.compact
145
145
  else
146
146
  {
147
147
  comments_before: comments_before,
148
148
  comments_after: comments_after,
149
- **identifier
149
+ identifier: identifier
150
150
  }.compact
151
151
  end
152
152
  else
@@ -68,7 +68,7 @@ class Code
68
68
  keyword: true,
69
69
  comments_before: comments_before,
70
70
  comments_after: comments_after,
71
- **key
71
+ identifier: key
72
72
  }.compact
73
73
  else
74
74
  @cursor = previous_cursor
@@ -96,7 +96,7 @@ class Code
96
96
  default: default,
97
97
  comments_before: comments_before,
98
98
  comments_after: comments_after,
99
- **identifier
99
+ identifier: identifier
100
100
  }.compact
101
101
  else
102
102
  @cursor = previous_cursor
@@ -9,36 +9,22 @@ class Code
9
9
  def parse
10
10
  return if end_of_input?
11
11
 
12
- previous_cursor = cursor
13
-
14
- if !simple? && match(AMPERSAND) && !next?(SPECIAL)
15
- kind = :block
16
- elsif !simple && match(ASTERISK + ASTERISK) && !next?(SPECIAL)
17
- kind = :keyword
18
- elsif !simple? && match(ASTERISK) && !next?(SPECIAL)
19
- kind = :regular
20
- elsif !next?(SPECIAL)
21
- kind = nil
22
- else
23
- @cursor = previous_cursor
24
- buffer!
25
- return
26
- end
27
-
28
- buffer!
12
+ if !simple? && match(AMPERSAND)
13
+ { block: parse_subclass(::Code::Parser::Statement) }
14
+ elsif !simple && match(ASTERISK + ASTERISK)
15
+ { keyword_splat: parse_subclass(::Code::Parser::Statement) }
16
+ elsif !simple? && match(ASTERISK)
17
+ { regular_splat: parse_subclass(::Code::Parser::Statement) }
18
+ elsif !next?(SPECIAL) && !next?(KEYWORDS)
19
+ consume while !next?(SPECIAL) && !end_of_input?
29
20
 
30
- consume while !next?(SPECIAL) && !end_of_input?
21
+ match(QUESTION_MARK) || match(EXCLAMATION_POINT) if !simple?
31
22
 
32
- match(QUESTION_MARK) || match(EXCLAMATION_POINT) if !simple?
23
+ name = buffer!
33
24
 
34
- name = buffer!
35
-
36
- if KEYWORDS.include?(name)
37
- @cursor = previous_cursor
38
- buffer!
39
- return
25
+ { name: name }
40
26
  else
41
- { name: name, kind: kind }.compact
27
+ return
42
28
  end
43
29
  end
44
30
 
@@ -11,28 +11,38 @@ class Code
11
11
  def parse
12
12
  previous_cursor = cursor
13
13
  left = parse_subclass(subclass)
14
- right = []
15
- previous_cursor = cursor
16
- comments = parse_comments
17
-
18
- while operator = match(operators)
14
+ if left
15
+ right = []
16
+ previous_cursor = cursor
19
17
  comments = parse_comments
20
- statement = parse_subclass(subclass)
21
- right << {
22
- comments: comments,
23
- statement: statement,
24
- operator: operator
25
- }.compact
26
- end
27
18
 
28
- if right.empty?
19
+ while operator = match(operators)
20
+ comments = parse_comments
21
+ statement = parse_subclass(subclass)
22
+ right << {
23
+ comments: comments,
24
+ statement: statement,
25
+ operator: operator
26
+ }.compact
27
+ end
28
+
29
+ if right.empty?
30
+ @cursor = previous_cursor
31
+ buffer!
32
+ left
33
+ else
34
+ {
35
+ operation: {
36
+ left: left,
37
+ comments: comments,
38
+ right: right
39
+ }.compact
40
+ }
41
+ end
42
+ else
29
43
  @cursor = previous_cursor
30
44
  buffer!
31
- left
32
- else
33
- {
34
- operation: { left: left, comments: comments, right: right }.compact
35
- }
45
+ return
36
46
  end
37
47
  end
38
48
 
@@ -1,6 +1,6 @@
1
1
  class Template
2
2
  class Parser < ::Code::Parser
3
- Version = Gem::Version.new("0.1.1")
3
+ Version = Gem::Version.new("0.1.2")
4
4
 
5
5
  def parse
6
6
  parts = []
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: code-ruby-parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Marié
@@ -23,8 +23,8 @@ files:
23
23
  - Gemfile.lock
24
24
  - bin/code-parser
25
25
  - bin/format
26
+ - bin/push
26
27
  - bin/template-parser
27
- - code-ruby-parser-0.1.0.gem
28
28
  - code-ruby-parser.gemspec
29
29
  - docs/class.code
30
30
  - docs/meetup.code
@@ -112,7 +112,6 @@ files:
112
112
  - spec/code/parser/while_spec.rb
113
113
  - spec/spec_helper.rb
114
114
  - spec/template/parser_spec.rb
115
- - template-ruby-parser-0.1.0.gem
116
115
  - template-ruby-parser.gemspec
117
116
  homepage: https://github.com/dorianmariefr/template-ruby-parser
118
117
  licenses:
Binary file
Binary file