merb-slices 0.9.4 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. data/Rakefile +2 -2
  2. data/lib/generators/base.rb +12 -0
  3. data/lib/generators/full.rb +10 -1
  4. data/lib/generators/templates/{full → common}/LICENSE +0 -0
  5. data/lib/generators/templates/{very_thin → common}/Rakefile +1 -1
  6. data/lib/generators/templates/{thin → common}/TODO +0 -0
  7. data/lib/generators/templates/{very_thin → common}/application.rb +0 -0
  8. data/lib/generators/templates/{thin → common}/lib/%base_name%/merbtasks.rb +3 -3
  9. data/lib/generators/templates/{full → common}/lib/%base_name%/slicetasks.rb +0 -0
  10. data/lib/generators/templates/common/lib/%base_name%/spectasks.rb +65 -0
  11. data/lib/generators/templates/{full → common}/public/javascripts/master.js +0 -0
  12. data/lib/generators/templates/{full → common}/public/stylesheets/master.css +0 -0
  13. data/lib/generators/templates/full/Rakefile +1 -1
  14. data/lib/generators/templates/full/lib/%base_name%.rb +1 -1
  15. data/lib/generators/templates/full/spec/%base_name%_spec.rb +1 -1
  16. data/lib/generators/thin.rb +14 -2
  17. data/lib/generators/very_thin.rb +11 -2
  18. metadata +18 -31
  19. data/lib/generators/templates/full/lib/%base_name%/merbtasks.rb +0 -166
  20. data/lib/generators/templates/thin/LICENSE +0 -20
  21. data/lib/generators/templates/thin/Rakefile +0 -46
  22. data/lib/generators/templates/thin/application.rb +0 -36
  23. data/lib/generators/templates/thin/lib/%base_name%/slicetasks.rb +0 -18
  24. data/lib/generators/templates/thin/public/javascripts/master.js +0 -0
  25. data/lib/generators/templates/thin/public/stylesheets/master.css +0 -2
  26. data/lib/generators/templates/very_thin/LICENSE +0 -20
  27. data/lib/generators/templates/very_thin/TODO +0 -7
  28. data/lib/generators/templates/very_thin/lib/%base_name%/merbtasks.rb +0 -106
  29. data/lib/generators/templates/very_thin/lib/%base_name%/slicetasks.rb +0 -18
data/Rakefile CHANGED
@@ -17,7 +17,7 @@ GEM_EMAIL = "info@fabien.be"
17
17
 
18
18
  GEM_NAME = "merb-slices"
19
19
  PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
20
- GEM_VERSION = (Merb::MORE_VERSION rescue "0.9.4") + PKG_BUILD
20
+ GEM_VERSION = (Merb::MORE_VERSION rescue "0.9.5") + PKG_BUILD
21
21
 
22
22
  RELEASE_NAME = "REL #{GEM_VERSION}"
23
23
 
@@ -35,7 +35,7 @@ spec = Gem::Specification.new do |s|
35
35
  s.author = GEM_AUTHOR
36
36
  s.email = GEM_EMAIL
37
37
  s.homepage = PROJECT_URL
38
- s.add_dependency('merb-core', '>= 0.9.4')
38
+ s.add_dependency('merb-core', '>= 0.9.5')
39
39
  s.require_path = 'lib'
40
40
  s.files = %w(LICENSE README Rakefile Generators TODO) + Dir.glob("{lib,spec}/**/*")
41
41
  end
@@ -14,6 +14,18 @@ module Merb::Generators
14
14
  invoke :full_slice, :thin => nil, :very_thin => nil
15
15
  invoke :thin_slice, :thin => true
16
16
  invoke :very_thin_slice, :very_thin => true
17
+
18
+ end
19
+
20
+ class BaseSliceGenerator < NamedGenerator
21
+
22
+ def self.common_template(name, source)
23
+ template name do
24
+ source File.dirname(__FILE__), 'templates', 'common', source
25
+ destination source
26
+ end
27
+ end
28
+
17
29
  end
18
30
 
19
31
  add :slice, SliceGenerator
@@ -1,6 +1,6 @@
1
1
  module Merb::Generators
2
2
 
3
- class FullSliceGenerator < NamedGenerator
3
+ class FullSliceGenerator < BaseSliceGenerator
4
4
 
5
5
  def self.source_root
6
6
  File.join(File.dirname(__FILE__), 'templates', 'full')
@@ -8,6 +8,15 @@ module Merb::Generators
8
8
 
9
9
  glob!
10
10
 
11
+ common_template :javascript, 'public/javascripts/master.js'
12
+ common_template :stylesheet, 'public/stylesheets/master.css'
13
+
14
+ common_template :license, 'LICENSE'
15
+
16
+ common_template :merbtasks, 'lib/%base_name%/merbtasks.rb'
17
+ common_template :slicetasks, 'lib/%base_name%/slicetasks.rb'
18
+ common_template :spectasks, 'lib/%base_name%/spectasks.rb'
19
+
11
20
  first_argument :name, :required => true
12
21
 
13
22
  def destination_root
File without changes
@@ -24,7 +24,7 @@ spec = Gem::Specification.new do |s|
24
24
  s.homepage = HOMEPAGE
25
25
  s.add_dependency('merb-slices', '>= <%= Merb::VERSION %>')
26
26
  s.require_path = 'lib'
27
- s.files = %w(LICENSE README Rakefile TODO application.rb) + Dir.glob("{lib,public,stubs}/**/*")
27
+ s.files = %w(LICENSE README Rakefile TODO application.rb) + Dir.glob("{lib,spec,app,public,stubs,views}/**/*")
28
28
  end
29
29
 
30
30
  Rake::GemPackageTask.new(spec) do |pkg|
File without changes
@@ -7,11 +7,11 @@ namespace :slices do
7
7
  desc "Test for any dependencies"
8
8
  task :preflight do # see slicetasks.rb
9
9
  end
10
-
10
+
11
11
  desc "Setup directories"
12
12
  task :setup_directories do
13
13
  puts "Creating directories for host application"
14
- [:application, :view, :model, :controller, :helper, :mailer, :part, :public].each do |type|
14
+ <%= module_name %>.mirrored_components.each do |type|
15
15
  if File.directory?(<%= module_name %>.dir_for(type))
16
16
  if !File.directory?(dst_path = <%= module_name %>.app_dir_for(type))
17
17
  relative_path = dst_path.relative_path_from(Merb.root)
@@ -33,7 +33,7 @@ namespace :slices do
33
33
 
34
34
  desc "Copy stub files and views to host application"
35
35
  task :patch => [ "stubs", "freeze:views" ]
36
-
36
+
37
37
  desc "Copy public assets to host application"
38
38
  task :copy_assets do
39
39
  puts "Copying assets for <%= module_name %> - resolves any collisions"
@@ -0,0 +1,65 @@
1
+ namespace :slices do
2
+ namespace :<%= symbol_name %> do
3
+
4
+ desc "Run slice specs within the host application context"
5
+ task :spec => [ "spec:explain", "spec:default" ]
6
+
7
+ namespace :spec do
8
+
9
+ slice_root = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
10
+
11
+ task :explain do
12
+ puts "\nNote: By running <%= module_name %> specs inside the application context any\n" +
13
+ "overrides could break existing specs. This isn't always a problem,\n" +
14
+ "especially in the case of views. Use these spec tasks to check how\n" +
15
+ "well your application conforms to the original slice implementation."
16
+ end
17
+
18
+ Spec::Rake::SpecTask.new('default') do |t|
19
+ t.spec_opts = ["--format", "specdoc", "--colour"]
20
+ t.spec_files = Dir["#{slice_root}/spec/**/*_spec.rb"].sort
21
+ end
22
+
23
+ desc "Run all model specs, run a spec for a specific Model with MODEL=MyModel"
24
+ Spec::Rake::SpecTask.new('model') do |t|
25
+ t.spec_opts = ["--format", "specdoc", "--colour"]
26
+ if(ENV['MODEL'])
27
+ t.spec_files = Dir["#{slice_root}/spec/models/**/#{ENV['MODEL']}_spec.rb"].sort
28
+ else
29
+ t.spec_files = Dir["#{slice_root}/spec/models/**/*_spec.rb"].sort
30
+ end
31
+ end
32
+
33
+ desc "Run all controller specs, run a spec for a specific Controller with CONTROLLER=MyController"
34
+ Spec::Rake::SpecTask.new('controller') do |t|
35
+ t.spec_opts = ["--format", "specdoc", "--colour"]
36
+ if(ENV['CONTROLLER'])
37
+ t.spec_files = Dir["#{slice_root}/spec/controllers/**/#{ENV['CONTROLLER']}_spec.rb"].sort
38
+ else
39
+ t.spec_files = Dir["#{slice_root}/spec/controllers/**/*_spec.rb"].sort
40
+ end
41
+ end
42
+
43
+ desc "Run all view specs, run specs for a specific controller (and view) with CONTROLLER=MyController (VIEW=MyView)"
44
+ Spec::Rake::SpecTask.new('view') do |t|
45
+ t.spec_opts = ["--format", "specdoc", "--colour"]
46
+ if(ENV['CONTROLLER'] and ENV['VIEW'])
47
+ t.spec_files = Dir["#{slice_root}/spec/views/**/#{ENV['CONTROLLER']}/#{ENV['VIEW']}*_spec.rb"].sort
48
+ elsif(ENV['CONTROLLER'])
49
+ t.spec_files = Dir["#{slice_root}/spec/views/**/#{ENV['CONTROLLER']}/*_spec.rb"].sort
50
+ else
51
+ t.spec_files = Dir["#{slice_root}/spec/views/**/*_spec.rb"].sort
52
+ end
53
+ end
54
+
55
+ desc "Run all specs and output the result in html"
56
+ Spec::Rake::SpecTask.new('html') do |t|
57
+ t.spec_opts = ["--format", "html"]
58
+ t.libs = ['lib', 'server/lib' ]
59
+ t.spec_files = Dir["#{slice_root}/spec/**/*_spec.rb"].sort
60
+ end
61
+
62
+ end
63
+
64
+ end
65
+ end
@@ -2,8 +2,8 @@ require 'rubygems'
2
2
  require 'rake/gempackagetask'
