parlour 0.2.0 → 0.2.1

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
  SHA256:
3
- metadata.gz: 88487f0d150090c2b0877343e66efc37d0643892fd3b99966f0d4cca992d29e1
4
- data.tar.gz: eb2f33d58f3606186d9691845d50071d456107d9a913947f70b89cfa2c9a6492
3
+ metadata.gz: 2d1c171ba47259b6a4ed2a996851cefddaf27fc263dee7cf36e5402dd0825ed7
4
+ data.tar.gz: e65db27b829a76f965aa09b01c7725496efef8aa4e7000618c7df6e058a91c81
5
5
  SHA512:
6
- metadata.gz: 8ae0f4def7984b641df8b45000eddbafcf10048ccc772f4802d413e79b8e1431afc58963f2c1e40533b99729dad4801c3f328fc3a6f35cb654ad9c7b092a493c
7
- data.tar.gz: ad6f1e9bd34f9b56aaa4ae1eb8ac30cded890f2b5f64672d9bdc5f3ca82d18ec4ee2b55cea1c7abd65ba32cd03d874715d470f4cd72c2a733d2ba209a7b06755
6
+ metadata.gz: a59f7d8291d718af02b7bf8885deae8891149ad73f39ba5ff6b92cd19df9738c5e49b7202ab49509a7ac1a719381b88bf67a80df12756a8cf80af939b7e18166
7
+ data.tar.gz: 357c2364280f8656372294799e879384019ef706c0b7bccf67b0491c7ea24d018a7af557a0791627810c7956770979708ee6f7b91f67771e4e1a242738695a73
@@ -3,6 +3,22 @@ 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.2.1] - 2019-07-08
7
+ ### Added
8
+ - Added the `add_comment_to_next_child` method to namespaces.
9
+
10
+ ## [0.2.0] - 2019-07-07
11
+ ### Added
12
+ - Add support for plugins using the `parlour` command-line tool.
13
+ - Comments can now be added using `add_comment`.
14
+ - Attribute readers, writers and accessors can now be created, using the `create_attr_...` methods.
15
+ - All objects are now YARD documented.
16
+
17
+ ### Changed
18
+ - The `RbiObject`, which is core to Parlour's internals, is now an abstract class rather than an interface.
19
+ - `ConflictResolver` now recurses to child namespaces.
20
+ - `create_method` now takes an initializer block like other `create_` methods.
21
+
6
22
  ## [0.1.1] - 2019-07-05
7
23
  ### Added
8
24
  - Initial release!
@@ -43,6 +43,7 @@ module Parlour
43
43
  @extends = []
44
44
  @includes = []
45
45
  @constants = []
46
+ @next_comments = []
46
47
  yield_self(&block)
47
48
  end
48
49
 
@@ -69,6 +70,27 @@ module Parlour
69
70
  # @return [Array<(String, String)>]
70
71
  attr_reader :constants
71
72
 
73
+ sig { params(comment: T.any(String, T::Array[String])).void }
74
+ # Adds one or more comments to the next child RBI object to be created.
75
+ #
76
+ # @example Creating a module with a comment.
77
+ # namespace.add_comment_to_next_child('This is a module')
78
+ # namespace.create_module('M')
79
+ #
80
+ # @example Creating a class with a multi-line comment.
81
+ # namespace.add_comment_to_next_child(['This is a multi-line comment!', 'It can be as long as you want!'])
82
+ # namespace.create_class('C')
83
+ #
84
+ # @param comment [String, Array<String>] The new comment(s).
85
+ # @return [void]
86
+ def add_comment_to_next_child(comment)
87
+ if comment.is_a?(String)
88
+ @next_comments << comment
89
+ elsif comment.is_a?(Array)
90
+ @next_comments.concat(comment)
91
+ end
92
+ end
93
+
72
94
  sig do
73
95
  params(
74
96
  name: String,
@@ -95,6 +117,7 @@ module Parlour
95
117
  # @return [ClassNamespace]
96
118
  def create_class(name, superclass: nil, abstract: false, &block)
97
119
  new_class = ClassNamespace.new(generator, name, superclass, abstract, &block)
120
+ move_next_comments(new_class)
98
121
  children << new_class
99
122
  new_class
100
123
  end
@@ -123,6 +146,7 @@ module Parlour
123
146
  # @return [ModuleNamespace]
124
147
  def create_module(name, interface: false, &block)
125
148
  new_module = ModuleNamespace.new(generator, name, interface, &block)
149
+ move_next_comments(new_module)
126
150
  children << new_module
127
151
  new_module
128
152
  end
@@ -171,6 +195,7 @@ module Parlour
171
195
  class_method: class_method,
172
196
  &block
173
197
  )
198
+ move_next_comments(new_method)
174
199
  children << new_method
175
200
  new_method
176
201
  end
@@ -207,6 +232,7 @@ module Parlour
207
232
  type,
208
233
  &block
209
234
  )
235
+ move_next_comments(new_attribute)
210
236
  children << new_attribute
211
237
  new_attribute
212
238
  end
@@ -371,6 +397,16 @@ module Parlour
371
397
 
372
398
  result
373
399
  end
400
+
401
+ sig { params(object: RbiObject).void }
402
+ # Copies the comments added with {#add_comment_to_next_child} into the
403
+ # given object, and clears the list of pending comments.
404
+ # @param object [RbiObject] The object to move the comments into.
405
+ # @return [void]
406
+ def move_next_comments(object)
407
+ object.comments.prepend(*@next_comments)
408
+ @next_comments.clear
409
+ end
374
410
  end
375
411
  end
376
412
  end
@@ -48,7 +48,8 @@ module Parlour
48
48
  attr_reader :comments
49
49
 
50
50
  sig { params(comment: T.any(String, T::Array[String])).void }
51
- # Adds one or more comments to this RBI object.
51
+ # Adds one or more comments to this RBI object. Comments always go above
52
+ # the definition for this object, not in the definition's body.
52
53
  #
53
54
  # @example Creating a module with a comment.
54
55
  # namespace.create_module('M') do |m|
@@ -1,5 +1,5 @@
1
1
  # typed: strong
2
2
  module Parlour
3
3
  # The library version.
4
- VERSION = '0.2.0'
4
+ VERSION = '0.2.1'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parlour
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Christiansen