parlour 5.0.0.beta.6 → 5.0.0

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: 1715bb17e55bec8c3c5e9879e2304b3357f4c56fa4969a7100e309be02c252a1
4
- data.tar.gz: aea13230a97e42b09eed1b120d311d21e9b1deddf6530869a254e34b55745678
3
+ metadata.gz: cb1e682fc74b2ccd30ac9055caf652889e898e2632347bf6cf0898f218bd5562
4
+ data.tar.gz: fcca5ca04676cbeed657add051e344fd9b5fa0a7efc757339847310300aa4d42
5
5
  SHA512:
6
- metadata.gz: 2adc666069616d219bbdc22d817b6d26b3775f64be30c2fa889c50022979674f5c066b2eed71cb2427f6015dcab5bc4247d23e539ae8d91ec5196164524d7966
7
- data.tar.gz: 5761fe954c1dd8bb2a6a17fa1b4a92b21d6d61ab2ad1478e0e5387f09e5918ce264acea38909c54dc89df77417301d26903a2697520a25101e1a154a4b3f0ddb
6
+ metadata.gz: cef41723b922734b49f8377dc3b5c60cf0071d2a9723326299872fea4789f8e6ea1cb280fcd21161d48bd5dbb074b416e60668138116e56caf1c8334cce8e535
7
+ data.tar.gz: b9ea0db060c8789e1324460cde4a69b1c20b829920e660024f53834e48cef536b5423736e6fce4859c2e2fea5339e3f26bdd7513947bafcc82bd239db57cc68a
@@ -3,6 +3,7 @@ dist: trusty
3
3
  before_install:
4
4
  - gem install bundler
5
5
  - gem install yard
6
+ - chmod +x ci/check_rbi.sh
6
7
  rvm:
7
8
  - 2.3
8
9
  - 2.4
@@ -13,6 +14,9 @@ rvm:
13
14
 
14
15
  jobs:
15
16
  include:
17
+ - stage: check RBI
18
+ script: ./ci/check_rbi.sh
19
+ rvm: 2.7
16
20
  - stage: deploy documentation
17
21
  script: yard
18
22
  deploy:
@@ -3,42 +3,13 @@ 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.6] - 2020-10-04
7
- ### Fixed
8
- - Fixed collection types sometimes generating as `T::::Array`
9
-
10
- ## [5.0.0.beta.5] - 2020-10-03
11
- ### Added
12
- - Added `Types::Generic` for user-defined generic types
13
-
14
- ## [5.0.0.beta.4] - 2020-09-22
15
- ### Added
16
- - Added support for parsing type aliases from RBI
17
- - Added conversion from RBI to RBS type aliases
18
-
19
- ## [5.0.0.beta.3] - 2020-09-15
20
- ### Changed
21
- - Changed the RBS keyword warning to come from "RBS generation" rather than
22
- "Type generalization"
23
- - Added many more of RBS' keywords which are detected and prefixed with an
24
- underscore to avoid syntax errors
25
-
26
- ## [5.0.0.beta.2] - 2020-09-14
27
- ### Added
28
- - Added `Types::Type#describe` for simple text descriptions of types
29
- - Added `Types::Self` for RBI's `T.self_type` or RBS' `self`
30
-
31
- ### Fixed
32
- - Fixed `RbiGenerator::Namespace#create_method`'s `returns:` kwarg only
33
- accepting String types
34
- - Fixed lack of spacing between argument lists and blocks in RBS
35
- - Fixed RBS attributes not having comments
36
-
37
- ## [5.0.0.beta.1] - 2020-09-13
6
+ ## [5.0.0] - 2020-12-26
38
7
  ### Added
39
8
  - Added RBS generation support! This includes:
40
9
  - The new `RbsGenerator` class
41
10
  - `RbsObject` and a set of subclasses representing different RBS components
11
+ - **Note:** RBS does not yet support Parlour plugins and some other features.
12
+ Refer to the README for a full breakdown!
42
13
  - Added the `Types` module, which is used to describe types agnostic of the
43
14
  underlying type system
44
15
  - Added `RbiGenerator::Namespace#generalize_from_rbi!` to convert RBI string
@@ -50,6 +21,66 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
50
21
  - `TypedObject`, which `RbiObject` and `RbsObject` both inherit from
51
22
  - `Generator`, which `RbiGenerator` and `RbsGenerator` both inherit from
52
23
  - Added RBI type aliases
