parlour 0.5.1 → 0.5.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 +4 -4
- data/CHANGELOG.md +15 -0
- data/README.md +1 -0
- data/lib/parlour/plugin.rb +11 -6
- data/lib/parlour/rbi_generator/method.rb +1 -1
- data/lib/parlour/rbi_generator/namespace.rb +50 -29
- data/lib/parlour/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd7b82a40507591cd3793427e52978d215cc70c12b94b1c80fa40909fe73f194
|
4
|
+
data.tar.gz: e2408f44d246e5090ab375a9ab5bba9bc733496f8d8b647576f6733d9aeeb48d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbb37ea0acb6091856f17d7a03cabf1c5b642e2571e47729e4232cda58da81da7dcc9477fe4f6d849f72afda6cc20f7c07310f44290079e1eded985719574a94
|
7
|
+
data.tar.gz: 5803b1fb765174873b3e8f45667b81da60d438d9209ee23d8fb860d391c02b1a6e1fabed9eb6cab14ec5f1d90bf6a37a78ba8edac887a0419ef1efd44f778afa
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,21 @@ 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
|
+
## [0.5.2] - 2019-07-24
|
7
|
+
### Added
|
8
|
+
- Added the `Namespace#create_includes` and `Namespace#create_extends` methods
|
9
|
+
to add multiple `include` and `extend` calls at once.
|
10
|
+
|
11
|
+
### Changed
|
12
|
+
- Signatures for some methods using keyword parameters have been altered such
|
13
|
+
that those keywords are required. Previously, these parameters defaulted to
|
14
|
+
`nil`, and the Sorbet runtime would fail an assertion if they weren't present.
|
15
|
+
|
16
|
+
### Fixed
|
17
|
+
- Fixed some incorrect documentation for the `Namespace` methods `path` and
|
18
|
+
`create_constant`.
|
19
|
+
- Fixed a Sorbet signature for `Method#describe` which was causing an exception.
|
20
|
+
|
6
21
|
## [0.5.1] - 2019-07-21
|
7
22
|
### Added
|
8
23
|
- Added the `Namespace#path` method for plugins to use.
|
data/README.md
CHANGED
@@ -151,6 +151,7 @@ plugins:
|
|
151
151
|
_Have you written an awesome Parlour plugin? Please submit a PR to add it to this list!_
|
152
152
|
|
153
153
|
- [Sord](https://github.com/AaronC81/sord) - Generate RBIs from YARD documentation
|
154
|
+
- [parlour-datamapper](https://github.com/AaronC81/parlour-datamapper) - Simple plugin for generating DataMapper model types
|
154
155
|
|
155
156
|
|
156
157
|
## Contributing
|
data/lib/parlour/plugin.rb
CHANGED
@@ -33,14 +33,19 @@ module Parlour
|
|
33
33
|
#
|
34
34
|
# @param plugins [Array<Plugin>] An array of {Plugin} instances.
|
35
35
|
# @param generator [RbiGenerator] The {RbiGenerator} to run the plugins on.
|
36
|
+
# @param allow_failure [Boolean] Whether to keep running plugins if a plugin
|
37
|
+
# throws an exception. If false, the exception is re-raised when caught.
|
36
38
|
# @return [void]
|
37
|
-
def self.run_plugins(plugins, generator)
|
39
|
+
def self.run_plugins(plugins, generator, allow_failure: true)
|
38
40
|
plugins.each do |plugin|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
begin
|
42
|
+
puts "=== #{plugin.class.name}"
|
43
|
+
generator.current_plugin = plugin
|
44
|
+
plugin.generate(generator.root)
|
45
|
+
rescue Exception => e
|
46
|
+
raise e unless allow_failure
|
47
|
+
puts "!!! This plugin threw an exception: #{e}"
|
48
|
+
end
|
44
49
|
end
|
45
50
|
end
|
46
51
|
|
@@ -185,7 +185,7 @@ module Parlour
|
|
185
185
|
# We don't need to change anything! We only merge identical methods
|
186
186
|
end
|
187
187
|
|
188
|
-
sig {
|
188
|
+
sig { implementation.returns(String) }
|
189
189
|
# Returns a human-readable brief string description of this method.
|
190
190
|
#
|
191
191
|
# @return [String]
|
@@ -79,12 +79,12 @@ module Parlour
|
|
79
79
|
)
|
80
80
|
end
|
81
81
|
|
82
|
+
sig { params(object: T.untyped, block: T.proc.params(x: Namespace).void).void }
|
82
83
|
# Given a Class or Module object, generates all classes and modules in the
|
83
84
|
# path to that object, then executes the given block on the last
|
84
85
|
# {Namespace}. This should only be executed on the root namespace.
|
85
86
|
# @param [Class, Module] object
|
86
87
|
# @param block A block which the new {Namespace} yields itself to.
|
87
|
-
sig { params(object: T.untyped, block: T.proc.params(x: Namespace).void).void }
|
88
88
|
def path(object, &block)
|
89
89
|
raise 'only call #path on root' if is_a?(ClassNamespace) || is_a?(ModuleNamespace)
|
90
90
|
|
@@ -130,7 +130,7 @@ module Parlour
|
|
130
130
|
|
131
131
|
sig do
|
132
132
|
params(
|
133
|
-
name:
|
133
|
+
name: String,
|
134
134
|
superclass: T.nilable(String),
|
135
135
|
abstract: T::Boolean,
|
136
136
|
block: T.nilable(T.proc.params(x: ClassNamespace).void)
|
@@ -152,8 +152,7 @@ module Parlour
|
|
152
152
|
# @param abstract [Boolean] A boolean indicating whether this class is abstract.
|
153
153
|
# @param block A block which the new instance yields itself to.
|
154
154
|
# @return [ClassNamespace]
|
155
|
-
def create_class(name
|
156
|
-
name = T.must(name)
|
155
|
+
def create_class(name:, superclass: nil, abstract: false, &block)
|
157
156
|
new_class = ClassNamespace.new(generator, name, superclass, abstract, &block)
|
158
157
|
move_next_comments(new_class)
|
159
158
|
children << new_class
|
@@ -162,7 +161,7 @@ module Parlour
|
|
162
161
|
|
163
162
|
sig do
|
164
163
|
params(
|
165
|
-
name:
|
164
|
+
name: String,
|
166
165
|
interface: T::Boolean,
|
167
166
|
block: T.nilable(T.proc.params(x: ClassNamespace).void)
|
168
167
|
).returns(ModuleNamespace)
|
@@ -182,8 +181,7 @@ module Parlour
|
|
182
181
|
# interface.
|
183
182
|
# @param block A block which the new instance yields itself to.
|
184
183
|
# @return [ModuleNamespace]
|
185
|
-
def create_module(name
|
186
|
-
name = T.must(name)
|
184
|
+
def create_module(name:, interface: false, &block)
|
187
185
|
new_module = ModuleNamespace.new(generator, name, interface, &block)
|
188
186
|
move_next_comments(new_module)
|
189
187
|
children << new_module
|
@@ -192,7 +190,7 @@ module Parlour
|
|
192
190
|
|
193
191
|
sig do
|
194
192
|
params(
|
195
|
-
name:
|
193
|
+
name: String,
|
196
194
|
parameters: T.nilable(T::Array[Parameter]),
|
197
195
|
return_type: T.nilable(String),
|
198
196
|
returns: T.nilable(String),
|
@@ -223,8 +221,7 @@ module Parlour
|
|
223
221
|
# it is defined using +self.+.
|
224
222
|
# @param block A block which the new instance yields itself to.
|
225
223
|
# @return [Method]
|
226
|
-
def create_method(name
|
227
|
-
name = T.must(name)
|
224
|
+
def create_method(name:, parameters: nil, return_type: nil, returns: nil, abstract: false, implementation: false, override: false, overridable: false, class_method: false, &block)
|
228
225
|
parameters = parameters || []
|
229
226
|
raise 'cannot specify both return_type: and returns:' if return_type && returns
|
230
227
|
return_type ||= returns
|
@@ -269,10 +266,7 @@ module Parlour
|
|
269
266
|
# +"String"+ or +"T.untyped"+.
|
270
267
|
# @param block A block which the new instance yields itself to.
|
271
268
|
# @return [RbiGenerator::Attribute]
|
272
|
-
def create_attribute(name
|
273
|
-
name = T.must(name)
|
274
|
-
kind = T.must(kind)
|
275
|
-
type = T.must(type)
|
269
|
+
def create_attribute(name:, kind:, type:, &block)
|
276
270
|
new_attribute = RbiGenerator::Attribute.new(
|
277
271
|
generator,
|
278
272
|
name,
|
@@ -293,7 +287,7 @@ module Parlour
|
|
293
287
|
# +"String"+ or +"T.untyped"+.
|
294
288
|
# @param block A block which the new instance yields itself to.
|
295
289
|
# @return [RbiGenerator::Attribute]
|
296
|
-
def create_attr_reader(name
|
290
|
+
def create_attr_reader(name:, type:, &block)
|
297
291
|
create_attribute(name: name, kind: :reader, type: type, &block)
|
298
292
|
end
|
299
293
|
|
@@ -304,7 +298,7 @@ module Parlour
|
|
304
298
|
# +"String"+ or +"T.untyped"+.
|
305
299
|
# @param block A block which the new instance yields itself to.
|
306
300
|
# @return [RbiGenerator::Attribute]
|
307
|
-
def create_attr_writer(name
|
301
|
+
def create_attr_writer(name:, type:, &block)
|
308
302
|
create_attribute(name: name, kind: :writer, type: type, &block)
|
309
303
|
end
|
310
304
|
|
@@ -315,7 +309,7 @@ module Parlour
|
|
315
309
|
# +"String"+ or +"T.untyped"+.
|
316
310
|
# @param block A block which the new instance yields itself to.
|
317
311
|
# @return [RbiGenerator::Attribute]
|
318
|
-
def create_attr_accessor(name
|
312
|
+
def create_attr_accessor(name:, type:, &block)
|
319
313
|
create_attribute(name: name, kind: :accessor, type: type, &block)
|
320
314
|
end
|
321
315
|
|
@@ -325,8 +319,7 @@ module Parlour
|
|
325
319
|
# @param code [String] The code to insert.
|
326
320
|
# @param block A block which the new instance yields itself to.
|
327
321
|
# @return [RbiGenerator::Arbitrary]
|
328
|
-
def create_arbitrary(code
|
329
|
-
code = T.must(code)
|
322
|
+
def create_arbitrary(code:, &block)
|
330
323
|
new_arbitrary = RbiGenerator::Arbitrary.new(
|
331
324
|
generator,
|
332
325
|
code: code,
|
@@ -347,8 +340,7 @@ module Parlour
|
|
347
340
|
# +"MyModule"+.
|
348
341
|
# @param block A block which the new instance yields itself to.
|
349
342
|
# @return [RbiGenerator::Extend]
|
350
|
-
def create_extend(name
|
351
|
-
name = T.must(name)
|
343
|
+
def create_extend(name:, &block)
|
352
344
|
new_extend = RbiGenerator::Extend.new(
|
353
345
|
generator,
|
354
346
|
name: name,
|
@@ -359,18 +351,33 @@ module Parlour
|
|
359
351
|
new_extend
|
360
352
|
end
|
361
353
|
|
354
|
+
sig { params(extendables: T::Array[String]).returns(T::Array[Extend]) }
|
355
|
+
# Adds new +extend+s to this namespace.
|
356
|
+
#
|
357
|
+
# @example Add +extend+s to a class.
|
358
|
+
# class.create_extends(['Foo', 'Bar'])
|
359
|
+
#
|
360
|
+
# @param [Array<String>] extendables An array of names for whatever is being extended.
|
361
|
+
# @return [Array<RbiGenerator::Extend>]
|
362
|
+
def create_extends(extendables)
|
363
|
+
returned_extendables = []
|
364
|
+
extendables.each do |extendable|
|
365
|
+
returned_extendables << create_extend(name: extendable)
|
366
|
+
end
|
367
|
+
returned_extendables
|
368
|
+
end
|
369
|
+
|
362
370
|
sig { params(name: String, block: T.nilable(T.proc.params(x: Include).void)).returns(Include) }
|
363
371
|
# Adds a new +include+ to this namespace.
|
364
372
|
#
|
365
373
|
# @example Add an +include+ to a class.
|
366
|
-
# class.create_include(name:
|
374
|
+
# class.create_include(name: 'IncludableClass') #=> include IncludableClass
|
367
375
|
#
|
368
|
-
# @param
|
376
|
+
# @param [String] name A code string for what is included, for example
|
369
377
|
# +"Enumerable"+.
|
370
378
|
# @param block A block which the new instance yields itself to.
|
371
379
|
# @return [RbiGenerator::Include]
|
372
|
-
def create_include(name
|
373
|
-
name = T.must(name)
|
380
|
+
def create_include(name:, &block)
|
374
381
|
new_include = RbiGenerator::Include.new(
|
375
382
|
generator,
|
376
383
|
name: name,
|
@@ -381,19 +388,33 @@ module Parlour
|
|
381
388
|
new_include
|
382
389
|
end
|
383
390
|
|
391
|
+
sig { params(includables: T::Array[String]).returns(T::Array[Include]) }
|
392
|
+
# Adds new +include+s to this namespace.
|
393
|
+
#
|
394
|
+
# @example Add +include+s to a class.
|
395
|
+
# class.create_includes(['Foo', 'Bar'])
|
396
|
+
#
|
397
|
+
# @param [Array<String>] includables An array of names for whatever is being included.
|
398
|
+
# @return [Array<RbiGenerator::Include>]
|
399
|
+
def create_includes(includables)
|
400
|
+
returned_includables = []
|
401
|
+
includables.each do |includable|
|
402
|
+
returned_includables << create_include(name: includable)
|
403
|
+
end
|
404
|
+
returned_includables
|
405
|
+
end
|
406
|
+
|
384
407
|
sig { params(name: String, value: String, block: T.nilable(T.proc.params(x: Constant).void)).returns(Constant) }
|
385
408
|
# Adds a new constant definition to this namespace.
|
386
409
|
#
|
387
410
|
# @example Add an +Elem+ constant to the class.
|
388
|
-
# class.
|
411
|
+
# class.create_constant(name: 'Elem', value: 'String') #=> Elem = String
|
389
412
|
#
|
390
413
|
# @param name [String] The name of the constant.
|
391
414
|
# @param value [String] The value of the constant, as a Ruby code string.
|
392
415
|
# @param block A block which the new instance yields itself to.
|
393
416
|
# @return [RbiGenerator::Constant]
|
394
|
-
def create_constant(name
|
395
|
-
name = T.must(name)
|
396
|
-
value = T.must(value)
|
417
|
+
def create_constant(name:, value:, &block)
|
397
418
|
new_constant = RbiGenerator::Constant.new(
|
398
419
|
generator,
|
399
420
|
name: name,
|
data/lib/parlour/version.rb
CHANGED
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: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Christiansen
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-07-
|
11
|
+
date: 2019-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sorbet-runtime
|