expand 1.0.1 → 1.0.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 67a04674a13b0dbfca22f2452f5f206af05452bb
4
- data.tar.gz: 7ea40c2d4bae7463a3ad99420107e96a5fc4d2e7
3
+ metadata.gz: fa05996ba3e525e97297fadc5e958ede85494fb8
4
+ data.tar.gz: 6f4425acb6142ef5e273c39bcc00b6140812dccf
5
5
  SHA512:
6
- metadata.gz: 8df7158a2bdaf8375cc5d8b7f782ae367fc081efcdd17e21352d252d20f3d1dfe33b3718046f693b58567fa58949514905373e70e850cfd3bcb8767478512c92
7
- data.tar.gz: 8c8f197f5ce23a87e9db11382be77e3f97b0ce50f07f7013c4390d72d335f6020727993f9bbf107f6e7f86dfc632b51a1dcd4bc4ec83a75bba58123251310d89
6
+ metadata.gz: 557437e0b3f3677503e81e591eccbbb41c46603a26674d95e02c394f8cb87e590bd5fec8cb33eaf162a7c5c963f3a178760592f9d9b22822cf4fcb3085a57ff4
7
+ data.tar.gz: dcc31bf73a0a410bd6b81958d8acc4a602a687331f90d5080fd53ca59079da07ea66f091678b8119483cad8af3516086dabdb4f7d4be50ecb0ab382dd94ad97c
data/README.md CHANGED
@@ -22,7 +22,7 @@ SomeGem::Thing::NewThing #=> warning: toplevel constant NewThing referenced by S
22
22
  To make this simpler, you can require `expand` and extend your current context with Expand.
23
23
 
24
24
  ```ruby
25
- reuire 'expand'
25
+ require 'expand'
26
26
  extend Expand
27
27
 
28
28
  namespace SomeGem::Thing do
@@ -1,17 +1,48 @@
1
1
  require "expand/version"
2
2
 
3
+ # Extend your classes or modules to use the Expand methods
3
4
  module Expand
5
+
6
+ # The primary way to access Manager objects is to use the Expand namespace method.
7
+ # @see Expand#namespace
8
+ #
4
9
  class Manager
10
+ # @see Expand#namespace
5
11
  def initialize(namespace)
6
12
  @managed = namespace
7
13
  end
8
14
 
15
+ # Create a module under the namespace for this object
16
+ # @example
17
+ # create_module 'Another' do
18
+ # def do_something
19
+ # end
20
+ # end
21
+ #
22
+ # @param name [String, Symbol] name to be used for the module
23
+ # @yield provide a block to be used when creating the module
24
+ #
25
+ # @return [Module] the named module you created
26
+ #
9
27
  def create_module(name, &block)
10
28
  mod = Module.new(&block)
11
29
  @managed.const_set(name, mod)
12
30
  mod
13
31
  end
14
32
 
33
+ # Create a class under the namespace for this object
34
+ # @example
35
+ # create_class 'Other' do
36
+ # def do_something
37
+ # end
38
+ # end
39
+ #
40
+ # @param name [String, Symbol] name to be used for the class
41
+ # @param parent [Class] an optional class to be used as the direct ancestor of the class
42
+ # @yield provide a block to be used when creating the class
43
+ #
44
+ # @return [Class] the named class you created
45
+ #
15
46
  def create_class(name, parent: Object, &block)
16
47
  klass = Class.new(parent, &block)
17
48
  @managed.const_set(name, klass)
@@ -19,6 +50,27 @@ module Expand
19
50
  end
20
51
  end
21
52
 
53
+ # Allows you to open a module namespace to add constants
54
+ # @example
55
+ # require 'expand'
56
+ # extend Expand
57
+ # namespace SomeGem::Thing do
58
+ # create_class 'Other' do
59
+ # # add your class code here
60
+ # end
61
+ # create_module 'Another' do
62
+ # # add your module code here
63
+ # end
64
+ # end
65
+ #
66
+ # @param context [Module, String, or any object responding to to_s] representing a module namespace.
67
+ # @yield the provided block is executed against an instance of Expand::Manager using instance_eval
68
+ #
69
+ # @return [Expand::Manager] instance which can allow you to create classes and modules in the given context.
70
+ #
71
+ # @see Expand::Manager#create_class
72
+ # @see Expand::Manager#create_module
73
+ #
22
74
  def namespace(context, &block)
23
75
  unless context.is_a?(Module)
24
76
  context = context.to_s.split('::').inject(Object) do |base, mod|
@@ -1,3 +1,3 @@
1
1
  module Expand
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: expand
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - "'Jim Gay'"
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-01-14 00:00:00.000000000 Z
11
+ date: 2016-03-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -97,3 +97,4 @@ signing_key:
97
97
  specification_version: 4
98
98
  summary: Create classes and modules under an existing namespace
99
99
  test_files: []
100
+ has_rdoc: