merb-gen 0.9.8 → 0.9.9
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.
- data/README +6 -3
- data/Rakefile +6 -4
- data/bin/merb-gen +1 -23
- data/lib/generators/controller.rb +4 -2
- data/lib/generators/helper.rb +0 -5
- data/lib/generators/merb/merb_core.rb +95 -0
- data/lib/generators/merb/merb_flat.rb +70 -69
- data/lib/generators/merb/merb_stack.rb +110 -0
- data/lib/generators/merb/merb_very_flat.rb +61 -64
- data/lib/generators/merb_plugin.rb +5 -0
- data/lib/generators/model.rb +5 -2
- data/lib/generators/resource.rb +7 -2
- data/lib/generators/resource_controller.rb +4 -4
- data/lib/generators/templates/application/common/Rakefile +2 -6
- data/lib/generators/templates/application/common/doc.thor +149 -0
- data/lib/generators/templates/application/common/dothtaccess +17 -0
- data/lib/generators/templates/application/common/jquery.js +32 -0
- data/lib/generators/templates/application/common/merb.thor +1550 -861
- data/lib/generators/templates/application/{merb → merb_core}/app/controllers/application.rb +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/app/controllers/exceptions.rb +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/app/helpers/global_helpers.rb +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/app/views/exceptions/internal_server_error.html.erb +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/app/views/exceptions/not_acceptable.html.erb +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/app/views/exceptions/not_found.html.erb +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/autotest/discover.rb +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/autotest/merb.rb +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/autotest/merb_rspec.rb +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/config/environments/development.rb +7 -2
- data/lib/generators/templates/application/{merb → merb_core}/config/environments/production.rb +5 -2
- data/lib/generators/templates/application/{merb → merb_core}/config/environments/rake.rb +6 -2
- data/lib/generators/templates/application/merb_core/config/environments/staging.rb +10 -0
- data/lib/generators/templates/application/merb_core/config/environments/test.rb +12 -0
- data/lib/generators/templates/application/{merb → merb_core}/config/init.rb +6 -6
- data/lib/generators/templates/application/{merb → merb_core}/config/rack.rb +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/config/router.rb +0 -0
- data/lib/generators/templates/application/merb_core/doc/rdoc/generators/merb_generator.rb +1362 -0
- data/lib/generators/templates/application/merb_core/doc/rdoc/generators/template/merb/api_grease.js +640 -0
- data/lib/generators/templates/application/merb_core/doc/rdoc/generators/template/merb/index.html.erb +37 -0
- data/lib/generators/templates/application/merb_core/doc/rdoc/generators/template/merb/merb.css +252 -0
- data/lib/generators/templates/application/merb_core/doc/rdoc/generators/template/merb/merb.rb +351 -0
- data/lib/generators/templates/application/merb_core/doc/rdoc/generators/template/merb/merb_doc_styles.css +492 -0
- data/lib/generators/templates/application/merb_core/doc/rdoc/generators/template/merb/prototype.js +2515 -0
- data/lib/generators/templates/application/{merb/app/models → merb_core/lib}/merb/session.rb +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/public/favicon.ico +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/public/images/merb.jpg +0 -0
- data/lib/generators/templates/application/merb_core/public/javascripts/application.js +1 -0
- data/lib/generators/templates/application/{merb → merb_core}/public/merb.fcgi +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/public/robots.txt +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/public/stylesheets/master.css +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/spec/spec.opts +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/spec/spec_helper.rb +0 -0
- data/lib/generators/templates/application/{merb → merb_core}/test/test_helper.rb +0 -0
- data/lib/generators/templates/application/merb_flat/application.rbt +1 -1
- data/lib/generators/templates/application/merb_flat/config/init.rb +8 -3
- data/lib/generators/templates/application/merb_plugin/LICENSE +1 -1
- data/lib/generators/templates/application/merb_stack/app/controllers/application.rb +2 -0
- data/lib/generators/templates/application/merb_stack/app/controllers/exceptions.rb +13 -0
- data/lib/generators/templates/application/merb_stack/app/helpers/global_helpers.rb +5 -0
- data/lib/generators/templates/application/merb_stack/app/models/user.rb +17 -0
- data/lib/generators/templates/application/merb_stack/app/views/exceptions/internal_server_error.html.erb +216 -0
- data/lib/generators/templates/application/merb_stack/app/views/exceptions/not_acceptable.html.erb +63 -0
- data/lib/generators/templates/application/merb_stack/app/views/exceptions/not_found.html.erb +47 -0
- data/lib/generators/templates/application/merb_stack/autotest/discover.rb +1 -0
- data/lib/generators/templates/application/merb_stack/autotest/merb.rb +149 -0
- data/lib/generators/templates/application/merb_stack/autotest/merb_rspec.rb +165 -0
- data/lib/generators/templates/application/merb_stack/config/database.yml +33 -0
- data/lib/generators/templates/application/merb_stack/config/dependencies.rb +15 -0
- data/lib/generators/templates/application/merb_stack/config/environments/development.rb +15 -0
- data/lib/generators/templates/application/merb_stack/config/environments/production.rb +10 -0
- data/lib/generators/templates/application/merb_stack/config/environments/rake.rb +11 -0
- data/lib/generators/templates/application/merb_stack/config/environments/staging.rb +10 -0
- data/lib/generators/templates/application/merb_stack/config/environments/test.rb +12 -0
- data/lib/generators/templates/application/merb_stack/config/init.rb +24 -0
- data/lib/generators/templates/application/merb_stack/config/rack.rb +12 -0
- data/lib/generators/templates/application/merb_stack/config/router.rb +44 -0
- data/lib/generators/templates/application/merb_stack/doc/rdoc/generators/merb_generator.rb +1362 -0
- data/lib/generators/templates/application/merb_stack/doc/rdoc/generators/template/merb/api_grease.js +640 -0
- data/lib/generators/templates/application/merb_stack/doc/rdoc/generators/template/merb/index.html.erb +37 -0
- data/lib/generators/templates/application/merb_stack/doc/rdoc/generators/template/merb/merb.css +252 -0
- data/lib/generators/templates/application/merb_stack/doc/rdoc/generators/template/merb/merb.rb +351 -0
- data/lib/generators/templates/application/merb_stack/doc/rdoc/generators/template/merb/merb_doc_styles.css +492 -0
- data/lib/generators/templates/application/merb_stack/doc/rdoc/generators/template/merb/prototype.js +2515 -0
- data/lib/generators/templates/application/merb_stack/merb/merb-auth/setup.rb +44 -0
- data/lib/generators/templates/application/merb_stack/merb/merb-auth/strategies.rb +11 -0
- data/lib/generators/templates/application/merb_stack/merb/session/session.rb +9 -0
- data/lib/generators/templates/application/merb_stack/public/favicon.ico +0 -0
- data/lib/generators/templates/application/merb_stack/public/images/merb.jpg +0 -0
- data/lib/generators/templates/application/merb_stack/public/javascripts/application.js +1 -0
- data/lib/generators/templates/application/merb_stack/public/merb.fcgi +22 -0
- data/lib/generators/templates/application/merb_stack/public/robots.txt +5 -0
- data/lib/generators/templates/application/merb_stack/public/stylesheets/master.css +119 -0
- data/lib/generators/templates/application/merb_stack/spec/spec.opts +0 -0
- data/lib/generators/templates/application/merb_stack/spec/spec_helper.rb +20 -0
- data/lib/generators/templates/application/merb_stack/test/test_helper.rb +19 -0
- data/lib/generators/templates/application/merb_very_flat/application.rbt +11 -5
- data/lib/generators/templates/component/layout/app/views/layout/%file_name%.html.erb +1 -0
- data/lib/generators/templates/component/resource_controller/spec/requests/%file_name%_spec.rb +53 -0
- data/lib/merb-gen/app_generator.rb +13 -0
- data/lib/merb-gen/generator.rb +36 -1
- data/lib/merb-gen/named_generator.rb +5 -2
- data/lib/merb-gen.rb +6 -8
- data/spec/controller_spec.rb +0 -20
- data/spec/{merb_full_spec.rb → merb_core_spec.rb} +11 -3
- data/spec/merb_stack_spec.rb +47 -0
- data/spec/part_controller_spec.rb +0 -39
- data/spec/resource_controller_spec.rb +1 -35
- data/spec/spec_helper.rb +4 -2
- metadata +133 -111
- data/lib/generators/merb/merb_full.rb +0 -85
- data/lib/generators/merb.rb +0 -24
- data/lib/generators/templates/application/merb/config/environments/staging.rb +0 -7
- data/lib/generators/templates/application/merb/config/environments/test.rb +0 -7
- data/lib/generators/templates/component/helper/spec/helpers/%file_name%_helper_spec.rb +0 -5
- data/lib/generators/templates/component/resource_controller/spec/controllers/%file_name%_spec.rb +0 -7
- data/spec/helper_spec.rb +0 -43
- data/spec/merb_spec.rb +0 -20
data/README
CHANGED
|
@@ -6,10 +6,13 @@ generators for Merb.
|
|
|
6
6
|
==== Usage
|
|
7
7
|
|
|
8
8
|
To generate directory structure for a new merb app, run merb-gen app <app-name>.
|
|
9
|
-
For instance, <tt>merb-gen app foo</tt> would create a new foo merb
|
|
9
|
+
For instance, <tt>merb-gen app foo</tt> would create a new foo merb stack application
|
|
10
|
+
inside of the foo directory. Merb stack sets up commonly used Merb and DataMapper gems
|
|
11
|
+
to quickly get you started.
|
|
10
12
|
|
|
11
|
-
Use <tt
|
|
12
|
-
|
|
13
|
+
Use <tt>merb-gen core</tt> to generate minimal merb-core application with full layout.
|
|
14
|
+
Use <tt>merb-gen flat</tt> to generate a flattened application (very simple directory structure)
|
|
15
|
+
and <tt>merb-gen very-flat</tt> to generate a single file application.
|
|
13
16
|
|
|
14
17
|
To generate a new merb plugin, run merb-gen plugin <plugin_name>.
|
|
15
18
|
|
data/Rakefile
CHANGED
|
@@ -4,6 +4,8 @@ require "extlib"
|
|
|
4
4
|
require 'merb-core/tasks/merb_rake_helper'
|
|
5
5
|
require "spec/rake/spectask"
|
|
6
6
|
|
|
7
|
+
require File.join(File.dirname(__FILE__), "../merb-core/lib/merb-core/version.rb")
|
|
8
|
+
|
|
7
9
|
##############################################################################
|
|
8
10
|
# Package && release
|
|
9
11
|
##############################################################################
|
|
@@ -17,7 +19,7 @@ GEM_EMAIL = "jonas.nicklas@gmail.com"
|
|
|
17
19
|
|
|
18
20
|
GEM_NAME = "merb-gen"
|
|
19
21
|
PKG_BUILD = ENV['PKG_BUILD'] ? '.' + ENV['PKG_BUILD'] : ''
|
|
20
|
-
GEM_VERSION =
|
|
22
|
+
GEM_VERSION = Merb::VERSION + PKG_BUILD
|
|
21
23
|
|
|
22
24
|
RELEASE_NAME = "REL #{GEM_VERSION}"
|
|
23
25
|
|
|
@@ -38,11 +40,11 @@ spec = Gem::Specification.new do |s|
|
|
|
38
40
|
s.bindir = "bin"
|
|
39
41
|
s.executables = %w( merb-gen )
|
|
40
42
|
|
|
41
|
-
s.add_dependency "merb-core", ">= 0.9.
|
|
42
|
-
s.add_dependency "templater", ">= 0.3.
|
|
43
|
+
s.add_dependency "merb-core", ">= 0.9.9"
|
|
44
|
+
s.add_dependency "templater", ">= 0.3.3"
|
|
43
45
|
|
|
44
46
|
s.require_path = 'lib'
|
|
45
|
-
s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,bin,spec}/**/*")
|
|
47
|
+
s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,bin,spec,merb}/**/*")
|
|
46
48
|
end
|
|
47
49
|
|
|
48
50
|
Rake::GemPackageTask.new(spec) do |pkg|
|
data/bin/merb-gen
CHANGED
|
@@ -3,26 +3,4 @@
|
|
|
3
3
|
require 'rubygems'
|
|
4
4
|
require 'merb-gen'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
Merb::Generators.run_cli(Dir.pwd, 'merb-gen', Merb::VERSION, ARGV)
|
|
8
|
-
else
|
|
9
|
-
Merb::BootLoader.after_app_loads do
|
|
10
|
-
Merb::Generators.run_cli(Dir.pwd, 'merb-gen', Merb::VERSION, ARGV)
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
Merb::Config.setup({
|
|
14
|
-
:log_level => :fatal,
|
|
15
|
-
:log_delimiter => " ~ ",
|
|
16
|
-
:log_auto_flush => false,
|
|
17
|
-
:reload_templates => false,
|
|
18
|
-
:reload_classes => false
|
|
19
|
-
})
|
|
20
|
-
|
|
21
|
-
Merb::BootLoader::Logger.run
|
|
22
|
-
Merb::BootLoader::BuildFramework.run
|
|
23
|
-
Merb::BootLoader::Dependencies.run
|
|
24
|
-
|
|
25
|
-
Merb::BootLoader::BeforeAppLoads.run
|
|
26
|
-
Merb::BootLoader::ReloadClasses.run
|
|
27
|
-
Merb::BootLoader::AfterAppLoads.run
|
|
28
|
-
end
|
|
6
|
+
Merb::Generators.run_cli(Dir.pwd, 'merb-gen', Merb::VERSION, ARGV)
|
|
@@ -36,9 +36,11 @@ module Merb::Generators
|
|
|
36
36
|
template.source = 'test/controllers/%file_name%_test.rb'
|
|
37
37
|
template.destination = "test/controllers" / base_path / "#{file_name}_test.rb"
|
|
38
38
|
end
|
|
39
|
-
|
|
39
|
+
|
|
40
|
+
def after_generation
|
|
41
|
+
STDOUT.puts "\n\nDon't forget to add request/controller tests first."
|
|
42
|
+
end
|
|
40
43
|
end
|
|
41
44
|
|
|
42
45
|
add :controller, ControllerGenerator
|
|
43
|
-
|
|
44
46
|
end
|
data/lib/generators/helper.rb
CHANGED
|
@@ -19,11 +19,6 @@ module Merb::Generators
|
|
|
19
19
|
template.destination = "app/helpers" / base_path / "#{file_name}_helper.rb"
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
template :helper_spec, :testing_framework => :rspec do |template|
|
|
23
|
-
template.source = 'spec/helpers/%file_name%_helper_spec.rb'
|
|
24
|
-
template.destination = "spec/helpers" / base_path / "#{file_name}_helper_spec.rb"
|
|
25
|
-
end
|
|
26
|
-
|
|
27
22
|
end
|
|
28
23
|
|
|
29
24
|
add :helper, HelperGenerator
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
module Merb
|
|
2
|
+
module Generators
|
|
3
|
+
class MerbCoreGenerator < AppGenerator
|
|
4
|
+
#
|
|
5
|
+
# ==== Paths
|
|
6
|
+
#
|
|
7
|
+
|
|
8
|
+
def self.source_root
|
|
9
|
+
File.join(super, 'application', 'merb_core')
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.common_templates_dir
|
|
13
|
+
File.expand_path(File.join(File.dirname(__FILE__), '..',
|
|
14
|
+
'templates', 'application', 'common'))
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def destination_root
|
|
18
|
+
File.join(@destination_root, base_name)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def common_templates_dir
|
|
22
|
+
self.class.common_templates_dir
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
#
|
|
26
|
+
# ==== Generator options
|
|
27
|
+
#
|
|
28
|
+
|
|
29
|
+
option :testing_framework, :default => :rspec,
|
|
30
|
+
:desc => 'Testing framework to use (one of: rspec, test_unit).'
|
|
31
|
+
option :orm, :default => :none,
|
|
32
|
+
:desc => 'Object-Relation Mapper to use (one of: none, activerecord, datamapper, sequel).'
|
|
33
|
+
option :template_engine, :default => :erb,
|
|
34
|
+
:desc => 'Template engine to prefer for this application (one of: erb, haml).'
|
|
35
|
+
|
|
36
|
+
desc <<-DESC
|
|
37
|
+
This generates a Merb application with Ruby on Rails like structure.
|
|
38
|
+
Generator lets you configure your ORM and testing framework of choice.
|
|
39
|
+
DESC
|
|
40
|
+
|
|
41
|
+
first_argument :name, :required => true, :desc => "Application name"
|
|
42
|
+
|
|
43
|
+
#
|
|
44
|
+
# ==== Common directories & files
|
|
45
|
+
#
|
|
46
|
+
|
|
47
|
+
empty_directory :gems, 'gems'
|
|
48
|
+
file :thorfile do |file|
|
|
49
|
+
file.source = File.join(common_templates_dir, "merb.thor")
|
|
50
|
+
file.destination = "merb.thor"
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
template :rakefile do |template|
|
|
54
|
+
template.source = File.join(common_templates_dir, "Rakefile")
|
|
55
|
+
template.destination = "Rakefile"
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
file :gitignore do |file|
|
|
59
|
+
file.source = File.join(common_templates_dir, 'dotgitignore')
|
|
60
|
+
file.destination = ".gitignore"
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
file :htaccess do |file|
|
|
64
|
+
file.source = File.join(common_templates_dir, 'dothtaccess')
|
|
65
|
+
file.destination = 'public/.htaccess'
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
directory :test_dir do |directory|
|
|
69
|
+
dir = testing_framework == :rspec ? "spec" : "test"
|
|
70
|
+
|
|
71
|
+
directory.source = File.join(source_root, dir)
|
|
72
|
+
directory.destination = dir
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
#
|
|
76
|
+
# ==== Layout specific things
|
|
77
|
+
#
|
|
78
|
+
|
|
79
|
+
# empty array means all files are considered to be just
|
|
80
|
+
# files, not templates
|
|
81
|
+
glob! "app"
|
|
82
|
+
glob! "autotest"
|
|
83
|
+
glob! "config"
|
|
84
|
+
glob! "doc", []
|
|
85
|
+
glob! "public"
|
|
86
|
+
|
|
87
|
+
invoke :layout do |generator|
|
|
88
|
+
generator.new(destination_root, options, 'application')
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
add :core, MerbCoreGenerator
|
|
93
|
+
|
|
94
|
+
end
|
|
95
|
+
end
|
|
@@ -1,90 +1,91 @@
|
|
|
1
|
-
module Merb
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
1
|
+
module Merb
|
|
2
|
+
module Generators
|
|
3
|
+
class MerbFlatGenerator < AppGenerator
|
|
4
|
+
#
|
|
5
|
+
# ==== Paths
|
|
6
|
+
#
|
|
7
|
+
|
|
8
|
+
def self.source_root
|
|
9
|
+
File.join(super, 'application', 'merb_flat')
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.common_templates_dir
|
|
13
|
+
File.expand_path(File.join(File.dirname(__FILE__), '..',
|
|
14
|
+
'templates', 'application', 'common'))
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def destination_root
|
|
18
|
+
File.join(@destination_root, base_name)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def common_templates_dir
|
|
22
|
+
self.class.common_templates_dir
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
#
|
|
26
|
+
# ==== Generator options
|
|
27
|
+
#
|
|
28
|
+
|
|
29
|
+
option :testing_framework, :default => :rspec,
|
|
30
|
+
:desc => 'Testing framework to use (one of: rspec, test_unit).'
|
|
31
|
+
option :orm, :default => :none,
|
|
32
|
+
:desc => 'Object-Relation Mapper to use (one of: none, activerecord, datamapper, sequel).'
|
|
33
|
+
option :template_engine, :default => :erb,
|
|
34
|
+
:desc => 'Template engine to prefer for this application (one of: erb, haml).'
|
|
35
|
+
|
|
36
|
+
desc <<-DESC
|
|
36
37
|
This generates a flat merb application: all code but config files and
|
|
37
38
|
templates fits in one application. This is something in between Sinatra
|
|
38
39
|
and "regular" Merb application.
|
|
39
40
|
DESC
|
|
40
41
|
|
|
41
|
-
|
|
42
|
+
first_argument :name, :required => true, :desc => "Application name"
|
|
42
43
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
#
|
|
45
|
+
# ==== Common directories & files
|
|
46
|
+
#
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
empty_directory :gems, 'gems'
|
|
49
|
+
file :thorfile do |file|
|
|
50
|
+
file.source = File.join(common_templates_dir, "merb.thor")
|
|
51
|
+
file.destination = "merb.thor"
|
|
52
|
+
end
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
template :rakefile do |template|
|
|
55
|
+
template.source = File.join(common_templates_dir, "Rakefile")
|
|
56
|
+
template.destination = "Rakefile"
|
|
57
|
+
end
|
|
57
58
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
59
|
+
file :gitignore do |file|
|
|
60
|
+
file.source = File.join(common_templates_dir, 'dotgitignore')
|
|
61
|
+
file.destination = ".gitignore"
|
|
62
|
+
end
|
|
62
63
|
|
|
63
|
-
|
|
64
|
-
|
|
64
|
+
directory :test_dir do |directory|
|
|
65
|
+
dir = testing_framework == :rspec ? "spec" : "test"
|
|
65
66
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
directory.source = File.join(source_root, dir)
|
|
68
|
+
directory.destination = dir
|
|
69
|
+
end
|
|
69
70
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
#
|
|
72
|
+
# ==== Layout specific things
|
|
73
|
+
#
|
|
73
74
|
|
|
74
|
-
|
|
75
|
+
file :readme, "README.txt"
|
|
75
76
|
|
|
76
|
-
|
|
77
|
+
template :application, "application.rb"
|
|
77
78
|
|
|
78
|
-
|
|
79
|
-
|
|
79
|
+
glob! "config"
|
|
80
|
+
glob! "views"
|
|
80
81
|
|
|
81
|
-
|
|
82
|
-
|
|
82
|
+
def class_name
|
|
83
|
+
self.name.gsub("-", "_").camel_case
|
|
84
|
+
end
|
|
83
85
|
end
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
add_private :app_flat, MerbFlatGenerator
|
|
87
86
|
|
|
87
|
+
add :flat, MerbFlatGenerator
|
|
88
|
+
end
|
|
88
89
|
end
|
|
89
90
|
|
|
90
91
|
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
module Merb
|
|
2
|
+
module Generators
|
|
3
|
+
class MerbStackGenerator < AppGenerator
|
|
4
|
+
#
|
|
5
|
+
# ==== Paths
|
|
6
|
+
#
|
|
7
|
+
|
|
8
|
+
def self.source_root
|
|
9
|
+
File.join(super, 'application', 'merb_stack')
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.common_templates_dir
|
|
13
|
+
File.expand_path(File.join(File.dirname(__FILE__), '..',
|
|
14
|
+
'templates', 'application', 'common'))
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def destination_root
|
|
18
|
+
File.join(@destination_root, base_name)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def common_templates_dir
|
|
22
|
+
self.class.common_templates_dir
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def testing_framework
|
|
26
|
+
:rspec
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def orm
|
|
30
|
+
:datamapper
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
#
|
|
34
|
+
# ==== Generator options
|
|
35
|
+
#
|
|
36
|
+
|
|
37
|
+
option :template_engine, :default => :erb,
|
|
38
|
+
:desc => 'Template engine to prefer for this application (one of: erb, haml).'
|
|
39
|
+
|
|
40
|
+
desc <<-DESC
|
|
41
|
+
This generates a "prepackaged" (or "opinionated") Merb application that uses DataMapper,
|
|
42
|
+
RSpec, helpers, assets, mailer, caching, slices and merb-auth all out of the box.
|
|
43
|
+
DESC
|
|
44
|
+
|
|
45
|
+
first_argument :name, :required => true, :desc => "Application name"
|
|
46
|
+
|
|
47
|
+
#
|
|
48
|
+
# ==== Common directories & files
|
|
49
|
+
#
|
|
50
|
+
|
|
51
|
+
empty_directory :gems, 'gems'
|
|
52
|
+
file :thorfile do |file|
|
|
53
|
+
file.source = File.join(common_templates_dir, "merb.thor")
|
|
54
|
+
file.destination = "tasks/merb.thor"
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
template :rakefile do |template|
|
|
58
|
+
template.source = File.join(common_templates_dir, "Rakefile")
|
|
59
|
+
template.destination = "Rakefile"
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
file :gitignore do |file|
|
|
63
|
+
file.source = File.join(common_templates_dir, 'dotgitignore')
|
|
64
|
+
file.destination = ".gitignore"
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
file :htaccess do |file|
|
|
68
|
+
file.source = File.join(common_templates_dir, 'dothtaccess')
|
|
69
|
+
file.destination = 'public/.htaccess'
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
file :doctask do |file|
|
|
73
|
+
file.source = File.join(common_templates_dir, 'doc.thor')
|
|
74
|
+
file.destination = 'tasks/doc.thor'
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
file :jquery do |file|
|
|
78
|
+
file.source = File.join(common_templates_dir, 'jquery.js')
|
|
79
|
+
file.destination = 'public/javascripts/jquery.js'
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
directory :test_dir do |directory|
|
|
83
|
+
dir = testing_framework == :rspec ? "spec" : "test"
|
|
84
|
+
|
|
85
|
+
directory.source = File.join(source_root, dir)
|
|
86
|
+
directory.destination = dir
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
#
|
|
90
|
+
# ==== Layout specific things
|
|
91
|
+
#
|
|
92
|
+
|
|
93
|
+
# empty array means all files are considered to be just
|
|
94
|
+
# files, not templates
|
|
95
|
+
glob! "app"
|
|
96
|
+
glob! "autotest"
|
|
97
|
+
glob! "config"
|
|
98
|
+
glob! "doc", []
|
|
99
|
+
glob! "public"
|
|
100
|
+
glob! "lib"
|
|
101
|
+
glob! "merb"
|
|
102
|
+
|
|
103
|
+
invoke :layout do |generator|
|
|
104
|
+
generator.new(destination_root, options, 'application')
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
add :app, MerbStackGenerator
|
|
109
|
+
end
|
|
110
|
+
end
|
|
@@ -1,72 +1,69 @@
|
|
|
1
|
-
module Merb
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
desc <<-DESC
|
|
1
|
+
module Merb
|
|
2
|
+
module Generators
|
|
3
|
+
class MerbVeryFlatGenerator < AppGenerator
|
|
4
|
+
def self.source_root
|
|
5
|
+
File.join(super, 'application', 'merb_very_flat')
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def self.common_templates_dir
|
|
9
|
+
File.expand_path(File.join(File.dirname(__FILE__), '..',
|
|
10
|
+
'templates', 'application', 'common'))
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def destination_root
|
|
14
|
+
File.join(@destination_root, base_name)
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
def common_templates_dir
|
|
18
|
+
File.expand_path(File.join(File.dirname(__FILE__), '..',
|
|
19
|
+
'templates', 'application', 'common'))
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
option :testing_framework, :default => :rspec,
|
|
23
|
+
:desc => 'Testing framework to use (one of: rspec, test_unit).'
|
|
24
|
+
option :orm, :default => :none,
|
|
25
|
+
:desc => 'Object-Relation Mapper to use (one of: none, activerecord, datamapper, sequel).'
|
|
26
|
+
option :template_engine, :default => :erb,
|
|
27
|
+
:desc => 'Template engine to prefer for this application (one of: erb, haml).'
|
|
28
|
+
|
|
29
|
+
desc <<-DESC
|
|
33
30
|
This generates a very flat merb application: the whole application
|
|
34
31
|
fits in one file, very much like Sinatra or Camping.
|
|
35
32
|
DESC
|
|
36
33
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
34
|
+
first_argument :name, :required => true, :desc => "Application name"
|
|
35
|
+
|
|
36
|
+
template :application do |template|
|
|
37
|
+
template.source = 'application.rbt'
|
|
38
|
+
template.destination = "#{base_name}.rb"
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
file :gitignore do |file|
|
|
42
|
+
file.source = File.join(common_templates_dir, 'dotgitignore')
|
|
43
|
+
file.destination = ".gitignore"
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
directory :test_dir do |directory|
|
|
47
|
+
dir = testing_framework == :rspec ? "spec" : "test"
|
|
48
|
+
directory.source = dir
|
|
49
|
+
directory.destination = dir
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
template :rakefile do |template|
|
|
53
|
+
template.source = File.join(common_templates_dir, "Rakefile")
|
|
54
|
+
template.destination = "Rakefile"
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
file :thorfile do |file|
|
|
58
|
+
file.source = File.join(common_templates_dir, "merb.thor")
|
|
59
|
+
file.destination = "merb.thor"
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def class_name
|
|
63
|
+
self.name.gsub("-", "_").camel_case
|
|
64
|
+
end
|
|
54
65
|
end
|
|
55
66
|
|
|
56
|
-
|
|
57
|
-
template.source = File.join(common_templates_dir, "Rakefile")
|
|
58
|
-
template.destination = "Rakefile"
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
file :thorfile do |file|
|
|
62
|
-
file.source = File.join(common_templates_dir, "merb.thor")
|
|
63
|
-
file.destination = "merb.thor"
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def class_name
|
|
67
|
-
self.name.gsub("-", "_").camel_case
|
|
68
|
-
end
|
|
67
|
+
add :very_flat, MerbVeryFlatGenerator
|
|
69
68
|
end
|
|
70
|
-
|
|
71
|
-
add_private :app_very_flat, MerbVeryFlatGenerator
|
|
72
69
|
end
|
data/lib/generators/model.rb
CHANGED
|
@@ -2,6 +2,7 @@ module Merb::Generators
|
|
|
2
2
|
|
|
3
3
|
class ModelGenerator < NamespacedGenerator
|
|
4
4
|
|
|
5
|
+
|
|
5
6
|
def self.source_root
|
|
6
7
|
File.join(super, 'component', 'model')
|
|
7
8
|
end
|
|
@@ -39,9 +40,11 @@ module Merb::Generators
|
|
|
39
40
|
def attributes_for_accessor
|
|
40
41
|
self.attributes.keys.map{|a| ":#{a}" }.compact.uniq.join(", ")
|
|
41
42
|
end
|
|
42
|
-
|
|
43
|
+
|
|
44
|
+
def after_generation
|
|
45
|
+
STDOUT.puts "\n\nDon't forget to add model tests first."
|
|
46
|
+
end
|
|
43
47
|
end
|
|
44
48
|
|
|
45
49
|
add :model, ModelGenerator
|
|
46
|
-
|
|
47
50
|
end
|
data/lib/generators/resource.rb
CHANGED
|
@@ -8,6 +8,9 @@ module Merb::Generators
|
|
|
8
8
|
|
|
9
9
|
first_argument :name, :required => true, :desc => "resource name (singular)"
|
|
10
10
|
second_argument :attributes, :as => :hash, :default => {}, :desc => "space separated resource model properties in form of name:type. Example: state:string"
|
|
11
|
+
|
|
12
|
+
option :testing_framework, :desc => 'Testing framework to use (one of: rspec, test_unit)'
|
|
13
|
+
option :orm, :desc => 'Object-Relation Mapper to use (one of: none, activerecord, datamapper, sequel)'
|
|
11
14
|
|
|
12
15
|
invoke :model do |generator|
|
|
13
16
|
generator.new(destination_root, options, model_name, attributes)
|
|
@@ -24,9 +27,11 @@ module Merb::Generators
|
|
|
24
27
|
def model_name
|
|
25
28
|
name
|
|
26
29
|
end
|
|
27
|
-
|
|
30
|
+
|
|
31
|
+
def after_generation
|
|
32
|
+
STDOUT << message("Don't forget to set your resource route in config/router.rb for instance: resources :#{model_name.downcase}s ")
|
|
33
|
+
end
|
|
28
34
|
end
|
|
29
35
|
|
|
30
36
|
add :resource, ResourceGenerator
|
|
31
|
-
|
|
32
37
|
end
|