24
+ - Added `sealed!` for RBI namespaces
25
+ - Added `abstract!` for RBI modules
26
+
27
+ ### Changed
28
+ - `Parlour::RbiGenerator::Options` is now `Parlour::Options`. An alias exists
29
+ for now, but **`Parlour::RbiGenerator::Options` is deprecated** and could be
30
+ removed in future versions.
31
+ - Updated README and gem metadata to refer to Parlour as a type information
32
+ generator, rather than just an RBI generator
33
+
34
+ <details>
35
+ <summary>5.0.0 pre-releases</summary>
36
+
37
+ ## [5.0.0.beta.6] - 2020-10-04
38
+ ### Fixed
39
+ - Fixed collection types sometimes generating as `T::::Array`
40
+
41
+ ## [5.0.0.beta.5] - 2020-10-03
42
+ ### Added
43
+ - Added `Types::Generic` for user-defined generic types
44
+
45
+ ## [5.0.0.beta.4] - 2020-09-22
46
+ ### Added
47
+ - Added support for parsing type aliases from RBI
48
+ - Added conversion from RBI to RBS type aliases
49
+
50
+ ## [5.0.0.beta.3] - 2020-09-15
51
+ ### Changed
52
+ - Changed the RBS keyword warning to come from "RBS generation" rather than
53
+ "Type generalization"
54
+ - Added many more of RBS' keywords which are detected and prefixed with an
55
+ underscore to avoid syntax errors
56
+
57
+ ## [5.0.0.beta.2] - 2020-09-14
58
+ ### Added
59
+ - Added `Types::Type#describe` for simple text descriptions of types
60
+ - Added `Types::Self` for RBI's `T.self_type` or RBS' `self`
61
+
62
+ ### Fixed
63
+ - Fixed `RbiGenerator::Namespace#create_method`'s `returns:` kwarg only
64
+ accepting String types
65
+ - Fixed lack of spacing between argument lists and blocks in RBS
66
+ - Fixed RBS attributes not having comments
67
+
68
+ ## [5.0.0.beta.1] - 2020-09-13
69
+ ### Added
70
+ - Added RBS generation support! This includes:
71
+ - The new `RbsGenerator` class
72
+ - `RbsObject` and a set of subclasses representing different RBS components
73
+ - Added the `Types` module, which is used to describe types agnostic of the
74
+ underlying type system
75
+ - Added `RbiGenerator::Namespace#generalize_from_rbi!` to convert RBI string
76
+ types into `Types` types
77
+ - **Specifying types as strings is still currently supported, but may be
78
+ phased out in future, and should be avoided in new projects**.
79
+ - Added conversion from RBI to RBS type trees
80
+ - Added a couple of classes to deduplicate functionality between type systems:
81
+ - `TypedObject`, which `RbiObject` and `RbsObject` both inherit from
82
+ - `Generator`, which `RbiGenerator` and `RbsGenerator` both inherit from
83
+ - Added RBI type aliases
53
84
 
54
85
  ### Changed
55
86
  - `Parlour::RbiGenerator::Options` is now `Parlour::Options`. An alias exists
@@ -57,6 +88,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
57
88
  removed in future versions.
58
89
  - Updated README and gem metadata to refer to Parlour as a type information
59
90
  generator, rather than just an RBI generator
91
+ </details>
60
92
 
61
93
  ## [4.0.1] - 2020-08-05
62
94
  ### Fixed
data/README.md CHANGED
@@ -407,6 +407,8 @@ srb rbi gems
407
407
  srb rbi sorbet-typed
