parlour 0.5.0 → 0.5.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 +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/parlour/rbi_generator/namespace.rb +28 -0
- data/lib/parlour/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2325cc0c8641efdbbf3499b4751f7e10dae39ee7823acb1a9588212711d9ceb
|
4
|
+
data.tar.gz: da88da407877745bb1f4265d0b90964881a2ef44bbd52566952dd18de467585c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 12438efd38d62b16d90f93186014b666950ff178bf00c5522575b00f9222baad9ebc8b7c507df2618833b9a04c5b3fcf8542670600e29ddfb254addb167ad282
|
7
|
+
data.tar.gz: fae177ea2bede03f5e27264bfaa9b5064ac6685860b5a708a5370aa749278d34bebe06c12cd37580b6c26a1e1ff4f95c69d71ae2f56767cc30fd5901679ae453
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,10 @@ 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.1] - 2019-07-21
|
7
|
+
### Added
|
8
|
+
- Added the `Namespace#path` method for plugins to use.
|
9
|
+
|
6
10
|
## [0.5.0] - 2019-07-20
|
7
11
|
### Added
|
8
12
|
- Added the `create_arbitrary` method for inserting arbitrary code into the
|
@@ -79,6 +79,34 @@ module Parlour
|
|
79
79
|
)
|
80
80
|
end
|
81
81
|
|
82
|
+
# Given a Class or Module object, generates all classes and modules in the
|
83
|
+
# path to that object, then executes the given block on the last
|
84
|
+
# {Namespace}. This should only be executed on the root namespace.
|
85
|
+
# @param [Class, Module] object
|
86
|
+
# @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
|
+
def path(object, &block)
|
89
|
+
raise 'only call #path on root' if is_a?(ClassNamespace) || is_a?(ModuleNamespace)
|
90
|
+
|
91
|
+
parts = object.to_s.split('::')
|
92
|
+
parts_with_types = parts.size.times.map do |i|
|
93
|
+
[parts[i], Module.const_get(parts[0..i].join('::')).class]
|
94
|
+
end
|
95
|
+
|
96
|
+
current_part = self
|
97
|
+
parts_with_types.each do |(name, type)|
|
98
|
+
if type == Class
|
99
|
+
current_part = current_part.create_class(name: name)
|
100
|
+
elsif type == Module
|
101
|
+
current_part = current_part.create_module(name: name)
|
102
|
+
else
|
103
|
+
raise "unexpected type: path part #{name} is a #{type}"
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
block.call(current_part)
|
108
|
+
end
|
109
|
+
|
82
110
|
sig { params(comment: T.any(String, T::Array[String])).void }
|
83
111
|
# Adds one or more comments to the next child RBI object to be created.
|
84
112
|
#
|
data/lib/parlour/version.rb
CHANGED