parlour 0.5.0 → 0.5.1

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: 9cfa95875716d50b33a4d3557fd6b60d6d477bed3e933c6c369d148399193cff
4
- data.tar.gz: 2c9f22571d96d3d592353807c3b40e96e1e567968b761a1ba1174cfeb3a5ecca
3
+ metadata.gz: a2325cc0c8641efdbbf3499b4751f7e10dae39ee7823acb1a9588212711d9ceb
4
+ data.tar.gz: da88da407877745bb1f4265d0b90964881a2ef44bbd52566952dd18de467585c
5
5
  SHA512:
6
- metadata.gz: a40ddab81583e19e1552c1b4e35257a8f99cf8d862221eb4c5b8641097d299a07b0290ab8d6ecedacfc94b0881cd95ab709bf9596446d1e41fceaebd823bc720
7
- data.tar.gz: 4de8a3ac91b6c17ebc99d5659f2af8f4cf52083963f60a5851809b05e7237797af6ea81126d35e716b9c46ebe90ace4c0d561d0d582f8ae16a973a159957218a
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
  #
@@ -1,5 +1,5 @@
1
1
  # typed: strong
2
2
  module Parlour
3
3
  # The library version.
4
- VERSION = '0.5.0'
4
+ VERSION = '0.5.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.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Christiansen