408
408
  ```
409
409
 
410
+ You should also regenerate the parlour.rbi file by running `bundle exec parlour`. Don't edit this file manually, as your changes will be overwritten!
411
+
410
412
  ## License
411
413
 
412
414
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,9 @@
1
+ #!/bin/bash
2
+ # Checks that the RBI in rbi/parlour.rbi is up-to-date with committed changes.
3
+ # This is done by generating a new RBI and comparing it with the committed RBI.
4
+ set -ev
5
+
6
+ bundle install
7
+ mv rbi/parlour.rbi rbi/parlour-committed.rbi
8
+ bundle exec parlour
9
+ cmp -s rbi/parlour.rbi rbi/parlour-committed.rbi
@@ -10,6 +10,7 @@ module Parlour
10
10
  generator: Generator,
11
11
  name: String,
12
12
  final: T::Boolean,
13
+ sealed: T::Boolean,
13
14
  superclass: T.nilable(String),
14
15
  abstract: T::Boolean,
15
16
  block: T.nilable(T.proc.params(x: ClassNamespace).void)
@@ -21,13 +22,14 @@ module Parlour
21
22
  # @param generator [RbiGenerator] The current RbiGenerator.
22
23
  # @param name [String] The name of this class.
23
24
  # @param final [Boolean] Whether this namespace is final.
25
+ # @param sealed [Boolean] Whether this namespace is sealed.
24
26
  # @param superclass [String, nil] The superclass of this class, or nil if it doesn't
25
27
  # have one.
26
28
  # @param abstract [Boolean] A boolean indicating whether this class is abstract.
27
29
  # @param block A block which the new instance yields itself to.
28
30
  # @return [void]
29
- def initialize(generator, name, final, superclass, abstract, &block)
30
- super(generator, name, final, &block)
31
+ def initialize(generator, name, final, sealed, superclass, abstract, &block)
32
+ super(generator, name, final, sealed, &block)
31
33
  @superclass = superclass
32
34
  @abstract = abstract
33
35
  end
@@ -10,6 +10,7 @@ module Parlour
10
10
  generator: Generator,
11
11
  name: String,
12
12
  final: T::Boolean,
13
+ sealed: T::Boolean,
13
14
  enums: T::Array[T.any([String, String], String)],
14
15
  abstract: T::Boolean,
15
16
  block: T.nilable(T.proc.params(x: EnumClassNamespace).void)
@@ -21,12 +22,13 @@ module Parlour
21
22
  # @param generator [RbiGenerator] The current RbiGenerator.
22
23
  # @param name [String] The name of this class.
23
24
  # @param final [Boolean] Whether this namespace is final.
25
+ # @param sealed [Boolean] Whether this namespace is sealed.
24
26
  # @param enums [Array<(String, String), String>] The values of the enumeration.
25
27
  # @param abstract [Boolean] A boolean indicating whether this class is abstract.
26
28
  # @param block A block which the new instance yields itself to.
27
29
  # @return [void]
28
- def initialize(generator, name, final, enums, abstract, &block)
29
- super(generator, name, final, 'T::Enum', abstract, &block)
30
+ def initialize(generator, name, final, sealed, enums, abstract, &block)
31
+ super(generator, name, final, sealed, 'T::Enum', abstract, &block)
30
32
  @enums = enums
31
33
  end
32
34
 
@@ -10,24 +10,29 @@ module Parlour
10
10
  generator: Generator,
11
11
  name: String,
12
12
  final: T::Boolean,
13
+ sealed: T::Boolean,
13
14
  interface: T::Boolean,
15
+ abstract: T::Boolean,
14
16
  block: T.nilable(T.proc.params(x: ClassNamespace).void)
15
17
  ).void
16
18
  end
17
19
  # Creates a new module definition.
18
20
  # @note You should use {Namespace#create_module} rather than this directly.
19
- #
21
+ #
20
22
  # @param generator [RbiGenerator] The current RbiGenerator.
21
23
  # @param name [String] The name of this module.
22
24
  # @param final [Boolean] Whether this namespace is final.
25
+ # @param sealed [Boolean] Whether this namespace is sealed.
23
26
  # @param interface [Boolean] A boolean indicating whether this module is an
24
27
  # interface.
28
+ # @param abstract [Boolean] A boolean indicating whether this module is abstract.
25
29
  # @param block A block which the new instance yields itself to.
26
30
  # @return [void]
27
- def initialize(generator, name, final, interface, &block)
28
- super(generator, name, final, &block)
31
+ def initialize(generator, name, final, sealed, interface, abstract, &block)
32
+ super(generator, name, final, sealed, &block)
29
33
  @name = name
30
34
  @interface = interface
35
+ @abstract = abstract
31
36
  end
32
37
 
33
38
  sig do
@@ -41,10 +46,11 @@ module Parlour
41
46
  # @param indent_level [Integer] The indentation level to generate the lines at.
42
47
  # @param options [Options] The formatting options to use.
43
48
  # @return [Array<String>] The RBI lines, formatted as specified.
44
- def generate_rbi(indent_level, options)
49
+ def generate_rbi(indent_level, options)
45
50
  lines = generate_comments(indent_level, options)
46
51
  lines << options.indented(indent_level, "module #{name}")
47
52
  lines += [options.indented(indent_level + 1, "interface!"), ""] if interface
53
+ lines += [options.indented(indent_level + 1, "abstract!"), ""] if abstract
48
54
  lines += generate_body(indent_level + 1, options)
49
55
  lines << options.indented(indent_level, "end")
50
56
  end
@@ -54,6 +60,11 @@ module Parlour
54
60
  # @return [Boolean]
55
61
  attr_reader :interface
56
62
 
63
+ sig { returns(T::Boolean) }
64
+ # A boolean indicating whether this module is abstract or not.
65
+ # @return [Boolean]
66
+ attr_reader :abstract
67
+
57
68
  sig do
58
69
  override.params(
59
70
  others: T::Array[RbiGenerator::RbiObject]
@@ -61,7 +72,7 @@ module Parlour
61
72
  end
62
73
  # Given an array of {Namespace} instances, returns true if they may
63
74
  # be merged into this instance using {merge_into_self}. For instances to
64
- # be mergeable, they must either all be interfaces or all not be
75
+ # be mergeable, they must either all be interfaces or all not be
65
76
  # interfaces.
66
77
  #
67
78
  # @param others [Array<RbiGenerator::RbiObject>] An array of other {Namespace} instances.
@@ -75,7 +86,7 @@ module Parlour
75
86
  all_modules.map(&:interface).uniq.length == 1
76
87
  end
77
88
 
78
- sig do
89
+ sig do
79
90
  override.params(
80
91
  others: T::Array[RbiGenerator::RbiObject]
81
92
  ).void
@@ -93,7 +104,8 @@ module Parlour
93
104
  # Returns a human-readable brief string description of this module.
94
105
  # @return [String]
95
106
  def describe
96
- "Module #{name} - #{"interface, " if interface}#{children.length} " +
107
+ "Module #{name} - #{"interface, " if interface}" +
108
+ "#{"abstract, " if abstract}#{children.length} " +
97
109
  "children, #{includes.length} includes, #{extends.length} extends"
98
110
  end
99
111
 
@@ -27,6 +27,7 @@ module Parlour
27
27
  generator: Generator,
28
28
  name: T.nilable(String),
29
29
  final: T::Boolean,
30
+ sealed: T::Boolean,
30
31
  block: T.nilable(T.proc.params(x: Namespace).void)
31
32
  ).void
32
33
  end
@@ -37,13 +38,15 @@ module Parlour
37
38
  # @param generator [RbiGenerator] The current RbiGenerator.
38
39
  # @param name [String, nil] The name of this module.
39
40
  # @param final [Boolean] Whether this namespace is final.
41
+ # @param final [Boolean] Whether this namespace is sealed.
40
42
  # @param block A block which the new instance yields itself to.
41
43
  # @return [void]
42
- def initialize(generator, name = nil, final = false, &block)
44
+ def initialize(generator, name = nil, final = false, sealed = false, &block)
43
45
  super(generator, name || '<anonymous namespace>')
44
46
  @children = []
45
47
  @next_comments = []
46
48
  @final = final
49
+ @sealed = sealed
47
50
  yield_self(&block) if block
48
51
  end
49
52
 
@@ -52,6 +55,11 @@ module Parlour
52
55
  # @return [Boolean]
53
56
  attr_reader :final
54
57
 
58
+ sig { returns(T::Boolean) }
59
+ # Whether this namespace is sealed.
60
+ # @return [Boolean]
61
+ attr_reader :sealed
62
+
55
63
  sig { returns(T::Array[RbiObject]) }
56
64
  # The child {RbiObject} instances inside this namespace.
57
65
  # @return [Array<RbiObject>]
@@ -151,6 +159,7 @@ module Parlour
151
159
  params(
152
160
  name: String,
153
161
  final: T::Boolean,
162
+ sealed: T::Boolean,
154
163
  superclass: T.nilable(String),
155
164
  abstract: T::Boolean,
156
165
  block: T.nilable(T.proc.params(x: ClassNamespace).void)
@@ -168,13 +177,14 @@ module Parlour
168
177
  #
169
178
  # @param name [String] The name of this class.
170
179
  # @param final [Boolean] Whether this namespace is final.
180
+ # @param sealed [Boolean] Whether this namespace is sealed.
171
181
  # @param superclass [String, nil] The superclass of this class, or nil if it doesn't
172
182
  # have one.
173
183
  # @param abstract [Boolean] A boolean indicating whether this class is abstract.
174
184
  # @param block A block which the new instance yields itself to.
175
185
  # @return [ClassNamespace]
176
- def create_class(name, final: false, superclass: nil, abstract: false, &block)
177
- new_class = ClassNamespace.new(generator, name, final, superclass, abstract, &block)
186
+ def create_class(name, final: false, sealed: false, superclass: nil, abstract: false, &block)
187
+ new_class = ClassNamespace.new(generator, name, final, sealed, superclass, abstract, &block)
178
188
  move_next_comments(new_class)
179
189
  children << new_class
180
190
  new_class
@@ -184,6 +194,7 @@ module Parlour
184
194
  params(
185
195
  name: String,
186
196
  final: T::Boolean,
197
+ sealed: T::Boolean,
187
198
  enums: T.nilable(T::Array[T.any([String, String], String)]),
188
199
  abstract: T::Boolean,
189
200
  block: T.nilable(T.proc.params(x: EnumClassNamespace).void)
@@ -196,12 +207,13 @@ module Parlour
196
207
  #
197
208
  # @param name [String] The name of this class.
198
209
  # @param final [Boolean] Whether this namespace is final.
210
+ # @param sealed [Boolean] Whether this namespace is sealed.
199
211
  # @param enums [Array<(String, String), String>] The values of the enumeration.
200
212
  # @param abstract [Boolean] A boolean indicating whether this class is abstract.
201
213
  # @param block A block which the new instance yields itself to.
202
214
  # @return [EnumClassNamespace]
203
- def create_enum_class(name, final: false, enums: nil, abstract: false, &block)
204
- new_enum_class = EnumClassNamespace.new(generator, name, final, enums || [], abstract, &block)
215
+ def create_enum_class(name, final: false, sealed: false, enums: nil, abstract: false, &block)
216
+ new_enum_class = EnumClassNamespace.new(generator, name, final, sealed, enums || [], abstract, &block)
205
217
  move_next_comments(new_enum_class)
206
218
  children << new_enum_class
207
219
  new_enum_class
@@ -211,6 +223,7 @@ module Parlour
211
223
  params(
212
224
  name: String,
213
225
  final: T::Boolean,
226
+ sealed: T::Boolean,
214
227
  props: T.nilable(T::Array[StructProp]),
215
228
  abstract: T::Boolean,
216
229
  block: T.nilable(T.proc.params(x: StructClassNamespace).void)
@@ -225,12 +238,13 @@ module Parlour
225
238
  #
226
239
  # @param name [String] The name of this class.
227
240
  # @param final [Boolean] Whether this namespace is final.
241
+ # @param sealed [Boolean] Whether this namespace is sealed.
228
242
  # @param props [Array<StructProp>] The props of the struct.
229
243
  # @param abstract [Boolean] A boolean indicating whether this class is abstract.
230
244
  # @param block A block which the new instance yields itself to.
231
245
  # @return [EnumClassNamespace]
232
- def create_struct_class(name, final: false, props: nil, abstract: false, &block)
233
- new_struct_class = StructClassNamespace.new(generator, name, final, props || [], abstract, &block)
246
+ def create_struct_class(name, final: false, sealed: false, props: nil, abstract: false, &block)
247
+ new_struct_class = StructClassNamespace.new(generator, name, final, sealed, props || [], abstract, &block)
234
248
  move_next_comments(new_struct_class)
235
249
  children << new_struct_class
236
250
  new_struct_class
@@ -240,7 +254,9 @@ module Parlour
240
254
  params(
241
255
  name: String,
242
256
  final: T::Boolean,
257
+ sealed: T::Boolean,
243
258
  interface: T::Boolean,
259
+ abstract: T::Boolean,
244
260
  block: T.nilable(T.proc.params(x: ClassNamespace).void)
245
261
  ).returns(ModuleNamespace)
246
262
  end
@@ -256,12 +272,15 @@ module Parlour
256
272
  #
257
273
  # @param name [String] The name of this module.
258
274
  # @param final [Boolean] Whether this namespace is final.
275
+ # @param sealed [Boolean] Whether this namespace is sealed.
259
276
  # @param interface [Boolean] A boolean indicating whether this module is an
260
277
  # interface.
278
+ # @param abstract [Boolean] A boolean indicating whether this module is
279
+ # abstract.
261
280
  # @param block A block which the new instance yields itself to.
262
281
  # @return [ModuleNamespace]
263
- def create_module(name, final: false, interface: false, &block)
264
- new_module = ModuleNamespace.new(generator, name, final, interface, &block)
282
+ def create_module(name, final: false, sealed: false, interface: false, abstract: false, &block)
283
+ new_module = ModuleNamespace.new(generator, name, final, sealed, interface, abstract, &block)
265
284
  move_next_comments(new_module)
266
285
  children << new_module
267
286
  new_module
@@ -657,6 +676,7 @@ module Parlour
657
676
  result = []
658
677
 
659
678
  result += [options.indented(indent_level, 'final!'), ''] if final
679
+ result += [options.indented(indent_level, 'sealed!'), ''] if sealed
660
680
 
661
681
  # Split away the eigen constants; these need to be put in a
662
682
  # "class << self" block later
@@ -39,7 +39,7 @@ module Parlour
39
39
  @name = name
40
40
 
41
41
  prefix = /^(\*\*|\*|\&)?/.match(name)&.captures&.first || ''
42
- @kind = PREFIXES.rassoc(prefix).first
42
+ @kind = T.must(PREFIXES.rassoc(prefix)).first
43
43
 
44
44
  @kind = :keyword if kind == :normal && name.end_with?(':')
45
45
 
@@ -123,12 +123,12 @@ module Parlour
123
123
  end
124
124
 
125
125
  # A mapping of {kind} values to the characteristic prefixes each kind has.
126
- PREFIXES = {
126
+ PREFIXES = T.let({
127
127
  normal: '',
128
128
  splat: '*',
129
129
  double_splat: '**',
130
130
  block: '&'
131
- }.freeze
131
+ }.freeze, T::Hash[Symbol, String])
132
132
 
133
133
  sig { void }
134
134
  def generalize_from_rbi!
@@ -11,6 +11,7 @@ module Parlour
11
11
  generator: Generator,
12
12
  name: String,
13
13
  final: T::Boolean,
14
+ sealed: T::Boolean,
14
15
  props: T::Array[StructProp],
15
16
  abstract: T::Boolean,
16
17
  block: T.nilable(T.proc.params(x: StructClassNamespace).void)
@@ -22,12 +23,13 @@ module Parlour
22
23
  # @param generator [RbiGenerator] The current RbiGenerator.
23
24
  # @param name [String] The name of this class.
24
25
  # @param final [Boolean] Whether this namespace is final.
26
+ # @param sealed [Boolean] Whether this namespace is sealed.
25
27
  # @param props [Array<StructProp>] The props of the struct.
26
28
  # @param abstract [Boolean] A boolean indicating whether this class is abstract.
27
29
  # @param block A block which the new instance yields itself to.
28
30
  # @return [void]
29
- def initialize(generator, name, final, props, abstract, &block)
30
- super(generator, name, final, 'T::Struct', abstract, &block)
31
+ def initialize(generator, name, final, sealed, props, abstract, &block)
32
+ super(generator, name, final, sealed, 'T::Struct', abstract, &block)
31
33
  @props = props
32
34
  end
33
35
 
@@ -112,9 +112,9 @@ module Parlour
112
112
  attr_reader :redaction
113
113
 
114
114
  # The optional properties available on instances of this class.
115
- EXTRA_PROPERTIES = %i{
115
+ EXTRA_PROPERTIES = T.let(%i{
116
116
  optional enum dont_store foreign default factory immutable array override redaction
117
- }
117
+ }, T::Array[Symbol])
118
118
 
119
119
  sig { returns(String) }
120
120
  # Returns the +prop+ call required to create this property.
@@ -89,7 +89,7 @@ module Parlour
89
89
 
90
90
  # Merge the first signature line, and indent & concat the rest
91
91
  first_line, *rest_lines = *partial_sig_lines
92
- this_sig_lines[0] += first_line
92
+ this_sig_lines[0] = T.unsafe(this_sig_lines[0]) + first_line
93
93
  rest_lines&.each do |line|
94
94
  this_sig_lines << ' ' * definition.length + options.indented(indent_level, line)
95
95
  end
@@ -158,6 +158,7 @@ module Parlour
158
158
 
159
159
  name, superclass, body = *node
160
160
  final = body_has_modifier?(body, :final!)
161
+ sealed = body_has_modifier?(body, :sealed!)
161
162
  abstract = body_has_modifier?(body, :abstract!)
162
163
  includes, extends = body ? body_includes_and_extends(body) : [[], []]
163
164
 
@@ -170,6 +171,7 @@ module Parlour
170
171
  generator,
171
172
  n.to_s,
172
173
  false,
174
+ false,
173
175
  )
174
176
  target.children << new_obj if target
175
177
  target = new_obj
@@ -233,6 +235,7 @@ module Parlour
233
235
  generator,
234
236
  this_name.to_s,
235
237
  final,
238
+ sealed,
236
239
  props,
237
240
  abstract,
238
241
  )
@@ -256,6 +259,7 @@ module Parlour
256
259
  generator,
257
260
  this_name.to_s,
258
261
  final,
262
+ sealed,
259
263
  enums,
260
264
  abstract,
261
265
  )
@@ -264,6 +268,7 @@ module Parlour
264
268
  generator,
265
269
  this_name.to_s,
266
270
  final,
271
+ sealed,
267
272
  node_to_s(superclass),
268
273
  abstract,
269
274
  )
@@ -275,7 +280,7 @@ module Parlour
275
280
 
276
281
  if target
277
282
  target.children << final_obj
278
- [top_level]
283
+ [T.must(top_level)]
279
284
  else
280
285
  [final_obj]
281
286
  end
@@ -283,7 +288,9 @@ module Parlour
283
288
  parse_err 'cannot declare modules in an eigenclass', node if is_within_eigenclass
284
289
 
285
290
  name, body = *node
291
+ abstract = body_has_modifier?(body, :abstract!)
286
292
  final = body_has_modifier?(body, :final!)
293
+ sealed = body_has_modifier?(body, :sealed!)
287
294
  interface = body_has_modifier?(body, :interface!)
288
295
  includes, extends = body ? body_includes_and_extends(body) : [[], []]
289
296
 
@@ -296,6 +303,7 @@ module Parlour
296
303
  generator,
297
304
  n.to_s,
298
305
  false,
306
+ false,
299
307
  )
300
308
  target.children << new_obj if target
301
309
  target = new_obj
@@ -306,7 +314,9 @@ module Parlour
306
314
  generator,
307
315
  this_name.to_s,
308
316
  final,
317
+ sealed,
309
318
  interface,
319
+ abstract,
310
320
  ) do |m|
311
321
  m.children.concat(parse_path_to_object(path.child(1))) if body
312
322
  m.create_includes(includes)
@@ -315,7 +325,7 @@ module Parlour
315
325
 
316
326
  if target
317
327
  target.children << final_obj
318
- [top_level]
328
+ [T.must(top_level)]
319
329
  else
320
330
  [final_obj]
321
331
  end
@@ -1,5 +1,5 @@
1
1
  # typed: strong
2
2
  module Parlour
3
3
  # The library version.
4
- VERSION = '5.0.0.beta.6'
4
+ VERSION = '5.0.0'
5
5
  end
@@ -3,7 +3,7 @@ module Kernel
3
3
  end
4
4
 
5
5
  module Parlour
6
- VERSION = '5.0.0.beta.6'
6
+ VERSION = '5.0.0'
7
7
 
8
8
  class ConflictResolver
9
9
  extend T::Sig
@@ -772,12 +772,13 @@ module Parlour
772
772
  generator: Generator,
773
773
  name: String,
774
774
  final: T::Boolean,
775
+ sealed: T::Boolean,
775
776
  superclass: T.nilable(String),
776
777
  abstract: T::Boolean,
777
778
  block: T.nilable(T.proc.params(x: ClassNamespace).void)
778
779
  ).void
779
780
  end
780
- def initialize(generator, name, final, superclass, abstract, &block); end
781
+ def initialize(generator, name, final, sealed, superclass, abstract, &block); end
781
782
 
782
783
  sig { override.params(indent_level: Integer, options: Options).returns(T::Array[String]) }
783
784
  def generate_rbi(indent_level, options); end
@@ -846,12 +847,13 @@ module Parlour
846
847
  generator: Generator,
847
848
  name: String,
848
849
  final: T::Boolean,
850
+ sealed: T::Boolean,
849
851
  enums: T::Array[T.any([String, String], String)],
850
852
  abstract: T::Boolean,
851
853
  block: T.nilable(T.proc.params(x: EnumClassNamespace).void)
852
854
  ).void
853
855
  end
854
- def initialize(generator, name, final, enums, abstract, &block); end
856
+ def initialize(generator, name, final, sealed, enums, abstract, &block); end
855
857
 
856
858
  sig { returns(T::Array[T.any([String, String], String)]) }
857
859
  attr_reader :enums
@@ -996,11 +998,13 @@ module Parlour
996
998
  generator: Generator,
997
999
  name: String,
998
1000
  final: T::Boolean,
1001
+ sealed: T::Boolean,
999
1002
  interface: T::Boolean,
1003
+ abstract: T::Boolean,
1000
1004
  block: T.nilable(T.proc.params(x: ClassNamespace).void)
1001
1005
  ).void
1002
1006
  end
1003
- def initialize(generator, name, final, interface, &block); end
1007
+ def initialize(generator, name, final, sealed, interface, abstract, &block); end
1004
1008
 
1005
1009
  sig { override.params(indent_level: Integer, options: Options).returns(T::Array[String]) }
1006
1010
  def generate_rbi(indent_level, options); end
@@ -1008,6 +1012,9 @@ module Parlour
1008
1012
  sig { returns(T::Boolean) }
1009
1013
  attr_reader :interface
1010
1014
 
1015
+ sig { returns(T::Boolean) }
1016
+ attr_reader :abstract
1017
+
1011
1018
  sig { override.params(others: T::Array[RbiGenerator::RbiObject]).returns(T::Boolean) }
1012
1019
  def mergeable?(others); end
1013
1020
 
@@ -1032,14 +1039,18 @@ module Parlour
1032
1039
  generator: Generator,
1033
1040
  name: T.nilable(String),
1034
1041
  final: T::Boolean,
1042
+ sealed: T::Boolean,
1035
1043
  block: T.nilable(T.proc.params(x: Namespace).void)
1036
1044
  ).void
1037
1045
  end
1038
- def initialize(generator, name = nil, final = false, &block); end
1046
+ def initialize(generator, name = nil, final = false, sealed = false, &block); end
1039
1047
 
1040
1048
  sig { returns(T::Boolean) }
1041
1049
  attr_reader :final
1042
1050
 
1051
+ sig { returns(T::Boolean) }
1052
+ attr_reader :sealed
1053
+
1043
1054
  sig { returns(T::Array[RbiObject]) }
1044
1055
  attr_reader :children
1045
1056
 
@@ -1065,44 +1076,49 @@ module Parlour
1065
1076
  params(
1066
1077
  name: String,
1067
1078
  final: T::Boolean,
1079
+ sealed: T::Boolean,
1068
1080
  superclass: T.nilable(String),
1069
1081
  abstract: T::Boolean,
1070
1082
  block: T.nilable(T.proc.params(x: ClassNamespace).void)
1071
1083
  ).returns(ClassNamespace)
1072
1084
  end
1073
- def create_class(name, final: false, superclass: nil, abstract: false, &block); end
1085
+ def create_class(name, final: false, sealed: false, superclass: nil, abstract: false, &block); end
1074
1086
 
1075
1087
  sig do
1076
1088
  params(
1077
1089
  name: String,
1078
1090
  final: T::Boolean,
1091
+ sealed: T::Boolean,
1079
1092
  enums: T.nilable(T::Array[T.any([String, String], String)]),
1080
1093
  abstract: T::Boolean,
1081
1094
  block: T.nilable(T.proc.params(x: EnumClassNamespace).void)
1082
1095
  ).returns(EnumClassNamespace)
1083
1096
  end
1084
- def create_enum_class(name, final: false, enums: nil, abstract: false, &block); end
1097
+ def create_enum_class(name, final: false, sealed: false, enums: nil, abstract: false, &block); end
1085
1098
 
1086
1099
  sig do
1087
1100
  params(
1088
1101
  name: String,
1089
1102
  final: T::Boolean,
1103
+ sealed: T::Boolean,
1090
1104
  props: T.nilable(T::Array[StructProp]),
1091
1105
  abstract: T::Boolean,
1092
1106
  block: T.nilable(T.proc.params(x: StructClassNamespace).void)
1093
1107
  ).returns(StructClassNamespace)
1094
1108
  end
1095
- def create_struct_class(name, final: false, props: nil, abstract: false, &block); end
1109
+ def create_struct_class(name, final: false, sealed: false, props: nil, abstract: false, &block); end
1096
1110
 
1097
1111
  sig do
1098
1112
  params(
1099
1113
  name: String,
1100
1114
  final: T::Boolean,
1115
+ sealed: T::Boolean,
1101
1116
  interface: T::Boolean,
1117
+ abstract: T::Boolean,
1102
1118
  block: T.nilable(T.proc.params(x: ClassNamespace).void)
1103
1119
  ).returns(ModuleNamespace)
1104
1120
  end
1105
- def create_module(name, final: false, interface: false, &block); end
1121
+ def create_module(name, final: false, sealed: false, interface: false, abstract: false, &block); end
1106
1122
 
1107
1123
  sig do
1108
1124
  params(
@@ -1212,12 +1228,12 @@ module Parlour
1212
1228
 
1213
1229
  class Parameter
1214
1230
  extend T::Sig
1215
- PREFIXES = {
1231
+ PREFIXES = T.let({
1216
1232
  normal: '',
1217
1233
  splat: '*',
1218
1234
  double_splat: '**',
1219
1235
  block: '&'
1220
- }.freeze
1236
+ }.freeze, T::Hash[Symbol, String])
1221
1237
 
1222
1238
  sig { params(name: String, type: T.nilable(Types::TypeLike), default: T.nilable(String)).void }
1223
1239
  def initialize(name, type: nil, default: nil); end
@@ -1283,12 +1299,13 @@ module Parlour
1283
1299
  generator: Generator,
1284
1300
  name: String,
1285
1301
  final: T::Boolean,
1302
+ sealed: T::Boolean,
1286
1303
  props: T::Array[StructProp],
1287
1304
  abstract: T::Boolean,
1288
1305
  block: T.nilable(T.proc.params(x: StructClassNamespace).void)
1289
1306
  ).void
1290
1307
  end
1291
- def initialize(generator, name, final, props, abstract, &block); end
1308
+ def initialize(generator, name, final, sealed, props, abstract, &block); end
1292
1309
 
1293
1310
  sig { returns(T::Array[StructProp]) }
1294
1311
  attr_reader :props
@@ -1308,9 +1325,9 @@ module Parlour
1308
1325
 
1309
1326
  class StructProp
1310
1327
  extend T::Sig
1311
- EXTRA_PROPERTIES = %i{
1328
+ EXTRA_PROPERTIES = T.let(%i{
1312
1329
  optional enum dont_store foreign default factory immutable array override redaction
1313
- }
1330
+ }, T::Array[Symbol])
1314
1331
 
1315
1332
  sig do
1316
1333
  params(
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.6
4
+ version: 5.0.0
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-10-04 00:00:00.000000000 Z
11
+ date: 2020-12-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sorbet-runtime
@@ -156,6 +156,7 @@ files:
156
156
  - LICENSE.txt
157
157
  - README.md
158
158
  - Rakefile
159
+ - ci/check_rbi.sh
159
160
  - exe/parlour
160
161
  - lib/parlour.rb
161
162
  - lib/parlour/conflict_resolver.rb
@@ -224,9 +225,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
224
225
  version: '0'
225
226
  required_rubygems_version: !ruby/object:Gem::Requirement
226
227
  requirements:
227
- - - ">"
228
+ - - ">="
228
229
  - !ruby/object:Gem::Version
229
- version: 1.3.1
230
+ version: '0'
230
231
  requirements: []
231
232
  rubygems_version: 3.0.3
232
233
  signing_key: