ruby2ruby 2.2.0 → 2.3.0

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
  SHA1:
3
- metadata.gz: 4071b8713e84a587983a485ea48163835eafc4aa
4
- data.tar.gz: 4acc95c551e76369e017e4ee4edc13533e229d32
3
+ metadata.gz: eb8caf02a8d2b2af6ef49ddd52a55f62e4dc683a
4
+ data.tar.gz: bbdd946629c332a35d65d9919bad429510e64218
5
5
  SHA512:
6
- metadata.gz: 12cd7ca6f607eb86dee92655813e34c145b821df17b3057baea781c8b84882669686b02f1dd24a037eb7b674b0bde981c5930ba1d9f1b3ac0ff288ac25e130f7
7
- data.tar.gz: 4225c4aac264d6093d1e17a668daa4f54d608ee82bfb0b7c30f24fd9b13299e6e84a148d8b33da107f86f232ee44cd7c8b748015ee1d1f77d241a358e6ddf7e0
6
+ metadata.gz: 2ac5b2af3ec0b14d74abbb17f4247b2c590bb8072b2adfae590a16a59cd5b78ef746585ff6561f56d28250407fcbdf6d565aa96934f6536280c936a5c639ceef
7
+ data.tar.gz: 5b77706f664f28b47927fa6a81615719cc0ca8deedfcd090d541a80c53989292f6311794d41bbec7f1b9c328f5da167dac98567f9cc382650fbc1b5f07b623e3
Binary file
data.tar.gz.sig CHANGED
Binary file
@@ -1,3 +1,11 @@
1
+ === 2.3.0 / 2016-02-18
2
+
3
+ * 3 minor enhancements:
4
+
5
+ * Added support for safe navigation/lonely operator. (presidentbeef)
6
+ * Expanded tests for 2.3 support
7
+ * Support safe attrasgn. (presidentbeef).
8
+
1
9
  === 2.2.0 / 2015-05-27
2
10
 
3
11
  * 1 minor enhancement:
@@ -31,7 +31,7 @@ end
31
31
  # Generate ruby code from a sexp.
32
32
 
33
33
  class Ruby2Ruby < SexpProcessor
34
- VERSION = "2.2.0" # :nodoc:
34
+ VERSION = "2.3.0" # :nodoc:
35
35
 
36
36
  # cutoff for one-liners
37
37
  LINE_LENGTH = 78
@@ -218,7 +218,7 @@ class Ruby2Ruby < SexpProcessor
218
218
  end
219
219
  end
220
220
 
221
- def process_call(exp) # :nodoc:
221
+ def process_call(exp, safe_call = false) # :nodoc:
222
222
  receiver_node_type = exp.first.nil? ? nil : exp.first.first
223
223
  receiver = process exp.shift
224
224
  receiver = "(#{receiver})" if ASSIGN_NODES.include? receiver_node_type
@@ -254,7 +254,11 @@ class Ruby2Ruby < SexpProcessor
254
254
 
255
255
  case name
256
256
  when *BINARY then
257
- "(#{receiver} #{name} #{args.join(', ')})"
257
+ if safe_call
258
+ "#{receiver}&.#{name}(#{args.join(', ')})"
259
+ else
260
+ "(#{receiver} #{name} #{args.join(', ')})"
261
+ end
258
262
  when :[] then
259
263
  receiver ||= "self"
260
264
  "#{receiver}[#{args.join(', ')}]"
@@ -271,7 +275,8 @@ class Ruby2Ruby < SexpProcessor
271
275
  else
272
276
  args = nil if args.empty?
273
277
  args = "(#{args.join(', ')})" if args
274
- receiver = "#{receiver}." if receiver
278
+ receiver = "#{receiver}." if receiver and not safe_call
279
+ receiver = "#{receiver}&." if receiver and safe_call
275
280
 
276
281
  "#{receiver}#{name}#{args}"
277
282
  end
@@ -279,6 +284,10 @@ class Ruby2Ruby < SexpProcessor
279
284
  @calls.pop
280
285
  end
281
286
 
287
+ def process_safe_call(exp) # :nodoc:
288
+ process_call(exp, :safe)
289
+ end
290
+
282
291
  def process_case(exp) # :nodoc:
283
292
  result = []
284
293
  expr = process exp.shift
@@ -827,6 +836,24 @@ class Ruby2Ruby < SexpProcessor
827
836
  end
828
837
  end
829
838
 
839
+ def process_safe_attrasgn(exp) # :nodoc:
840
+ receiver = process exp.shift
841
+ name = exp.shift
842
+ rhs = exp.pop
843
+ args = exp.pop # should be nil
844
+ exp.clear
845
+
846
+ raise "dunno what to do: #{args.inspect}" if args
847
+
848
+ name = name.to_s.sub(/=$/, '')
849
+
850
+ if rhs && rhs != s(:arglist) then
851
+ "#{receiver}&.#{name} = #{process(rhs)}"
852
+ else
853
+ raise "dunno what to do: #{rhs.inspect}"
854
+ end
855
+ end
856
+
830
857
  def process_sclass(exp) # :nodoc:
831
858
  "class << #{process(exp.shift)}\n#{indent(process_block(exp))}\nend"
832
859
  end
@@ -19,7 +19,7 @@ class R2RTestCase < ParseTreeTestCase
19
19
  def self.generate_test klass, node, data, input_name, output_name
20
20
  output_name = data.has_key?('Ruby2Ruby') ? 'Ruby2Ruby' : 'Ruby'
21
21
 
22
- return if node.to_s =~ /(str_question|not|bang).*_(19|20|21|22)$/
22
+ return if node.to_s =~ /(str_question|not|bang).*_(19|20|21|22|23)$/
23
23
 