3
3
  require 'spec/rake/spectask'
4
4
  require 'merb-core/version'
5
- require 'merb-core/test/tasks/spectasks'
6
5
  require 'merb-core/tasks/merb_rake_helper'
6
+ require 'merb-core/test/tasks/spectasks'
7
7
 
8
8
  NAME = "<%= base_name %>"
9
9
  AUTHOR = "Your Name"
@@ -3,7 +3,7 @@ if defined?(Merb::Plugins)
3
3
  $:.unshift File.dirname(__FILE__)
4
4
 
5
5
  load_dependency 'merb-slices'
6
- Merb::Plugins.add_rakefiles "<%= base_name %>/merbtasks", "<%= base_name %>/slicetasks"
6
+ Merb::Plugins.add_rakefiles "<%= base_name %>/merbtasks", "<%= base_name %>/slicetasks", "<%= base_name %>/spectasks"
7
7
 
8
8
  # Register the Slice for the current host application
9
9
  Merb::Slices::register(__FILE__)
@@ -47,7 +47,7 @@ describe "<%= module_name %> (module)" do
47
47
 
48
48
  it "should have :routes and :named_routes properties" do
49
49
  <%= module_name %>.routes.should_not be_empty
50
- <%= module_name %>.named_routes[:<%= base_name %>_index].should be_kind_of(Merb::Router::Route)
50
+ <%= module_name %>.named_routes[:<%= symbol_name %>_index].should be_kind_of(Merb::Router::Route)
51
51
  end
52
52
 
53
53
  it "should have an url helper method for slice-specific routes" do
@@ -1,13 +1,25 @@
1
1
  module Merb::Generators
2
2
 
3
- class ThinSliceGenerator < NamedGenerator
4
-
3
+ class ThinSliceGenerator < BaseSliceGenerator
4
+
5
5
  def self.source_root
6
6
  File.join(File.dirname(__FILE__), 'templates', 'thin')
7
7
  end
8
8
 
9
9
  glob!
10
10
 
11
+ common_template :application, 'application.rb'
12
+
13
+ common_template :javascript, 'public/javascripts/master.js'
14
+ common_template :stylesheet, 'public/stylesheets/master.css'
15
+
16
+ common_template :rakefile, 'Rakefile'
17
+ common_template :license, 'LICENSE'
18
+ common_template :todo, 'TODO'
19
+
20
+ common_template :merbtasks, 'lib/%base_name%/merbtasks.rb'
21
+ common_template :slicetasks, 'lib/%base_name%/slicetasks.rb'
22
+
11
23
  first_argument :name, :required => true
12
24
 
13
25
  def destination_root
@@ -1,13 +1,22 @@
1
1
  module Merb::Generators
2
2
 
3
- class VeryThinSliceGenerator < NamedGenerator
4
-
3
+ class VeryThinSliceGenerator < BaseSliceGenerator
4
+
5
5
  def self.source_root
6
6
  File.join(File.dirname(__FILE__), 'templates', 'very_thin')
7
7
  end
8
8
 
9
9
  glob!
10
10
 
11
+ common_template :application, 'application.rb'
12
+
13
+ common_template :rakefile, 'Rakefile'
14
+ common_template :license, 'LICENSE'
15
+ common_template :todo, 'TODO'
16
+
17
+ common_template :merbtasks, 'lib/%base_name%/merbtasks.rb'
18
+ common_template :slicetasks, 'lib/%base_name%/slicetasks.rb'
19
+
11
20
  first_argument :name, :required => true
