unparser 0.6.12 → 0.6.14

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: 238250e76ff58e37c5b4244ab7405049b41f561bca57fb25f96dbc94b60912fe
4
- data.tar.gz: f65992f16196488d06ed58bb419de2fe5201152e13af5338df2d3ca5194a74ba
3
+ metadata.gz: f7ba6fe43070f8f0f156310dc9b588dfcb0dc9aef45c1eb639250efb1622d3dd
4
+ data.tar.gz: b73a4e1be5514ca85e2014be9008b59ed1a6847f370682a505d8e718d2e7cbef
5
5
  SHA512:
6
- metadata.gz: ee110d72b0d04851cf9d6131c1d20072a5ca37bfbf83a48c21a4044d9404370191fd801e02af615f90459c5afab4b67d83df5cbbc1de9ec44456d7272cc44e61
7
- data.tar.gz: ee6b0324cde01ad9d60b3a2233f3213e1c2f01ce0cd61b1dc029281cc650a1659403174c2ddb449d488e84b632bf7554f7d5eb7183f05682407690eabcc5c92f
6
+ metadata.gz: c360281c3941b7094ee10e09718e6b37f2de361af373942313692728f95160b3c94b979b3fe352804c7f91768edaf3e448e7ec406d392c8eeb68e1f9002ade62
7
+ data.tar.gz: 962d1c44aaa8d94aae4e60997dd75a2c8535b6a6f054f5aa382ff112c3c335a8a67d01af5700781073dce1e6e1b1f20567d7b532b2e1b7fc7dca71a701b26b10
data/README.md CHANGED
@@ -10,7 +10,7 @@ The following constraints apply:
10
10
 
11
11
  * No support for macruby extensions
12
12
  * Only support for the [modern AST](https://github.com/whitequark/parser/#usage) format
13
- * Only support for Ruby >= 3.0
13
+ * Only support for Ruby >= 3.1
14
14
 
15
15
  Notable Users:
16
16
 
@@ -20,9 +20,11 @@ module Unparser
20
20
  # @return [Object]
21
21
  #
22
22
  # @api public
23
+ #
24
+ # mutant:disable
23
25
  def freeze
24
26
  memoized_method_cache
25
- super()
27
+ super
26
28
  end
27
29
 
28
30
  private
@@ -5,7 +5,7 @@ module Unparser
5
5
 
6
6
  # Calculated local variable scope for a given node
7
7
  class LocalVariableScope
8
- include Enumerable, Adamantium, Concord.new(:node)
8
+ include Enumerable, Adamantium
9
9
 
10
10
  # Initialize object
11
11
  #
@@ -21,7 +21,6 @@ module Unparser
21
21
  items << scope
22
22
  end
23
23
  @items = items
24
- super(node)
25
24
  end
26
25
 
27
26
  # Test if local variable was first at given assignment
@@ -9,20 +9,11 @@ module Unparser
9
9
 
10
10
  children :target, :pattern
11
11
 
12
- # Modern ast format emits `match_pattern`
13
- # node on single line pre 3.0, but 3.0+ uses `match_pattern_p`
14
- SYMBOL =
15
- if RUBY_VERSION < '3.0'
16
- ' in '
17
- else
18
- ' => '
19
- end
20
-
21
12
  private
22
13
 
23
14
  def dispatch
24
15
  visit(target)
25
- write(SYMBOL)
16
+ write(' => ')
26
17
  visit(pattern)
27
18
  end
28
19
  end # MatchPattern
@@ -15,19 +15,30 @@ module Unparser
15
15
  private
16
16
 
17
17
  def dispatch
18
- if colon?(key)
19
- write(key.children.first.to_s, ': ')
18
+ if colon?
19
+ emit_colon
20
+ unless implicit_value?
21
+ write(' ')
22
+ visit(value)
23
+ end
20
24
  else
21
25
  visit(key)
22
26
  write(' => ')
27
+ visit(value)
23
28
  end
24
-
25
- visit(value)
26
29
  end
27
30
 
28
- def colon?(key)
31
+ def colon?
29
32
  n_sym?(key) && BAREWORD.match?(key.children.first)
30
33
  end
34
+
35
+ def emit_colon
36
+ write(key.children.first.to_s, ':')
37
+ end
38
+
39
+ def implicit_value?
40
+ n_lvar?(value) && value.children.first.equal?(key.children.first)
41
+ end
31
42
  end
32
43
  end
33
44
  end
@@ -10,7 +10,7 @@ module Unparser
10
10
  # Emitter for primitives based on Object#inspect
11
11
  class Inspect < self
12
12
 
13
- handle :sym, :str
13
+ handle :str
14
14
 
15
15
  private
16
16
 
@@ -20,6 +20,32 @@ module Unparser
20
20
 
21
21
  end # Inspect
22
22
 
23
+ class Symbol < self
24
+
25
+ handle :sym
26
+
27
+ private
28
+
29
+ # mutant:disable
30
+ def dispatch
31
+ if inspect_breaks_parsing?
32
+ write(":#{value.name.inspect}")
33
+ else
34
+ write(value.inspect)
35
+ end
36
+ end
37
+
38
+ # mutant:disable
39
+ def inspect_breaks_parsing?
40
+ return false unless RUBY_VERSION < '3.2.'
41
+
42
+ Unparser.parse(value.inspect)
43
+ false
44
+ rescue Parser::SyntaxError
45
+ true
46
+ end
47
+ end # Symbol
48
+
23
49
  # Emitter for complex literals
24
50
  class Complex < self
25
51
 
@@ -52,6 +52,7 @@ module Unparser
52
52
  kwargs
53
53
  kwsplat
54
54
  lambda
55
+ lvar
55
56
  match_rest
56
57
  pair
57
58
  rescue
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unparser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.12
4
+ version: 0.6.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Markus Schirp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-10 00:00:00.000000000 Z
11
+ date: 2024-06-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diff-lcs
@@ -30,42 +30,42 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 3.2.2.4
33
+ version: 3.3.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: 3.2.2.4
40
+ version: 3.3.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: mutant
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.11.22
47
+ version: 0.12.2
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.11.22
54
+ version: 0.12.2
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: mutant-rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 0.11.22
61
+ version: 0.12.2
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 0.11.22
68
+ version: 0.12.2
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -251,6 +251,7 @@ metadata:
251
251
  bug_tracker_uri: https://github.com/mbj/unparser/issues
252
252
  changelog_uri: https://github.com/mbj/unparser/blob/master/Changelog.md
253
253
  funding_uri: https://github.com/sponsors/mbj
254
+ source_code_uri: https://github.com/mbj/unparser
254
255
  rubygems_mfa_required: 'true'
255
256
  post_install_message:
256
257
  rdoc_options: []
@@ -260,14 +261,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
260
261
  requirements:
261
262
  - - ">="
262
263
  - !ruby/object:Gem::Version
263
- version: '3.0'
264
+ version: '3.1'
264
265
  required_rubygems_version: !ruby/object:Gem::Requirement
265
266
  requirements:
266
267
  - - ">="
267
268
  - !ruby/object:Gem::Version
268
269
  version: '0'
269
270
  requirements: []
270
- rubygems_version: 3.4.10
271
+ rubygems_version: 3.3.26
271
272
  signing_key:
272
273
  specification_version: 4
273
274
  summary: Generate equivalent source for parser gem AST nodes