sugar-high 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/sugar-high/module.rb +3 -3
- data/spec/sugar-high/module_spec.rb +10 -0
- data/sugar-high.gemspec +1 -1
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/lib/sugar-high/module.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'active_support/inflector'
|
2
2
|
|
3
3
|
def modules *module_names, &block
|
4
|
-
module_names.each do |name|
|
4
|
+
module_names.flatten.each do |name|
|
5
5
|
class_eval %{
|
6
6
|
module #{name.to_s.camelize}
|
7
7
|
#{yield block if block}
|
@@ -11,11 +11,11 @@ def modules *module_names, &block
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def nested_modules *module_names, &block
|
14
|
-
module_names.inject([]) do |res, name|
|
14
|
+
module_names.flatten.inject([]) do |res, name|
|
15
15
|
res << %{
|
16
16
|
module #{name.to_s.camelize}
|
17
17
|
#{yield block if block}
|
18
18
|
end}
|
19
|
-
end.join("\n")
|
19
|
+
end.flatten.join("\n")
|
20
20
|
end
|
21
21
|
|
@@ -11,6 +11,11 @@ module Nested
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
module AuthAssistant
|
15
|
+
NAMESPACES = [:view, :controller, :model, :link, :helper]
|
16
|
+
|
17
|
+
modules NAMESPACES
|
18
|
+
end
|
14
19
|
|
15
20
|
describe "SugarHigh" do
|
16
21
|
describe "Module ext" do
|
@@ -20,6 +25,11 @@ describe "SugarHigh" do
|
|
20
25
|
Simple::Y.should_not be_nil
|
21
26
|
end
|
22
27
|
|
28
|
+
it "should create namespaces under AuthAssistant for various modules" do
|
29
|
+
AuthAssistant::View.should_not be_nil
|
30
|
+
AuthAssistant::Helper.should_not be_nil
|
31
|
+
end
|
32
|
+
|
23
33
|
it "should create namespaces under Nested for modules X and Y, and modules A and B under each of those X and Y modules" do
|
24
34
|
Nested::X.should_not be_nil
|
25
35
|
Nested::Y.should_not be_nil
|
data/sugar-high.gemspec
CHANGED