merb-slices 0.9.7 → 0.9.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (68) hide show
  1. data/README +4 -4
  2. data/Rakefile +27 -13
  3. data/TODO +1 -2
  4. data/bin/slice +77 -0
  5. data/lib/generators/templates/common/Rakefile +16 -12
  6. data/lib/generators/templates/full/README +4 -4
  7. data/lib/generators/templates/full/Rakefile +32 -13
  8. data/lib/generators/templates/full/config/init.rb +43 -0
  9. data/lib/generators/templates/full/lib/%base_name%.rb +3 -1
  10. data/lib/generators/templates/full/spec/%base_name%_spec.rb +10 -121
  11. data/lib/generators/templates/full/spec/controllers/main_spec.rb +18 -8
  12. data/lib/generators/templates/thin/README +4 -4
  13. data/lib/generators/templates/very_thin/README +4 -4
  14. data/lib/merb-slices.rb +3 -3
  15. data/lib/merb-slices/controller_mixin.rb +34 -7
  16. data/lib/merb-slices/merbtasks.rb +5 -34
  17. data/lib/merb-slices/module.rb +9 -3
  18. data/lib/merb-slices/module_mixin.rb +19 -31
  19. data/lib/merb-slices/router_ext.rb +10 -7
  20. data/spec/full_slice_generator_spec.rb +31 -2
  21. data/spec/full_slice_spec.rb +162 -0
  22. data/spec/merb-slice_spec.rb +97 -3
  23. data/spec/slice_generator_spec.rb +15 -3
  24. data/spec/slices/full-test-slice/LICENSE +20 -0
  25. data/spec/slices/full-test-slice/README +170 -0
  26. data/spec/slices/full-test-slice/Rakefile +67 -0
  27. data/spec/slices/full-test-slice/TODO +15 -0
  28. data/spec/slices/full-test-slice/app/controllers/application.rb +5 -0
  29. data/spec/slices/full-test-slice/app/controllers/main.rb +7 -0
  30. data/spec/slices/full-test-slice/app/helpers/application_helper.rb +64 -0
  31. data/spec/slices/full-test-slice/app/views/layout/full_test_slice.html.erb +16 -0
  32. data/spec/slices/full-test-slice/app/views/main/index.html.erb +1 -0
  33. data/spec/slices/full-test-slice/config/init.rb +43 -0
  34. data/spec/slices/full-test-slice/lib/full-test-slice.rb +80 -0
  35. data/spec/slices/full-test-slice/lib/full-test-slice/merbtasks.rb +103 -0
  36. data/spec/slices/full-test-slice/lib/full-test-slice/slicetasks.rb +18 -0
  37. data/spec/slices/full-test-slice/lib/full-test-slice/spectasks.rb +65 -0
  38. data/spec/slices/full-test-slice/public/javascripts/master.js +0 -0
  39. data/spec/slices/full-test-slice/public/stylesheets/master.css +2 -0
  40. data/spec/slices/full-test-slice/stubs/app/controllers/application.rb +2 -0
  41. data/spec/slices/full-test-slice/stubs/app/controllers/main.rb +2 -0
  42. data/spec/slices/thin-test-slice/LICENSE +20 -0
  43. data/spec/slices/thin-test-slice/README +130 -0
  44. data/spec/slices/thin-test-slice/Rakefile +43 -0
  45. data/spec/slices/thin-test-slice/TODO +7 -0
  46. data/spec/slices/thin-test-slice/application.rb +36 -0
  47. data/spec/slices/thin-test-slice/lib/thin-test-slice.rb +93 -0
  48. data/spec/slices/thin-test-slice/lib/thin-test-slice/merbtasks.rb +103 -0
  49. data/spec/slices/thin-test-slice/lib/thin-test-slice/slicetasks.rb +18 -0
  50. data/spec/slices/thin-test-slice/public/javascripts/master.js +0 -0
  51. data/spec/slices/thin-test-slice/public/stylesheets/master.css +2 -0
  52. data/spec/slices/thin-test-slice/stubs/application.rb +9 -0
  53. data/spec/slices/thin-test-slice/views/layout/thin_test_slice.html.erb +16 -0
  54. data/spec/slices/thin-test-slice/views/main/index.html.erb +1 -0
  55. data/spec/slices/very-thin-test-slice/LICENSE +20 -0
  56. data/spec/slices/very-thin-test-slice/README +110 -0
  57. data/spec/slices/very-thin-test-slice/Rakefile +43 -0
  58. data/spec/slices/very-thin-test-slice/TODO +7 -0
  59. data/spec/slices/very-thin-test-slice/application.rb +36 -0
  60. data/spec/slices/very-thin-test-slice/lib/very-thin-test-slice.rb +89 -0
  61. data/spec/slices/very-thin-test-slice/lib/very-thin-test-slice/merbtasks.rb +103 -0
  62. data/spec/slices/very-thin-test-slice/lib/very-thin-test-slice/slicetasks.rb +18 -0
  63. data/spec/spec_helper.rb +27 -2
  64. data/spec/thin_slice_generator_spec.rb +24 -2
  65. data/spec/thin_slice_spec.rb +139 -0
  66. data/spec/very_thin_slice_generator_spec.rb +22 -2
  67. data/spec/very_thin_slice_spec.rb +119 -0
  68. metadata +79 -5
