modularize 0.0.2 → 0.0.3

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: 6d679f6b678438e974373b4e0aa6d83b9c6343cc
4
- data.tar.gz: ede2458c47223c606fd562f6abe9bd99fff8b4fe
3
+ metadata.gz: ab39037fef7a952a9a17069a78717c4e10304b6c
4
+ data.tar.gz: a277ddb58509087123234baaf500b00d3415af29
5
5
  SHA512:
6
- metadata.gz: 4d32ad050572a4f0e94743fc9915a590db906362508d347236bd4a4ed496b0c772100a5dd617266a3dc5651abe1c315c17b6175c9e5b4d9d12ebbe79a4e4d7fb
7
- data.tar.gz: 625779216c832281e84103e81bb5947504129523439732ad5610532a234f52521d991d1ada2cc536c6758c785e1e67223381917424185d23225624a35b2a45fa
6
+ metadata.gz: 96db29bd5cde9c5d871e4cff4f64da8963ce1b8774423daa00a03d7ad009bf27ead2d0723e8aa833bef5481e1dac1100fbe898961dca54d450251dc69f2d2879
7
+ data.tar.gz: 176fbf344c07c3691e3f7051682df7393421144230c9b0b0125d77b9afef068e4c925765bcd31499a8ac78edb6dd3f7cc7156b75448b2c1f30e063927ce945c5
data/.rspec CHANGED
@@ -1,2 +1,2 @@
1
1
  --color
2
- --format progress
2
+ --format documentation
data/README.md CHANGED
@@ -1,6 +1,49 @@
1
1
  # Modularize
2
2
 
3
- TODO: Write a gem description
3
+ Dynamically create Ruby module hierarchies
4
+
5
+ ```ruby
6
+ Modulize.create('Animals::Cats::Bombay')
7
+ ```
8
+
9
+ is the equivelent to:
10
+
11
+ ```ruby
12
+ module Animals
13
+ module Cats
14
+ module Bombay
15
+ end
16
+ end
17
+ end
18
+ ```
19
+
20
+ ## But Why?
21
+
22
+ In [RestPack](https://github.com/restpack), I want to create some modules at load time so that I don't need to nest class definitions in module namespaces. I want to be able to do this:
23
+
24
+ ```ruby
25
+ module Commands::Groups::Invitation
26
+ class Create
27
+ ..
28
+ end
29
+ end
30
+ ```
31
+
32
+ instead of this:
33
+
34
+ ```ruby
35
+ module Commands
36
+ module Groups
37
+ module Invitation
38
+ class Create
39
+ ..
40
+ end
41
+ end
42
+ end
43
+ end
44
+ ```
45
+
46
+ Watch a video of the gem creation: http://www.youtube.com/watch?v=JR3tlXae73k
4
47
 
5
48
  ## Installation
6
49
 
@@ -16,10 +59,6 @@ Or install it yourself as:
16
59
 
17
60
  $ gem install modularize
18
61
 
19
- ## Usage
20
-
21
- TODO: Write usage instructions here
22
-
23
62
  ## Contributing
24
63
 
25
64
  1. Fork it
@@ -8,7 +8,7 @@ module Modularize
8
8
  private
9
9
 
10
10
  def self.create_module(name, root)
11
- new_module = root.const_defined?(name) ? root.const_get(name) : nil
11
+ new_module = root.const_defined?(name, false) ? root.const_get(name) : nil
12
12
 
13
13
  unless new_module
14
14
  new_module = Module.new
@@ -1,3 +1,3 @@
1
1
  module Modularize
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
@@ -35,4 +35,18 @@ describe Modularize do
35
35
  Modularize.create('Fruit')
36
36
  defined?(Fruit::Orange).should_not == nil
37
37
  end
38
+
39
+ context 'when a decendant module name already exists on the root' do
40
+ it 'creates a decendant module in the correct namespace' do
41
+ defined?(Computers::Keyboards).should == nil
42
+ Modularize.create('Keyboards')
43
+ Modularize.create('Computers::Keyboards')
44
+ defined?(Computers::Keyboards).should_not == nil
45
+ end
46
+
47
+ after do
48
+ Object.send(:remove_const, :Computers) if defined?(Computers)
49
+ Object.send(:remove_const, :Keyboards) if defined?(Keyboards)
50
+ end
51
+ end
38
52
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: modularize
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gavin Joyce
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-11-15 00:00:00.000000000 Z
11
+ date: 2013-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -91,7 +91,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
91
  version: '0'
92
92
  requirements: []
93
93
  rubyforge_project:
94
- rubygems_version: 2.0.7
94
+ rubygems_version: 2.0.5
95
95
  signing_key:
96
96
  specification_version: 4
97
97
  summary: Dynamically create module hierarchies...