24
24
  klass.class_eval <<-EOM
25
25
  def test_#{node}
@@ -379,6 +379,39 @@ class TestRuby2Ruby < R2RTestCase
379
379
  util_compare inn, out
380
380
  end
381
381
 
382
+ def test_safe_attrasgn
383
+ inn = s(:safe_attrasgn,
384
+ s(:call, nil, :x),
385
+ :y=,
386
+ s(:lit, 1))
387
+
388
+ out = "x&.y = 1"
389
+
390
+ util_compare inn, out
391
+ end
392
+
393
+ def test_safe_call
394
+ inn = s(:safe_call,
395
+ s(:safe_call,
396
+ s(:call, nil, :x),
397
+ :y),
398
+ :z,
399
+ s(:lit, 1))
400
+
401
+ out ="x&.y&.z(1)"
402
+ util_compare inn, out
403
+ end
404
+
405
+ def test_safe_call_binary
406
+ inn = s(:safe_call,
407
+ s(:call, nil, :x),
408
+ :>,
409
+ s(:lit, 1))
410
+
411
+ out = "x&.>(1)"
412
+ util_compare inn, out
413
+ end
414
+
382
415
  def test_splat_call
383
416
  inn = s(:call, nil, :x,
384
417
  s(:splat,
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby2ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Davis
@@ -10,9 +10,9 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIDPjCCAiagAwIBAgIBAjANBgkqhkiG9w0BAQUFADBFMRMwEQYDVQQDDApyeWFu
13
+ MIIDPjCCAiagAwIBAgIBAzANBgkqhkiG9w0BAQUFADBFMRMwEQYDVQQDDApyeWFu
14
14
  ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
15
- GRYDY29tMB4XDTE0MDkxNzIzMDcwN1oXDTE1MDkxNzIzMDcwN1owRTETMBEGA1UE
15
+ GRYDY29tMB4XDTE1MDkxOTIwNTEyMloXDTE2MDkxODIwNTEyMlowRTETMBEGA1UE
16
16
  AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
17
17
  JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
18
18
  b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
@@ -22,14 +22,14 @@ cert_chain:
22
22
  qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
23
23
  gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
24
24
  HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBBQUAA4IB
25
- AQAFoDJRokCQdxFfOrmsKX41KOFlU/zjrbDVM9hgB/Ur999M6OXGSi8FitXNtMwY
26
- FVjsiAPeU7HaWVVcZkj6IhINelTkXsxgGz/qCzjHy3iUMuZWw36cS0fiWJ5rvH+e
27
- hD7uXxJSFuyf1riDGI1aeWbQ74WMwvNstOxLUMiV5a1fzBhlxPqb537ubDjq/M/h
28
- zPUFPVYeL5KjDHLCqI2FwIk2sEMOQgjpXHzl+3NlD2LUgUhHDMevmgVua0e2GT1B
29
- xJcC6UN6NHMOVMyAXsr2HR0gRRx4ofN1LoP2KhXzSr8UMvQYlwPmE0N5GQv1b5AO
30
- VpzF30vNaJK6ZT7xlIsIlwmH
25
+ AQB+Hx8xUgrpZa4P8H8gR8zme5kISwQrG80MbpqJV6/G3/ZicRFhN5sjwu0uHGue
26
+ bd9Cymf6oIRwHVarJux2M32T6bL07Hmi07w2QaPc3MnMKB/D46SRZ2JSSGPFRBTc
27
+ SilobMRoGs/7B15uGFUEnNrCB/ltMqhwwSx1r++UQPfeySHEV9uqu03E5Vb7J37O
28
+ 2Er6PLXHRiYsIycD1LkMi6YnixdITRHmrqJYE2rsjaIfpIehiusVAPHkNf7qbpHq
29
+ qx3h45R1CAsObX0SQDIT+rRbQrtKz1GHIZTOFYvEJjUY1XmRTZupD3CJ8Q7sDqSy
30
+ NLq5jm1fq6Y9Uolu3RJbmycf
31
31
  -----END CERTIFICATE-----
32
- date: 2015-05-27 00:00:00.000000000 Z
32
+ date: 2016-02-19 00:00:00.000000000 Z
33
33
  dependencies:
34
34
  - !ruby/object:Gem::Dependency
35
35
  name: sexp_processor
@@ -65,14 +65,14 @@ dependencies:
65
65
  requirements:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: '5.7'
68
+ version: '5.8'
69
69
  type: :development
70
70
  prerelease: false
71
71
  version_requirements: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - ~>
74
74
  - !ruby/object:Gem::Version
75
- version: '5.7'
75
+ version: '5.8'
76
76
  - !ruby/object:Gem::Dependency
77
77
  name: rdoc
78
78
  requirement: !ruby/object:Gem::Requirement
@@ -93,14 +93,14 @@ dependencies:
93
93
  requirements:
94
94
  - - ~>
95
95
  - !ruby/object:Gem::Version
96
- version: '3.13'
96
+ version: '3.14'
97
97
  type: :development
98
98
  prerelease: false
99
99
  version_requirements: !ruby/object:Gem::Requirement
100
100
  requirements:
101
101
  - - ~>
102
102
  - !ruby/object:Gem::Version
103
- version: '3.13'
103
+ version: '3.14'
104
104
  description: |-
105
105
  ruby2ruby provides a means of generating pure ruby code easily from
106
106
  RubyParser compatible Sexps. This makes making dynamic language
@@ -116,7 +116,6 @@ extra_rdoc_files:
116
116
  - README.txt
117
117
  files:
118
118
  - .autotest
119
- - .gemtest
120
119
  - History.txt
121
120
  - Manifest.txt
122
121
  - README.txt
metadata.gz.sig CHANGED
Binary file
data/.gemtest DELETED
File without changes