@@ -1,14 +1,34 @@
1
1
  require File.dirname(__FILE__) + '/spec_helper'
2
2
 
3
+ slices_path = File.dirname(__FILE__) / 'slices'
4
+
3
5
  describe Merb::Generators::VeryThinSliceGenerator do
4
6
 
5
7
  describe "templates" do
6
8
 
9
+ before(:all) { FileUtils.rm_rf(slices_path / 'testing-very-thin') rescue nil }
10
+ after(:all) { FileUtils.rm_rf(slices_path / 'testing-very-thin') rescue nil }
11
+
7
12
  before do
8
- @generator = Merb::Generators::VeryThinSliceGenerator.new('/tmp', {}, 'testing')
13
+ @generator = Merb::Generators::VeryThinSliceGenerator.new(slices_path, {}, 'testing-very-thin')
9
14
  end
10
15
 
11
- it "should create a number of templates"
16
+ it "should create a number of templates" do
17
+ @generator.invoke!
18
+ files = Dir[slices_path / 'testing-very-thin' / '**' / '*'].map do |path|
19
+ path.relative_path_from(slices_path)
20
+ end
21
+ expected = [
22
+ "testing-very-thin/application.rb", "testing-very-thin/lib",
23
+ "testing-very-thin/lib/testing-very-thin",
24
+ "testing-very-thin/lib/testing-very-thin/merbtasks.rb",
25
+ "testing-very-thin/lib/testing-very-thin/slicetasks.rb",
26
+ "testing-very-thin/lib/testing-very-thin.rb",
27
+ "testing-very-thin/LICENSE", "testing-very-thin/Rakefile",
28
+ "testing-very-thin/README", "testing-very-thin/TODO"
29
+ ]
30
+ files.should == expected
31
+ end
12
32
 
13
33
  it "should render templates successfully" do
14
34
  lambda { @generator.render! }.should_not raise_error
