parlour 5.0.0.beta.3 → 5.0.0.beta.4

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: 9c9fa581e9b41195e54a4716df7926d1beb225c47871ff39d2f08fb0fa462aeb
4
- data.tar.gz: 1aa333b0896df783baefa79d87fdbda732dea8676b85e89b7d76de607716658c
3
+ metadata.gz: 28a746eeb5c6322d0dfbfc53336bde66a65a35462f8e7685098aadd8720d3ade
4
+ data.tar.gz: 5cd5e9fe8cd248e1b7685134b3116f04c28e481d30ed6ac01b77b6f82aa7236b
5
5
  SHA512:
6
- metadata.gz: 30486957baea0d7b30f827483ca69fbf589bd55039bedbcee6ea4f6258c0601612d191818a547569b32fe2e805dd29e34f27a46005eb3d5586dd7cb3462f7fb2
7
- data.tar.gz: ed021b13ea01c171852be2d4892ba1042bc7dbf747e3413881e7d9c674553dea82337172c986dfec8ec78bfbed2be5519b6a091e2f3cd19f142797f54e35689e
6
+ metadata.gz: 51d1cdde17b3d84ae927343e7627efc2ef832440907b8f3ae40ec3cf20edcd20a8f7f76f3991933251a7542ccc7b6ac1269a98a268603e34eaaf043322e05625
7
+ data.tar.gz: d84ae4f6260e82de62dafdc67a7715c9cd74f01a68bbce8f5e89d0aa1f00509bd4a5230ec0fa7c850898f57936e29aee07c8f607935dbc1c784f4212ff709246
@@ -3,6 +3,11 @@ All notable changes to this project will be documented in this file.
3
3
 
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
5
5
 
6
+ ## [5.0.0.beta.4] - 2020-09-22
7
+ ### Added
8
+ - Added support for parsing type aliases from RBI
9
+ - Added conversion from RBI to RBS type aliases
10
+
6
11
  ## [5.0.0.beta.3] - 2020-09-15
7
12
  ### Changed
8
13
  - Changed the RBS keyword warning to come from "RBS generation" rather than
@@ -121,6 +121,12 @@ module Parlour
121
121
  type: node.value,
122
122
  ).add_comments(node.comments)
123
123
 
124
+ when RbiGenerator::TypeAlias
125
+ new_parent.create_type_alias(
126
+ node.name,
127
+ type: node.type,
128
+ ).add_comments(node.comments)
129
+
124
130
  when RbiGenerator::Extend
125
131
  new_parent.create_extend(node.name).add_comments(node.comments)
126
132
 
@@ -21,7 +21,7 @@ module Parlour
21
21
  yield_self(&block) if block
22
22
  end
23
23
 
24
- # @return [String] The type to alias to.
24
+ # @return [Types::TypeLike] The type to alias to.
25
25
  sig { returns(Types::TypeLike) }
26
26
  attr_reader :type
27
27
 
@@ -345,11 +345,28 @@ module Parlour
345
345
  end.flatten
346
346
  when :casgn
347
347
  _, name, body = *node
348
- [Parlour::RbiGenerator::Constant.new(
349
- generator,
350
- name: T.must(name).to_s,
351
- value: T.must(node_to_s(body)),
352
- )]
348
+
349
+ # Determine whether this is a constant or a type alias
350
+ # A type alias looks like:
351
+ # (block (send (const nil :T) :type_alias) (args) (type_to_alias))
352
+ if body.type == :block &&
353
+ body.to_a[0].type == :send &&
354
+ body.to_a[0].to_a[0].type == :const &&
355
+ body.to_a[0].to_a[0].to_a == [nil, :T] &&
356
+ body.to_a[0].to_a[1] == :type_alias
357
+
358
+ [Parlour::RbiGenerator::TypeAlias.new(
359
+ generator,
360
+ name: T.must(name).to_s,
361
+ type: T.must(node_to_s(body.to_a[2])),
362
+ )]
363
+ else
364
+ [Parlour::RbiGenerator::Constant.new(
365
+ generator,
366
+ name: T.must(name).to_s,
367
+ value: T.must(node_to_s(body)),
368
+ )]
369
+ end
353
370
  else
354
371
  if unknown_node_errors
355
372
  parse_err "don't understand node type #{node.type}", node
@@ -230,7 +230,7 @@ module Parlour
230
230
  class Array < SingleElementCollection
231
231
  sig { override.returns(String) }
232
232
  def collection_name
233
- 'Array'
233
+ '::Array'
234
234
  end
235
235
 
236
236
  sig { params(other: Object).returns(T::Boolean) }
@@ -243,7 +243,7 @@ module Parlour
243
243
  class Set < SingleElementCollection
244
244
  sig { override.returns(String) }
245
245
  def collection_name
246
- 'Set'
246
+ '::Set'
247
247
  end
248
248
 
249
249
  sig { params(other: Object).returns(T::Boolean) }
@@ -256,7 +256,7 @@ module Parlour
256
256
  class Range < SingleElementCollection
257
257
  sig { override.returns(String) }
258
258
  def collection_name
259
- 'Range'
259
+ '::Range'
260
260
  end
261
261
 
262
262
  sig { params(other: Object).returns(T::Boolean) }
@@ -269,7 +269,7 @@ module Parlour
269
269
  class Enumerable < SingleElementCollection
270
270
  sig { override.returns(String) }
271
271
  def collection_name
272
- 'Enumerable'
272
+ '::Enumerable'
273
273
  end
274
274
 
275
275
  sig { params(other: Object).returns(T::Boolean) }
@@ -282,7 +282,7 @@ module Parlour
282
282
  class Enumerator < SingleElementCollection
283
283
  sig { override.returns(String) }
284
284
  def collection_name
285
- 'Enumerator'
285
+ '::Enumerator'
286
286
  end
287
287
 
288
288
  sig { params(other: Object).returns(T::Boolean) }
@@ -317,7 +317,7 @@ module Parlour
317
317
 
318
318
  sig { override.returns(String) }
319
319
  def generate_rbs
320
- "Hash[#{key.generate_rbs}, #{value.generate_rbs}]"
320
+ "::Hash[#{key.generate_rbs}, #{value.generate_rbs}]"
321
321
  end
322
322
 
323
323
  sig { override.returns(String) }
@@ -1,5 +1,5 @@
1
1
  # typed: strong
2
2
  module Parlour
3
3
  # The library version.
4
- VERSION = '5.0.0.beta.3'
4
+ VERSION = '5.0.0.beta.4'
5
5
  end
@@ -3,7 +3,7 @@ module Kernel
3
3
  end
4
4
 
5
5
  module Parlour
6
- VERSION = '5.0.0.beta.3'
6
+ VERSION = '5.0.0.beta.4'
7
7
 
8
8
  class ConflictResolver
9
9
  extend T::Sig
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parlour
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0.beta.3
4
+ version: 5.0.0.beta.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Christiansen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-09-15 00:00:00.000000000 Z
11
+ date: 2020-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sorbet-runtime