12
21
 
13
22
  def destination_root
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.4
4
+ version: 0.9.5
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-08-13 00:00:00 +03:00
12
+ date: 2008-08-21 00:00:00 +03:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 0.9.4
23
+ version: 0.9.5
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
@@ -42,6 +42,21 @@ files:
42
42
  - lib/generators/base.rb
43
43
  - lib/generators/full.rb
44
44
  - lib/generators/templates
45
+ - lib/generators/templates/common
46
+ - lib/generators/templates/common/application.rb
47
+ - lib/generators/templates/common/lib
48
+ - lib/generators/templates/common/lib/%base_name%
49
+ - lib/generators/templates/common/lib/%base_name%/merbtasks.rb
50
+ - lib/generators/templates/common/lib/%base_name%/slicetasks.rb
51
+ - lib/generators/templates/common/lib/%base_name%/spectasks.rb
52
+ - lib/generators/templates/common/LICENSE
53
+ - lib/generators/templates/common/public
54
+ - lib/generators/templates/common/public/javascripts
55
+ - lib/generators/templates/common/public/javascripts/master.js
56
+ - lib/generators/templates/common/public/stylesheets
57
+ - lib/generators/templates/common/public/stylesheets/master.css
58
+ - lib/generators/templates/common/Rakefile
59
+ - lib/generators/templates/common/TODO
45
60
  - lib/generators/templates/full
46
61
  - lib/generators/templates/full/app
47
62
  - lib/generators/templates/full/app/controllers
@@ -55,16 +70,7 @@ files:
55
70
  - lib/generators/templates/full/app/views/main
56
71
  - lib/generators/templates/full/app/views/main/index.html.erb
57
72
  - lib/generators/templates/full/lib
58
- - lib/generators/templates/full/lib/%base_name%
59
- - lib/generators/templates/full/lib/%base_name%/merbtasks.rb
60
- - lib/generators/templates/full/lib/%base_name%/slicetasks.rb
61
73
  - lib/generators/templates/full/lib/%base_name%.rb
62
- - lib/generators/templates/full/LICENSE
63
- - lib/generators/templates/full/public
64
- - lib/generators/templates/full/public/javascripts
65
- - lib/generators/templates/full/public/javascripts/master.js
66
- - lib/generators/templates/full/public/stylesheets
67
- - lib/generators/templates/full/public/stylesheets/master.css
68
74
  - lib/generators/templates/full/Rakefile
69
75
  - lib/generators/templates/full/README
70
76
  - lib/generators/templates/full/spec
@@ -79,39 +85,20 @@ files:
79
85
  - lib/generators/templates/full/stubs/app/controllers/main.rb
80
86
  - lib/generators/templates/full/TODO
81
87
  - lib/generators/templates/thin
82
- - lib/generators/templates/thin/application.rb
83
88
  - lib/generators/templates/thin/lib
84
- - lib/generators/templates/thin/lib/%base_name%
85
- - lib/generators/templates/thin/lib/%base_name%/merbtasks.rb
86
- - lib/generators/templates/thin/lib/%base_name%/slicetasks.rb
87
89
  - lib/generators/templates/thin/lib/%base_name%.rb
88
- - lib/generators/templates/thin/LICENSE
89
- - lib/generators/templates/thin/public
90
- - lib/generators/templates/thin/public/javascripts
91
- - lib/generators/templates/thin/public/javascripts/master.js
92
- - lib/generators/templates/thin/public/stylesheets
93
- - lib/generators/templates/thin/public/stylesheets/master.css
94
- - lib/generators/templates/thin/Rakefile
95
90
  - lib/generators/templates/thin/README
96
91
  - lib/generators/templates/thin/stubs
97
92
  - lib/generators/templates/thin/stubs/application.rb
98
- - lib/generators/templates/thin/TODO
99
93
  - lib/generators/templates/thin/views
100
94
  - lib/generators/templates/thin/views/layout
101
95
  - lib/generators/templates/thin/views/layout/%symbol_name%.html.erb
102
96
  - lib/generators/templates/thin/views/main
103
97
  - lib/generators/templates/thin/views/main/index.html.erb
104
98
  - lib/generators/templates/very_thin
105
- - lib/generators/templates/very_thin/application.rb
106
99
  - lib/generators/templates/very_thin/lib
107
- - lib/generators/templates/very_thin/lib/%base_name%
108
- - lib/generators/templates/very_thin/lib/%base_name%/merbtasks.rb
109
- - lib/generators/templates/very_thin/lib/%base_name%/slicetasks.rb
110
100
  - lib/generators/templates/very_thin/lib/%base_name%.rb
111
- - lib/generators/templates/very_thin/LICENSE
112
- - lib/generators/templates/very_thin/Rakefile
113
101
  - lib/generators/templates/very_thin/README
114
- - lib/generators/templates/very_thin/TODO
115
102
  - lib/generators/thin.rb
116
103
  - lib/generators/very_thin.rb
117
104
  - lib/merb-slices
@@ -1,166 +0,0 @@
1
- namespace :slices do
2
- namespace :<%= symbol_name %> do
3
-
4
- desc "Install <%= module_name %>"
5
- task :install => [:preflight, :setup_directories, :copy_assets, :migrate]
6
-
7
- desc "Test for any dependencies"
8
- task :preflight do # see slicetasks.rb
9
- end
10
-
11
- desc "Setup directories"
12
- task :setup_directories do
13
- puts "Creating directories for host application"
14
- <%= module_name %>.mirrored_components.each do |type|
15
- if File.directory?(<%= module_name %>.dir_for(type))
16
- if !File.directory?(dst_path = <%= module_name %>.app_dir_for(type))
17
- relative_path = dst_path.relative_path_from(Merb.root)
18
- puts "- creating directory :#{type} #{File.basename(Merb.root) / relative_path}"
19
- mkdir_p(dst_path)
20
- end
21
- end
22
- end
23
- end
24
-
25
- desc "Copy stub files to host application"
26
- task :stubs do
27
- puts "Copying stubs for <%= module_name %> - resolves any collisions"
28
- copied, preserved = <%= module_name %>.mirror_stubs!
29
- puts "- no files to copy" if copied.empty? && preserved.empty?
30
- copied.each { |f| puts "- copied #{f}" }
31
- preserved.each { |f| puts "! preserved override as #{f}" }
32
- end
33
-
34
- desc "Copy stub files and views to host application"
35
- task :patch => [ "stubs", "freeze:views" ]
36
-
37
- desc "Copy public assets to host application"
38
- task :copy_assets do
39
- puts "Copying assets for <%= module_name %> - resolves any collisions"
40
- copied, preserved = <%= module_name %>.mirror_public!
41
- puts "- no files to copy" if copied.empty? && preserved.empty?
42
- copied.each { |f| puts "- copied #{f}" }
43
- preserved.each { |f| puts "! preserved override as #{f}" }
44
- end
45
-
46
- desc "Migrate the database"
47
- task :migrate do # see slicetasks.rb
48
- end
49
-
50
- desc "Freeze <%= module_name %> into your app (only <%= base_name %>/app)"
51
- task :freeze => [ "freeze:app" ]
52
-
53
- namespace :freeze do
54
-
55
- desc "Freezes <%= module_name %> by installing the gem into application/gems using merb-freezer"
56
- task :gem do
57
- begin
58
- Object.const_get(:Freezer).freeze(ENV["GEM"] || "<%= base_name %>", ENV["UPDATE"], ENV["MODE"] || 'rubygems')
59
- rescue NameError
60
- puts "! dependency 'merb-freezer' missing"
61
- end
62
- end
63
-
64
- desc "Freezes <%= module_name %> by copying all files from <%= base_name %>/app to your application"
65
- task :app do
66
- puts "Copying all <%= base_name %>/app files to your application - resolves any collisions"
67
- copied, preserved = <%= module_name %>.mirror_app!
68
- puts "- no files to copy" if copied.empty? && preserved.empty?
69
- copied.each { |f| puts "- copied #{f}" }
70
- preserved.each { |f| puts "! preserved override as #{f}" }
71
- end
72
-
73
- desc "Freeze all views into your application for easy modification"
74
- task :views do
75
- puts "Copying all view templates to your application - resolves any collisions"
76
- copied, preserved = <%= module_name %>.mirror_files_for :view
77
- puts "- no files to copy" if copied.empty? && preserved.empty?
78
- copied.each { |f| puts "- copied #{f}" }
79
- preserved.each { |f| puts "! preserved override as #{f}" }
80
- end
81
-
82
- desc "Freeze all models into your application for easy modification"
83
- task :models do
84
- puts "Copying all models to your application - resolves any collisions"
85
- copied, preserved = <%= module_name %>.mirror_files_for :model
86
- puts "- no files to copy" if copied.empty? && preserved.empty?
87
- copied.each { |f| puts "- copied #{f}" }
88
- preserved.each { |f| puts "! preserved override as #{f}" }
89
- end
90
-
91
- desc "Freezes <%= module_name %> as a gem and copies over <%= base_name %>/app"
92
- task :app_with_gem => [:gem, :app]
93
-
94
- desc "Freezes <%= module_name %> by unpacking all files into your application"
95
- task :unpack do
96
- puts "Unpacking <%= module_name %> files to your application - resolves any collisions"
97
- copied, preserved = <%= module_name %>.unpack_slice!
98
- puts "- no files to copy" if copied.empty? && preserved.empty?
99
- copied.each { |f| puts "- copied #{f}" }
100
- preserved.each { |f| puts "! preserved override as #{f}" }
101
- end
102
-
103
- end
104
-
105
- desc "Run slice specs within the host application context"
106
- task :spec => [ "spec:explain", "spec:default" ]
107
-
108
- namespace :spec do
109
-
110
- slice_root = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
111
-
112
- task :explain do
113
- puts "\nNote: By running <%= module_name %> specs inside the application context any\n" +
114
- "overrides could break existing specs. This isn't always a problem,\n" +
115
- "especially in the case of views. Use these spec tasks to check how\n" +
116
- "well your application conforms to the original slice implementation."
117
- end
118
-
119
- Spec::Rake::SpecTask.new('default') do |t|
120
- t.spec_opts = ["--format", "specdoc", "--colour"]
121
- t.spec_files = Dir["#{slice_root}/spec/**/*_spec.rb"].sort
122
- end
123
-
124
- desc "Run all model specs, run a spec for a specific Model with MODEL=MyModel"
125
- Spec::Rake::SpecTask.new('model') do |t|
126
- t.spec_opts = ["--format", "specdoc", "--colour"]
127
- if(ENV['MODEL'])
128
- t.spec_files = Dir["#{slice_root}/spec/models/**/#{ENV['MODEL']}_spec.rb"].sort
129
- else
130
- t.spec_files = Dir["#{slice_root}/spec/models/**/*_spec.rb"].sort
131
- end
132
- end
133
-
134
- desc "Run all controller specs, run a spec for a specific Controller with CONTROLLER=MyController"
135
- Spec::Rake::SpecTask.new('controller') do |t|
136
- t.spec_opts = ["--format", "specdoc", "--colour"]
137
- if(ENV['CONTROLLER'])
138
- t.spec_files = Dir["#{slice_root}/spec/controllers/**/#{ENV['CONTROLLER']}_spec.rb"].sort
139
- else
140
- t.spec_files = Dir["#{slice_root}/spec/controllers/**/*_spec.rb"].sort
141
- end
142
- end
143
-
144
- desc "Run all view specs, run specs for a specific controller (and view) with CONTROLLER=MyController (VIEW=MyView)"
145
- Spec::Rake::SpecTask.new('view') do |t|
146
- t.spec_opts = ["--format", "specdoc", "--colour"]
147
- if(ENV['CONTROLLER'] and ENV['VIEW'])
148
- t.spec_files = Dir["#{slice_root}/spec/views/**/#{ENV['CONTROLLER']}/#{ENV['VIEW']}*_spec.rb"].sort
149
- elsif(ENV['CONTROLLER'])
150
- t.spec_files = Dir["#{slice_root}/spec/views/**/#{ENV['CONTROLLER']}/*_spec.rb"].sort
151
- else
152
- t.spec_files = Dir["#{slice_root}/spec/views/**/*_spec.rb"].sort
153
- end
154
- end
155
-
156
- desc "Run all specs and output the result in html"
157
- Spec::Rake::SpecTask.new('html') do |t|
158
- t.spec_opts = ["--format", "html"]
159
- t.libs = ['lib', 'server/lib' ]
160
- t.spec_files = Dir["#{slice_root}/spec/**/*_spec.rb"].sort
161
- end
162
-
163
- end
164
-
165
- end
166
- end
@@ -1,20 +0,0 @@
1
- Copyright (c) <%= Time.now.year %> YOUR NAME
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,46 +0,0 @@
1
- require 'rubygems'
2
- require 'rake/gempackagetask'
3
- require 'merb-core/version'
4
- require 'merb-core/tasks/merb_rake_helper'
5
-
6
- NAME = "<%= base_name %>"
7
- AUTHOR = "Your Name"
8
- EMAIL = "Your Email"
9
- HOMEPAGE = "http://merbivore.com/"
10
- SUMMARY = "Merb Slice that provides ..."
11
- GEM_VERSION = "<%= Merb::VERSION %>"
12
-
13
- spec = Gem::Specification.new do |s|
14
- s.rubyforge_project = 'merb'
15
- s.name = NAME
16
- s.version = GEM_VERSION
17
- s.platform = Gem::Platform::RUBY
18
- s.has_rdoc = true
19
- s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
20
- s.summary = SUMMARY
21
- s.description = s.summary
22
- s.author = AUTHOR
23
- s.email = EMAIL
24
- s.homepage = HOMEPAGE
25
- s.add_dependency('merb-slices', '>= <%= Merb::VERSION %>')
26
- s.require_path = 'lib'
27
- s.files = %w(LICENSE README Rakefile TODO application.rb) + Dir.glob("{lib,public,views,stubs}/**/*")
28
- end
29
-
30
- Rake::GemPackageTask.new(spec) do |pkg|
31
- pkg.gem_spec = spec
32
- end
33
-
34
- desc "Install <%= module_name %> as a gem"
35
- task :install => [:package] do
36
- sh %{#{sudo} gem install pkg/#{NAME}-#{GEM_VERSION} --no-update-sources}
37
- end
38
-
39
- namespace :jruby do
40
-
41
- desc "Run :package and install the resulting .gem with jruby"
42
- task :install => :package do
43
- sh %{#{sudo} jruby -S gem install #{install_home} pkg/#{NAME}-#{GEM_VERSION}.gem --no-rdoc --no-ri}
44
- end
45
-
46
- end
@@ -1,36 +0,0 @@
1
- module <%= module_name %>
2
-
3
- # All Slice code is expected to be namespaced inside this module.
4
-
5
- class Application < Merb::Controller
6
-
7
- controller_for_slice
8
-
9
- private
10
-
11
- # Construct a path relative to the public directory
12
- def public_path_for(type, *segments)
13
- ::<%= module_name %>.public_path_for(type, *segments)
14
- end
15
-
16
- # Construct an app-level path.
17
- def app_path_for(type, *segments)
18
- ::<%= module_name %>.app_path_for(type, *segments)
19
- end
20
-
21
- # Construct a slice-level path
22
- def slice_path_for(type, *segments)
23
- ::<%= module_name %>.slice_path_for(type, *segments)
24
- end
25
-
26
- end
27
-
28
- class Main < Application
29
-
30
- def index
31
- render
32
- end
33
-
34
- end
35
-
36
- end
@@ -1,18 +0,0 @@
1
- namespace :slices do
2
- namespace :<%= symbol_name %> do
3
-
4
- # add your own <%= base_name %> tasks here
5
-
6
- # implement this to test for structural/code dependencies
7
- # like certain directories or availability of other files
8
- desc "Test for any dependencies"
9
- task :preflight do
10
- end
11
-
12
- # implement this to perform any database related setup steps
13
- desc "Migrate the database"
14
- task :migrate do
15
- end
16
-
17
- end
18
- end
@@ -1,2 +0,0 @@
1
- html, body { margin: 0; padding: 0; }
2
- #container { width: 800px; margin: 4em auto; padding: 4em 4em 6em 4em; background: #DDDDDD; }
@@ -1,20 +0,0 @@
1
- Copyright (c) <%= Time.now.year %> YOUR NAME
2
-
3
- Permission is hereby granted, free of charge, to any person obtaining
4
- a copy of this software and associated documentation files (the
5
- "Software"), to deal in the Software without restriction, including
6
- without limitation the rights to use, copy, modify, merge, publish,
7
- distribute, sublicense, and/or sell copies of the Software, and to
8
- permit persons to whom the Software is furnished to do so, subject to
9
- the following conditions:
10
-
11
- The above copyright notice and this permission notice shall be
12
- included in all copies or substantial portions of the Software.
13
-
14
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,7 +0,0 @@
1
- TODO:
2
-
3
- - Fix <%= module_name %>.description and <%= module_name %>.version
4
- - Fix LICENSE with your name
5
- - Fix Rakefile with your name and contact info
6
- - Add your code to lib/<%= base_name %>.rb
7
- - Add your Merb rake tasks to lib/<%= base_name %>/merbtasks.rb
@@ -1,106 +0,0 @@
1
- namespace :slices do
2
- namespace :<%= symbol_name %> do
3
-
4
- desc "Install <%= module_name %>"
5
- task :install => [:preflight, :setup_directories, :copy_assets, :migrate]
6
-
7
- desc "Test for any dependencies"
8
- task :preflight do # see slicetasks.rb
9
- end
10
-
11
- desc "Setup directories"
12
- task :setup_directories do
13
- puts "Creating directories for host application"
14
- [:application, :view, :model, :controller, :helper, :mailer, :part, :public].each do |type|
15
- if File.directory?(<%= module_name %>.dir_for(type))
16
- if !File.directory?(dst_path = <%= module_name %>.app_dir_for(type))
17
- relative_path = dst_path.relative_path_from(Merb.root)
18
- puts "- creating directory :#{type} #{File.basename(Merb.root) / relative_path}"
19
- mkdir_p(dst_path)
20
- end
21
- end
22
- end
23
- end
24
-
25
- desc "Copy stub files to host application"
26
- task :stubs do
27
- puts "Copying stubs for <%= module_name %> - resolves any collisions"
28
- copied, preserved = <%= module_name %>.mirror_stubs!
29
- puts "- no files to copy" if copied.empty? && preserved.empty?
30
- copied.each { |f| puts "- copied #{f}" }
31
- preserved.each { |f| puts "! preserved override as #{f}" }
32
- end
33
-
34
- desc "Copy stub files and views to host application"
35
- task :patch => [ "stubs", "freeze:views" ]
36
-
37
- desc "Copy public assets to host application"
38
- task :copy_assets do
39
- puts "Copying assets for <%= module_name %> - resolves any collisions"
40
- copied, preserved = <%= module_name %>.mirror_public!
41
- puts "- no files to copy" if copied.empty? && preserved.empty?
42
- copied.each { |f| puts "- copied #{f}" }
43
- preserved.each { |f| puts "! preserved override as #{f}" }
44
- end
45
-
46
- desc "Migrate the database"
47
- task :migrate do # see slicetasks.rb
48
- end
49
-
50
- desc "Freeze <%= module_name %> into your app (only <%= base_name %>/app)"
51
- task :freeze => [ "freeze:app" ]
52
-
53
- namespace :freeze do
54
-
55
- desc "Freezes <%= module_name %> by installing the gem into application/gems using merb-freezer"
56
- task :gem do
57
- begin
58
- Object.const_get(:Freezer).freeze(ENV["GEM"] || "<%= base_name %>", ENV["UPDATE"], ENV["MODE"] || 'rubygems')
59
- rescue NameError
60
- puts "! dependency 'merb-freezer' missing"
61
- end
62
- end
63
-
64
- desc "Freezes <%= module_name %> by copying all files from <%= base_name %>/app to your application"
65
- task :app do
66
- puts "Copying all <%= base_name %>/app files to your application - resolves any collisions"
67
- copied, preserved = <%= module_name %>.mirror_app!
68
- puts "- no files to copy" if copied.empty? && preserved.empty?
69
- copied.each { |f| puts "- copied #{f}" }
70
- preserved.each { |f| puts "! preserved override as #{f}" }
71
- end
72
-
73
- desc "Freeze all views into your application for easy modification"
74
- task :views do
75
- puts "Copying all view templates to your application - resolves any collisions"
76
- copied, preserved = <%= module_name %>.mirror_files_for :view
77
- puts "- no files to copy" if copied.empty? && preserved.empty?
78
- copied.each { |f| puts "- copied #{f}" }
79
- preserved.each { |f| puts "! preserved override as #{f}" }
80
- end
81
-
82
- desc "Freeze all models into your application for easy modification"
83
- task :models do
84
- puts "Copying all models to your application - resolves any collisions"
85
- copied, preserved = <%= module_name %>.mirror_files_for :model
86
- puts "- no files to copy" if copied.empty? && preserved.empty?
87
- copied.each { |f| puts "- copied #{f}" }
88
- preserved.each { |f| puts "! preserved override as #{f}" }
89
- end
90
-
91
- desc "Freezes <%= module_name %> as a gem and copies over <%= base_name %>/app"
92
- task :app_with_gem => [:gem, :app]
93
-
94
- desc "Freezes <%= module_name %> by unpacking all files into your application"
95
- task :unpack do
96
- puts "Unpacking <%= module_name %> files to your application - resolves any collisions"
97
- copied, preserved = <%= module_name %>.unpack_slice!
98
- puts "- no files to copy" if copied.empty? && preserved.empty?
99
- copied.each { |f| puts "- copied #{f}" }
100
- preserved.each { |f| puts "! preserved override as #{f}" }
101
- end
102
-
103
- end
104
-
105
- end
106
- end
@@ -1,18 +0,0 @@
1
- namespace :slices do
2
- namespace :<%= symbol_name %> do
3
-
4
- # add your own <%= base_name %> tasks here
5
-
6
- # implement this to test for structural/code dependencies
7
- # like certain directories or availability of other files
8
- desc "Test for any dependencies"
9
- task :preflight do
10
- end
11
-
12
- # implement this to perform any database related setup steps
13
- desc "Migrate the database"
14
- task :migrate do
15
- end
16
-
17
- end
18
- end