@@ -0,0 +1,119 @@
1
+ require File.dirname(__FILE__) + '/spec_helper'
2
+
3
+ slices_path = File.dirname(__FILE__) / 'slices'
4
+
5
+ describe "A very thin slice" do
6
+
7
+ before(:all) do
8
+ self.current_slice_root = slices_path / 'very-thin-test-slice'
9
+
10
+ # Uncomment this re-generate the slice
11
+
12
+ # FileUtils.rm_rf(slices_path / 'very-thin-test-slice') rescue nil
13
+ # generator = Merb::Generators::VeryThinSliceGenerator.new(slices_path, {}, 'very-thin-test-slice')
14
+ # generator.invoke!
15
+
16
+ # Add the slice to the search path
17
+ Merb::Plugins.config[:merb_slices][:auto_register] = true
18
+ Merb::Plugins.config[:merb_slices][:search_path] = slices_path
19
+
20
+ Merb.start(
21
+ :testing => true,
22
+ :adapter => 'runner',
23
+ :environment => ENV['MERB_ENV'] || 'test',
24
+ :merb_root => Merb.root
25
+ )
26
+ end
27
+
28
+ # Uncomment this re-generate the slice
29
+
30
+ # after(:all) do
31
+ # FileUtils.rm_rf(slices_path / 'very-thin-test-slice') rescue nil
32
+ # end
33
+
34
+ before :all do
35
+ Merb::Router.prepare { add_slice(:VeryThinTestSlice) }
36
+ end
37
+
38
+ after :all do
39
+ Merb::Router.reset!
40
+ end
41
+
42
+ it "should be registered in Merb::Slices.slices" do
43
+ Merb::Slices.slices.should include(VeryThinTestSlice)
44
+ end
45
+
46
+ it "should be registered in Merb::Slices.paths" do
47
+ Merb::Slices.paths[VeryThinTestSlice.name].should == current_slice_root
48
+ end
49
+
50
+ it "should have an :identifier property" do
51
+ VeryThinTestSlice.identifier.should == "very-thin-test-slice"
52
+ end
53
+
54
+ it "should have an :identifier_sym property" do
55
+ VeryThinTestSlice.identifier_sym.should == :very_thin_test_slice
56
+ end
57
+
58
+ it "should have a :root property" do
59
+ VeryThinTestSlice.root.should == Merb::Slices.paths[VeryThinTestSlice.name]
60
+ VeryThinTestSlice.root_path('app').should == current_slice_root / 'app'
61
+ end
62
+
63
+ it "should have a :file property" do
64
+ VeryThinTestSlice.file.should == current_slice_root / 'lib' / 'very-thin-test-slice.rb'
65
+ end
66
+
67
+ it "should have metadata properties" do
68
+ VeryThinTestSlice.description.should == "VeryThinTestSlice is a very thin Merb slice!"
69
+ VeryThinTestSlice.version.should == "0.0.1"
70
+ VeryThinTestSlice.author.should == "YOUR NAME"
71
+ end
72
+
73
+ it "should have a :named_routes property" do
74
+ VeryThinTestSlice.named_routes[:default].should be_kind_of(Merb::Router::Route)
75
+ end
76
+
77
+ it "should have a dir_for method" do
78
+ app_path = VeryThinTestSlice.dir_for(:application)
79
+ app_path.should == current_slice_root
80
+ end
81
+
82
+ it "should have a app_dir_for method" do
83
+ root_path = VeryThinTestSlice.app_dir_for(:root)
84
+ root_path.should == Merb.root / 'slices' / 'very-thin-test-slice'
85
+ app_path = VeryThinTestSlice.app_dir_for(:application)
86
+ app_path.should == root_path
87
+ end
88
+
89
+ it "should have a public_dir_for method" do
90
+ public_path = VeryThinTestSlice.public_dir_for(:public)
91
+ public_path.should == '/slices' / 'very-thin-test-slice'
92
+ [:stylesheet, :javascript, :image].each do |type|
93
+ VeryThinTestSlice.public_dir_for(type).should == public_path / "#{type}s"
94
+ end
95
+ end
96
+
97
+ it "should have a public_path_for method" do
98
+ public_path = VeryThinTestSlice.public_dir_for(:public)
99
+ VeryThinTestSlice.public_path_for("path", "to", "file").should == public_path / "path" / "to" / "file"
100
+ [:stylesheet, :javascript, :image].each do |type|
101
+ VeryThinTestSlice.public_path_for(type, "path", "to", "file").should == public_path / "#{type}s" / "path" / "to" / "file"
102
+ end
103
+ end
104
+
105
+ it "should have a app_path_for method" do
106
+ VeryThinTestSlice.app_path_for("path", "to", "file").should == VeryThinTestSlice.app_dir_for(:root) / "path" / "to" / "file"
107
+ VeryThinTestSlice.app_path_for(:controller, "path", "to", "file").should == VeryThinTestSlice.app_dir_for(:controller) / "path" / "to" / "file"
108
+ end
109
+
110
+ it "should have a slice_path_for method" do
111
+ VeryThinTestSlice.slice_path_for("path", "to", "file").should == VeryThinTestSlice.dir_for(:root) / "path" / "to" / "file"
112
+ VeryThinTestSlice.slice_path_for(:controller, "path", "to", "file").should == VeryThinTestSlice.dir_for(:controller) / "path" / "to" / "file"
113
+ end
114
+
115
+ it "should keep a list of path component types to use when copying files" do
116
+ (VeryThinTestSlice.mirrored_components & VeryThinTestSlice.slice_paths.keys).length.should == VeryThinTestSlice.mirrored_components.length
117
+ end
118
+
119
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: merb-slices
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.7
4
+ version: 0.9.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fabien Franzen
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-09-10 00:00:00 +03:00
12
+ date: 2008-10-06 00:00:00 +03:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,12 +20,12 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 0.9.7
23
+ version: 0.9.8
24
24
  version:
25
25
  description: Merb-Slices is a Merb plugin for using and creating application 'slices' which help you modularize your application.
26
26
  email: info@fabien.be
27
- executables: []
28
-
27
+ executables:
28
+ - slice
29
29
  extensions: []
30
30
 
31
31
  extra_rdoc_files:
@@ -69,6 +69,8 @@ files:
69
69
  - lib/generators/templates/full/app/views/layout/%symbol_name%.html.erb
70
70
  - lib/generators/templates/full/app/views/main
71
71
  - lib/generators/templates/full/app/views/main/index.html.erb
72
+ - lib/generators/templates/full/config
73
+ - lib/generators/templates/full/config/init.rb
72
74
  - lib/generators/templates/full/lib
73
75
  - lib/generators/templates/full/lib/%base_name%.rb
74
76
  - lib/generators/templates/full/Rakefile
@@ -109,11 +111,83 @@ files:
109
111
  - lib/merb-slices/router_ext.rb
110
112
  - lib/merb-slices.rb
111
113
  - spec/full_slice_generator_spec.rb
114
+ - spec/full_slice_spec.rb
112
115
  - spec/merb-slice_spec.rb
113
116
  - spec/slice_generator_spec.rb
117
+ - spec/slices
118
+ - spec/slices/full-test-slice
119
+ - spec/slices/full-test-slice/app
120
+ - spec/slices/full-test-slice/app/controllers
121
+ - spec/slices/full-test-slice/app/controllers/application.rb
122
+ - spec/slices/full-test-slice/app/controllers/main.rb
123
+ - spec/slices/full-test-slice/app/helpers
124
+ - spec/slices/full-test-slice/app/helpers/application_helper.rb
125
+ - spec/slices/full-test-slice/app/views
126
+ - spec/slices/full-test-slice/app/views/layout
127
+ - spec/slices/full-test-slice/app/views/layout/full_test_slice.html.erb
128
+ - spec/slices/full-test-slice/app/views/main
129
+ - spec/slices/full-test-slice/app/views/main/index.html.erb
130
+ - spec/slices/full-test-slice/config
131
+ - spec/slices/full-test-slice/config/init.rb
132
+ - spec/slices/full-test-slice/lib
133
+ - spec/slices/full-test-slice/lib/full-test-slice
134
+ - spec/slices/full-test-slice/lib/full-test-slice/merbtasks.rb
135
+ - spec/slices/full-test-slice/lib/full-test-slice/slicetasks.rb
136
+ - spec/slices/full-test-slice/lib/full-test-slice/spectasks.rb
137
+ - spec/slices/full-test-slice/lib/full-test-slice.rb
138
+ - spec/slices/full-test-slice/LICENSE
139
+ - spec/slices/full-test-slice/public
140
+ - spec/slices/full-test-slice/public/javascripts
141
+ - spec/slices/full-test-slice/public/javascripts/master.js
142
+ - spec/slices/full-test-slice/public/stylesheets
143
+ - spec/slices/full-test-slice/public/stylesheets/master.css
144
+ - spec/slices/full-test-slice/Rakefile
145
+ - spec/slices/full-test-slice/README
146
+ - spec/slices/full-test-slice/stubs
147
+ - spec/slices/full-test-slice/stubs/app
148
+ - spec/slices/full-test-slice/stubs/app/controllers
149
+ - spec/slices/full-test-slice/stubs/app/controllers/application.rb
150
+ - spec/slices/full-test-slice/stubs/app/controllers/main.rb
151
+ - spec/slices/full-test-slice/TODO
152
+ - spec/slices/thin-test-slice
153
+ - spec/slices/thin-test-slice/application.rb
154
+ - spec/slices/thin-test-slice/lib
155
+ - spec/slices/thin-test-slice/lib/thin-test-slice
156
+ - spec/slices/thin-test-slice/lib/thin-test-slice/merbtasks.rb
157
+ - spec/slices/thin-test-slice/lib/thin-test-slice/slicetasks.rb
158
+ - spec/slices/thin-test-slice/lib/thin-test-slice.rb
159
+ - spec/slices/thin-test-slice/LICENSE
160
+ - spec/slices/thin-test-slice/public
161
+ - spec/slices/thin-test-slice/public/javascripts
162
+ - spec/slices/thin-test-slice/public/javascripts/master.js
163
+ - spec/slices/thin-test-slice/public/stylesheets
164
+ - spec/slices/thin-test-slice/public/stylesheets/master.css
165
+ - spec/slices/thin-test-slice/Rakefile
166
+ - spec/slices/thin-test-slice/README
167
+ - spec/slices/thin-test-slice/stubs
168
+ - spec/slices/thin-test-slice/stubs/application.rb
169
+ - spec/slices/thin-test-slice/TODO
170
+ - spec/slices/thin-test-slice/views
171
+ - spec/slices/thin-test-slice/views/layout
172
+ - spec/slices/thin-test-slice/views/layout/thin_test_slice.html.erb
173
+ - spec/slices/thin-test-slice/views/main
174
+ - spec/slices/thin-test-slice/views/main/index.html.erb
175
+ - spec/slices/very-thin-test-slice
176
+ - spec/slices/very-thin-test-slice/application.rb
177
+ - spec/slices/very-thin-test-slice/lib
178
+ - spec/slices/very-thin-test-slice/lib/very-thin-test-slice
179
+ - spec/slices/very-thin-test-slice/lib/very-thin-test-slice/merbtasks.rb
180
+ - spec/slices/very-thin-test-slice/lib/very-thin-test-slice/slicetasks.rb
181
+ - spec/slices/very-thin-test-slice/lib/very-thin-test-slice.rb
182
+ - spec/slices/very-thin-test-slice/LICENSE
183
+ - spec/slices/very-thin-test-slice/Rakefile
184
+ - spec/slices/very-thin-test-slice/README
185
+ - spec/slices/very-thin-test-slice/TODO
114
186
  - spec/spec_helper.rb
115
187
  - spec/thin_slice_generator_spec.rb
188
+ - spec/thin_slice_spec.rb
116
189
  - spec/very_thin_slice_generator_spec.rb
190
+ - spec/very_thin_slice_spec.rb
117
191
  has_rdoc: true
118
192
  homepage: http://merbivore.com
119
193
  post_install_message: