merb-gen 0.9.3 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README +14 -2
- data/Rakefile +43 -27
- data/TODO +13 -0
- data/bin/merb-gen +5 -93
- data/lib/generators/controller.rb +44 -0
- data/lib/generators/freezer.rb +19 -0
- data/lib/generators/helper.rb +31 -0
- data/lib/generators/layout.rb +27 -0
- data/lib/generators/merb.rb +24 -0
- data/lib/generators/merb/merb_flat.rb +27 -0
- data/lib/generators/merb/merb_full.rb +35 -0
- data/lib/generators/merb/merb_very_flat.rb +29 -0
- data/lib/generators/merb_plugin.rb +29 -0
- data/lib/generators/migration.rb +54 -0
- data/lib/generators/model.rb +47 -0
- data/lib/generators/part_controller.rb +33 -0
- data/lib/generators/resource.rb +32 -0
- data/lib/generators/resource_controller.rb +78 -0
- data/lib/generators/session_migration.rb +34 -0
- data/lib/generators/templates/application/merb/Rakefile +75 -0
- data/{app_generators/merb/templates → lib/generators/templates/application/merb}/app/controllers/application.rb +0 -0
- data/{app_generators/merb/templates → lib/generators/templates/application/merb}/app/controllers/exceptions.rb +0 -0
- data/{app_generators/merb/templates → lib/generators/templates/application/merb}/app/helpers/global_helpers.rb +0 -0
- data/{app_generators/merb/templates → lib/generators/templates/application/merb}/app/views/exceptions/internal_server_error.html.erb +1 -1
- data/{app_generators/merb/templates → lib/generators/templates/application/merb}/app/views/exceptions/not_acceptable.html.erb +0 -0
- data/{app_generators/merb/templates → lib/generators/templates/application/merb}/app/views/exceptions/not_found.html.erb +0 -0
- data/{app_generators/merb/templates → lib/generators/templates/application/merb}/autotest/discover.rb +0 -0
- data/{app_generators/merb/templates → lib/generators/templates/application/merb}/autotest/merb.rb +2 -2
- data/lib/generators/templates/application/merb/autotest/merb_rspec.rb +166 -0
- data/{app_generators/merb/templates → lib/generators/templates/application/merb}/config/environments/development.rb +0 -0
- data/{app_generators/merb/templates → lib/generators/templates/application/merb}/config/environments/production.rb +0 -0
- data/{app_generators/merb/templates → lib/generators/templates/application/merb}/config/environments/rake.rb +0 -0
- data/{app_generators/merb/templates → lib/generators/templates/application/merb}/config/environments/test.rb +0 -0
- data/{app_generators/merb/templates → lib/generators/templates/application/merb}/config/init.rb +38 -27
- data/lib/generators/templates/application/merb/config/rack.rb +12 -0
- data/{app_generators/merb/templates → lib/generators/templates/application/merb}/config/router.rb +0 -0
- data/{app_generators/merb/templates → lib/generators/templates/application/merb}/public/images/merb.jpg +0 -0
- data/{app_generators/merb/templates → lib/generators/templates/application/merb}/public/merb.fcgi +0 -0
- data/{app_generators/merb/templates → lib/generators/templates/application/merb}/public/stylesheets/master.css +0 -0
- data/{app_generators/merb/templates → lib/generators/templates/application/merb}/spec/spec.opts +0 -0
- data/{app_generators/merb/templates → lib/generators/templates/application/merb}/spec/spec_helper.rb +3 -1
- data/{app_generators/merb/templates → lib/generators/templates/application/merb}/test/test_helper.rb +0 -0
- data/{app_generators/merb_flat/templates → lib/generators/templates/application/merb_flat}/README.txt +0 -0
- data/{app_generators/merb_flat/templates → lib/generators/templates/application/merb_flat}/application.rb +0 -0
- data/lib/generators/templates/application/merb_flat/config/framework.rb +7 -0
- data/{app_generators/merb_flat/templates → lib/generators/templates/application/merb_flat}/config/init.rb +0 -1
- data/{app_generators/merb_flat/templates → lib/generators/templates/application/merb_flat}/views/foo.html.erb +0 -0
- data/{app_generators/merb_plugin/templates → lib/generators/templates/application/merb_plugin}/LICENSE +0 -0
- data/{app_generators/merb_plugin/templates → lib/generators/templates/application/merb_plugin}/README +0 -0
- data/lib/generators/templates/application/merb_plugin/Rakefile +59 -0
- data/{app_generators/merb_plugin/templates → lib/generators/templates/application/merb_plugin}/TODO +0 -0
- data/{app_generators/merb_plugin/templates → lib/generators/templates/application/merb_plugin}/lib/%base_name%.rb +1 -1
- data/{app_generators/merb_plugin/templates → lib/generators/templates/application/merb_plugin}/lib/%base_name%/merbtasks.rb +1 -1
- data/{app_generators/merb_plugin/templates → lib/generators/templates/application/merb_plugin}/spec/%base_name%_spec.rb +0 -0
- data/{app_generators/merb_plugin/templates → lib/generators/templates/application/merb_plugin}/spec/spec_helper.rb +0 -0
- data/{app_generators/merb_plugin/templates → lib/generators/templates/application/merb_plugin}/test/%base_name%_test.rb +0 -0
- data/{app_generators/merb_plugin/templates → lib/generators/templates/application/merb_plugin}/test/test_helper.rb +0 -0
- data/lib/generators/templates/application/merb_very_flat/application.rbt +17 -0
- data/lib/generators/templates/component/controller/app/controllers/%file_name%.rb +11 -0
- data/lib/generators/templates/component/controller/app/views/%file_name%/index.html.erb +1 -0
- data/lib/generators/templates/component/controller/spec/controllers/%file_name%_spec.rb +7 -0
- data/lib/generators/templates/component/controller/test/controllers/%file_name%_test.rb +17 -0
- data/lib/generators/templates/component/freezer/script/frozen_merb +43 -0
- data/lib/generators/templates/component/helper/app/helpers/%file_name%_helper.rb +7 -0
- data/lib/generators/templates/component/helper/spec/helpers/%file_name%_helper_spec.rb +5 -0
- data/{app_generators/merb/templates/app/views/layout/application.html.erb → lib/generators/templates/component/layout/app/views/layout/%file_name%.html.erb} +0 -0
- data/lib/generators/templates/component/layout/spec/views/layout/%file_name%.html.erb_spec.rb +1 -0
- data/lib/generators/templates/component/model/app/models/%file_name%.rb +7 -0
- data/lib/generators/templates/component/model/spec/models/%file_name%_spec.rb +7 -0
- data/lib/generators/templates/component/model/test/models/%file_name%_test.rb +9 -0
- data/lib/generators/templates/component/part_controller/app/parts/%file_name%_part.rb +9 -0
- data/lib/generators/templates/component/part_controller/app/parts/views/%file_name%_part/index.html.erb +3 -0
- data/lib/generators/templates/component/resource_controller/app/controllers/%file_name%.rb +44 -0
- data/lib/generators/templates/component/resource_controller/app/views/%file_name%/edit.html.erb +3 -0
- data/lib/generators/templates/component/resource_controller/app/views/%file_name%/index.html.erb +3 -0
- data/lib/generators/templates/component/resource_controller/app/views/%file_name%/new.html.erb +3 -0
- data/lib/generators/templates/component/resource_controller/app/views/%file_name%/show.html.erb +3 -0
- data/lib/generators/templates/component/resource_controller/spec/controllers/%file_name%_spec.rb +7 -0
- data/lib/generators/templates/component/resource_controller/test/controllers/%file_name%_test.rb +17 -0
- data/lib/merb-gen.rb +34 -36
- data/lib/merb-gen/generator.rb +54 -0
- data/lib/merb-gen/named_generator.rb +33 -0
- data/lib/merb-gen/namespaced_generator.rb +47 -0
- data/lib/merb-gen/spec_helper.rb +65 -0
- data/spec/controller_spec.rb +106 -0
- data/spec/fixtures/results/no_modules.test +1 -0
- data/spec/fixtures/results/some_modules.test +5 -0
- data/spec/fixtures/templates/no_modules.test +3 -0
- data/spec/fixtures/templates/some_modules.test +3 -0
- data/spec/freezer_spec.rb +17 -0
- data/spec/generator_spec.rb +51 -0
- data/spec/helper_spec.rb +43 -0
- data/spec/layout_spec.rb +25 -0
- data/spec/merb_flat_spec.rb +21 -0
- data/spec/merb_full_spec.rb +31 -0
- data/spec/merb_plugin_spec.rb +21 -0
- data/spec/merb_spec.rb +20 -0
- data/spec/merb_very_flat_spec.rb +19 -0
- data/spec/migration_spec.rb +47 -0
- data/spec/model_spec.rb +66 -0
- data/spec/named_generator_spec.rb +11 -0
- data/spec/namespaced_generator_spec.rb +11 -0
- data/spec/part_controller_spec.rb +74 -0
- data/spec/resource_controller_spec.rb +102 -0
- data/spec/resource_spec.rb +18 -0
- data/spec/session_migration_spec.rb +15 -0
- data/spec/spec_helper.rb +271 -0
- metadata +246 -181
- data/app_generators/merb/USAGE +0 -0
- data/app_generators/merb/merb_generator.rb +0 -40
- data/app_generators/merb/templates/Rakefile +0 -34
- data/app_generators/merb/templates/autotest/merb_rspec.rb +0 -223
- data/app_generators/merb/templates/config/rack.rb +0 -1
- data/app_generators/merb_flat/merb_flat_generator.rb +0 -22
- data/app_generators/merb_flat/templates/config/framework.rb +0 -5
- data/app_generators/merb_plugin/merb_plugin_generator.rb +0 -22
- data/app_generators/merb_plugin/templates/Rakefile +0 -44
- data/app_generators/merb_very_flat/merb_very_flat_generator.rb +0 -37
- data/app_generators/merb_very_flat/templates/%app_file_name%.rb +0 -15
- data/app_generators/merb_very_flat/templates/README.txt +0 -9
- data/lib/merb-gen/base.rb +0 -66
- data/lib/merb-gen/helpers.rb +0 -108
- data/merb_default_generators/model/USAGE +0 -0
- data/merb_default_generators/model/model_generator.rb +0 -40
- data/merb_default_generators/model/templates/app/models/%model_file_name%.rb +0 -5
- data/merb_default_generators/resource_controller/USAGE +0 -0
- data/merb_default_generators/resource_controller/resource_controller_generator.rb +0 -74
- data/merb_default_generators/resource_controller/templates/app/controllers/%controller_file_name%.rb +0 -46
- data/merb_default_generators/resource_controller/templates/app/helpers/%controller_file_name%_helper.rb +0 -16
- data/merb_default_generators/resource_controller/templates/app/views/%controller_file_name%/delete.html.erb +0 -3
- data/merb_default_generators/resource_controller/templates/app/views/%controller_file_name%/edit.html.erb +0 -3
- data/merb_default_generators/resource_controller/templates/app/views/%controller_file_name%/index.html.erb +0 -3
- data/merb_default_generators/resource_controller/templates/app/views/%controller_file_name%/new.html.erb +0 -3
- data/merb_default_generators/resource_controller/templates/app/views/%controller_file_name%/show.html.erb +0 -3
- data/merb_generators/controller/USAGE +0 -0
- data/merb_generators/controller/controller_generator.rb +0 -59
- data/merb_generators/controller/templates/app/controllers/%controller_file_name%.rb +0 -18
- data/merb_generators/controller/templates/app/helpers/%controller_file_name%_helper.rb +0 -16
- data/merb_generators/controller/templates/app/views/%controller_file_name%/index.html.erb +0 -1
- data/merb_generators/part_controller/USAGE +0 -0
- data/merb_generators/part_controller/part_controller_generator.rb +0 -58
- data/merb_generators/part_controller/templates/app/helpers/%controller_file_name%_part_helper.rb +0 -16
- data/merb_generators/part_controller/templates/app/parts/%controller_file_name%_part.rb +0 -18
- data/merb_generators/part_controller/templates/app/parts/views/%controller_file_name%_part/index.html.erb +0 -3
- data/merb_generators/resource/USAGE +0 -0
- data/merb_generators/resource/resource_generator.rb +0 -48
- data/rspec_generators/merb_controller_test/merb_controller_test_generator.rb +0 -49
- data/rspec_generators/merb_controller_test/templates/spec/controllers/%controller_full_file_path%_spec.rb +0 -7
- data/rspec_generators/merb_controller_test/templates/spec/helpers/%controller_full_file_path%_helper_spec.rb +0 -5
- data/rspec_generators/merb_model_test/merb_model_test_generator.rb +0 -35
- data/rspec_generators/merb_model_test/templates/spec/models/%model_file_name%_spec.rb +0 -7
- data/rspec_generators/merb_resource_controller_test/merb_resource_controller_test_generator.rb +0 -49
- data/rspec_generators/merb_resource_controller_test/templates/spec/controllers/%controller_full_file_path%_spec.rb +0 -7
- data/rspec_generators/merb_resource_controller_test/templates/spec/helpers/%controller_full_file_path%_helpers.rb +0 -5
- data/rspec_generators/merb_resource_controller_test/templates/spec/views/%controller_full_file_path%/delete.html.erb_spec.rb +0 -1
- data/rspec_generators/merb_resource_controller_test/templates/spec/views/%controller_full_file_path%/edit.html.erb_spec.rb +0 -1
- data/rspec_generators/merb_resource_controller_test/templates/spec/views/%controller_full_file_path%/index.html.erb_spec.rb +0 -1
- data/rspec_generators/merb_resource_controller_test/templates/spec/views/%controller_full_file_path%/new.html.erb_spec.rb +0 -1
- data/rspec_generators/merb_resource_controller_test/templates/spec/views/%controller_full_file_path%/show.html.erb_spec.rb +0 -1
- data/test_unit_generators/merb_controller_test/merb_controller_test_generator.rb +0 -47
- data/test_unit_generators/merb_controller_test/templates/test/functional/%controller_full_file_path%_test.rb +0 -17
- data/test_unit_generators/merb_model_test/merb_model_test_generator.rb +0 -34
- data/test_unit_generators/merb_model_test/templates/test/unit/%model_file_name%_test.rb +0 -9
- data/test_unit_generators/merb_resource_controller_test/merb_resource_controller_test_generator.rb +0 -31
data/app_generators/merb/USAGE
DELETED
File without changes
|
@@ -1,40 +0,0 @@
|
|
1
|
-
require "merb-gen/helpers"
|
2
|
-
require "merb-gen/base"
|
3
|
-
|
4
|
-
class MerbGenerator < Merb::GeneratorBase
|
5
|
-
|
6
|
-
def initialize(args, runtime_options = {})
|
7
|
-
@base = File.dirname(__FILE__)
|
8
|
-
@name = args.first
|
9
|
-
super
|
10
|
-
@destination_root = @name
|
11
|
-
end
|
12
|
-
|
13
|
-
protected
|
14
|
-
def banner
|
15
|
-
<<-EOS.split("\n").map{|x| x.strip}.join("\n")
|
16
|
-
Creates a Merb application stub.
|
17
|
-
|
18
|
-
USAGE: #{spec.name} -g path
|
19
|
-
|
20
|
-
Set environment variable MERB_ORM=[activerecord|datamapper|sequel]
|
21
|
-
to pre-enabled an ORM.
|
22
|
-
EOS
|
23
|
-
end
|
24
|
-
|
25
|
-
def default_orm?(orm)
|
26
|
-
ENV['MERB_ORM'] == orm.to_s
|
27
|
-
end
|
28
|
-
|
29
|
-
def default_test_suite?(suite)
|
30
|
-
return ENV['MERB_TEST_SUITE'] == suite.to_s if ENV['MERB_TEST_SUITE']
|
31
|
-
options[suite]
|
32
|
-
end
|
33
|
-
|
34
|
-
def display_framework_selections
|
35
|
-
end
|
36
|
-
|
37
|
-
def create_dirs
|
38
|
-
m.directory 'log'
|
39
|
-
end
|
40
|
-
end
|
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
Gem.clear_paths
|
3
|
-
Gem.path.unshift(File.join(File.dirname(__FILE__), "gems"))
|
4
|
-
|
5
|
-
require 'rake'
|
6
|
-
require 'rake/rdoctask'
|
7
|
-
require 'rake/testtask'
|
8
|
-
require 'spec/rake/spectask'
|
9
|
-
require 'fileutils'
|
10
|
-
require 'merb-core'
|
11
|
-
require 'rubigen'
|
12
|
-
include FileUtils
|
13
|
-
|
14
|
-
# Load the basic runtime dependencies; this will include
|
15
|
-
# any plugins and therefore plugin rake tasks.
|
16
|
-
init_env = ENV['MERB_ENV'] || 'rake'
|
17
|
-
Merb.load_dependencies(:environment => init_env)
|
18
|
-
|
19
|
-
# Get Merb plugins and dependencies
|
20
|
-
Merb::Plugins.rakefiles.each { |r| require r }
|
21
|
-
|
22
|
-
desc "start runner environment"
|
23
|
-
task :merb_env do
|
24
|
-
Merb.start_environment(:environment => init_env, :adapter => 'runner')
|
25
|
-
end
|
26
|
-
|
27
|
-
##############################################################################
|
28
|
-
# ADD YOUR CUSTOM TASKS BELOW
|
29
|
-
##############################################################################
|
30
|
-
|
31
|
-
desc "Add new files to subversion"
|
32
|
-
task :svn_add do
|
33
|
-
system "svn status | grep '^\?' | sed -e 's/? *//' | sed -e 's/ /\ /g' | xargs svn add"
|
34
|
-
end
|
@@ -1,223 +0,0 @@
|
|
1
|
-
# Adapted from Autotest::Rails, RSpec's autotest class, as well as merb-core's.
|
2
|
-
require 'autotest'
|
3
|
-
|
4
|
-
class RspecCommandError < StandardError; end
|
5
|
-
|
6
|
-
class Autotest::MerbRspec < Autotest
|
7
|
-
|
8
|
-
# +model_tests_dir+:: the directory to find model-centric tests
|
9
|
-
# +controller_tests_dir+:: the directory to find controller-centric tests
|
10
|
-
# +view_tests_dir+:: the directory to find view-centric tests
|
11
|
-
# +fixtures_dir+:: the directory to find fixtures in
|
12
|
-
attr_accessor :model_tests_dir, :controller_tests_dir, :view_tests_dir, :fixtures_dir
|
13
|
-
|
14
|
-
def initialize # :nodoc:
|
15
|
-
super
|
16
|
-
|
17
|
-
initialize_test_layout
|
18
|
-
|
19
|
-
# Ignore any happenings in these directories
|
20
|
-
add_exception %r%^\./(?:doc|log|public|tmp)%
|
21
|
-
|
22
|
-
# Ignore any mappings that Autotest may have already set up
|
23
|
-
clear_mappings
|
24
|
-
|
25
|
-
# Any changes to a file in the root of the 'lib' directory will run any
|
26
|
-
# model test with a corresponding name.
|
27
|
-
add_mapping %r%^lib\/.*\.rb% do |filename, _|
|
28
|
-
files_matching %r%#{model_test_for(filename)}$%
|
29
|
-
end
|
30
|
-
|
31
|
-
add_mapping %r%^spec/(spec_helper|shared/.*)\.rb$% do
|
32
|
-
files_matching %r%^spec/.*_spec\.rb$%
|
33
|
-
end
|
34
|
-
|
35
|
-
# Any changes to a fixture will run corresponding view, controller and
|
36
|
-
# model tests
|
37
|
-
add_mapping %r%^#{fixtures_dir}/(.*)s.yml% do |_, m|
|
38
|
-
[
|
39
|
-
model_test_for(m[1]),
|
40
|
-
controller_test_for(m[1]),
|
41
|
-
view_test_for(m[1])
|
42
|
-
]
|
43
|
-
end
|
44
|
-
|
45
|
-
# Any change to a test or spec will cause it to be run
|
46
|
-
add_mapping %r%^spec/(unit|models|integration|controllers|views|functional)/.*rb$% do |filename, _|
|
47
|
-
filename
|
48
|
-
end
|
49
|
-
|
50
|
-
# Any change to a model will cause it's corresponding test to be run
|
51
|
-
add_mapping %r%^app/models/(.*)\.rb$% do |_, m|
|
52
|
-
model_test_for(m[1])
|
53
|
-
end
|
54
|
-
|
55
|
-
# Any change to the global helper will result in all view and controller
|
56
|
-
# tests being run
|
57
|
-
add_mapping %r%^app/helpers/global_helpers.rb% do
|
58
|
-
files_matching %r%^spec/(views|functional|controllers)/.*_spec\.rb$%
|
59
|
-
end
|
60
|
-
|
61
|
-
# Any change to a helper will run it's corresponding view and controller
|
62
|
-
# tests, unless the helper is the global helper. Changes to the global
|
63
|
-
# helper run all view and controller tests.
|
64
|
-
add_mapping %r%^app/helpers/(.*)_helper(s)?.rb% do |_, m|
|
65
|
-
if m[1] == "global" then
|
66
|
-
files_matching %r%^spec/(views|functional|controllers)/.*_spec\.rb$%
|
67
|
-
else
|
68
|
-
[
|
69
|
-
view_test_for(m[1]),
|
70
|
-
controller_test_for(m[1])
|
71
|
-
]
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
# Changes to views result in their corresponding view and controller test
|
76
|
-
# being run
|
77
|
-
add_mapping %r%^app/views/(.*)/% do |_, m|
|
78
|
-
[
|
79
|
-
view_test_for(m[1]),
|
80
|
-
controller_test_for(m[1])
|
81
|
-
]
|
82
|
-
end
|
83
|
-
|
84
|
-
# Changes to a controller result in its corresponding test being run. If
|
85
|
-
# the controller is the exception or application controller, all
|
86
|
-
# controller tests are run.
|
87
|
-
add_mapping %r%^app/controllers/(.*)\.rb$% do |_, m|
|
88
|
-
if ["application", "exception"].include?(m[1])
|
89
|
-
files_matching %r%^spec/(controllers|views|functional)/.*_spec\.rb$%
|
90
|
-
else
|
91
|
-
controller_test_for(m[1])
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
# If a change is made to the router, run all controller and view tests
|
96
|
-
add_mapping %r%^config/router.rb$% do # FIX
|
97
|
-
files_matching %r%^spec/(controllers|views|functional)/.*_spec\.rb$%
|
98
|
-
end
|
99
|
-
|
100
|
-
# If any of the major files governing the environment are altered, run
|
101
|
-
# everything
|
102
|
-
add_mapping %r%^spec/spec_helper.rb|config/(init|rack|environments/test.rb|database.yml)% do # FIX
|
103
|
-
files_matching %r%^spec/(unit|models|controllers|views|functional)/.*_spec\.rb$%
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
def failed_results(results)
|
108
|
-
results.scan(/^\d+\)\n(?:\e\[\d*m)?(?:.*?Error in )?'([^\n]*)'(?: FAILED)?(?:\e\[\d*m)?\n(.*?)\n\n/m)
|
109
|
-
end
|
110
|
-
|
111
|
-
def handle_results(results)
|
112
|
-
@failures = failed_results(results)
|
113
|
-
@files_to_test = consolidate_failures @failures
|
114
|
-
unless $TESTING
|
115
|
-
if @files_to_test.empty?
|
116
|
-
hook :green
|
117
|
-
else
|
118
|
-
hook :red
|
119
|
-
end
|
120
|
-
end
|
121
|
-
@tainted = true unless @files_to_test.empty?
|
122
|
-
end
|
123
|
-
|
124
|
-
def consolidate_failures(failed)
|
125
|
-
filters = Hash.new { |h,k| h[k] = [] }
|
126
|
-
failed.each do |spec, failed_trace|
|
127
|
-
find_files.keys.select { |f| f =~ /spec\// }.each do |f|
|
128
|
-
if failed_trace =~ Regexp.new(f)
|
129
|
-
filters[f] << spec
|
130
|
-
break
|
131
|
-
end
|
132
|
-
end
|
133
|
-
end
|
134
|
-
filters
|
135
|
-
end
|
136
|
-
|
137
|
-
def make_test_cmd(files_to_test)
|
138
|
-
[
|
139
|
-
ruby,
|
140
|
-
"-S",
|
141
|
-
spec_command,
|
142
|
-
add_options_if_present,
|
143
|
-
files_to_test.keys.flatten.join(' ')
|
144
|
-
].join(" ")
|
145
|
-
end
|
146
|
-
|
147
|
-
def add_options_if_present
|
148
|
-
File.exist?("spec/spec.opts") ? "-O spec/spec.opts " : ""
|
149
|
-
end
|
150
|
-
|
151
|
-
# Finds the proper spec command to use. Precendence is set in the
|
152
|
-
# lazily-evaluated method spec_commands. Alias + Override that in
|
153
|
-
# ~/.autotest to provide a different spec command then the default
|
154
|
-
# paths provided.
|
155
|
-
def spec_command(separator=File::ALT_SEPARATOR)
|
156
|
-
unless defined? @spec_command then
|
157
|
-
@spec_command = spec_commands.find { |cmd| File.exists? cmd }
|
158
|
-
|
159
|
-
raise RspecCommandError, "No spec command could be found!" unless @spec_command
|
160
|
-
|
161
|
-
@spec_command.gsub!(File::SEPARATOR, separator) if separator
|
162
|
-
end
|
163
|
-
@spec_command
|
164
|
-
end
|
165
|
-
|
166
|
-
# Autotest will look for spec commands in the following
|
167
|
-
# locations, in this order:
|
168
|
-
#
|
169
|
-
# * default spec bin/loader installed in Rubygems
|
170
|
-
# * any spec command found in PATH
|
171
|
-
def spec_commands
|
172
|
-
[ File.join(Config::CONFIG['bindir'], 'spec'), 'spec' ]
|
173
|
-
end
|
174
|
-
|
175
|
-
private
|
176
|
-
|
177
|
-
# Determines the paths we can expect tests or specs to reside, as well as
|
178
|
-
# corresponding fixtures.
|
179
|
-
def initialize_test_layout
|
180
|
-
self.model_tests_dir = "spec/models"
|
181
|
-
self.controller_tests_dir = "spec/controllers"
|
182
|
-
self.view_tests_dir = "spec/views"
|
183
|
-
self.fixtures_dir = "spec/fixtures"
|
184
|
-
end
|
185
|
-
|
186
|
-
# Given a filename and the test type, this method will return the
|
187
|
-
# corresponding test's or spec's name.
|
188
|
-
#
|
189
|
-
# ==== Arguments
|
190
|
-
# +filename+<String>:: the file name of the model, view, or controller
|
191
|
-
# +kind_of_test+<Symbol>:: the type of test we that we should run
|
192
|
-
#
|
193
|
-
# ==== Returns
|
194
|
-
# String:: the name of the corresponding test or spec
|
195
|
-
#
|
196
|
-
# ==== Example
|
197
|
-
#
|
198
|
-
# > test_for("user", :model)
|
199
|
-
# => "user_test.rb"
|
200
|
-
# > test_for("login", :controller)
|
201
|
-
# => "login_controller_test.rb"
|
202
|
-
# > test_for("form", :view)
|
203
|
-
# => "form_view_spec.rb" # If you're running a RSpec-like suite
|
204
|
-
def test_for(filename, kind_of_test) # :nodoc:
|
205
|
-
name = [filename]
|
206
|
-
name << kind_of_test.to_s if kind_of_test == :view
|
207
|
-
name << "spec"
|
208
|
-
return name.join("_") + ".rb"
|
209
|
-
end
|
210
|
-
|
211
|
-
def model_test_for(filename)
|
212
|
-
[model_tests_dir, test_for(filename, :model)].join("/")
|
213
|
-
end
|
214
|
-
|
215
|
-
def controller_test_for(filename)
|
216
|
-
[controller_tests_dir, test_for(filename, :controller)].join("/")
|
217
|
-
end
|
218
|
-
|
219
|
-
def view_test_for(filename)
|
220
|
-
[view_tests_dir, test_for(filename, :view)].join("/")
|
221
|
-
end
|
222
|
-
|
223
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
run Merb::Rack::Application.new
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require "merb-gen/helpers"
|
2
|
-
require "merb-gen/base"
|
3
|
-
|
4
|
-
class MerbFlatGenerator < Merb::GeneratorBase
|
5
|
-
|
6
|
-
def initialize(args, runtime_options = {})
|
7
|
-
@base = File.dirname(__FILE__)
|
8
|
-
@name = args.first
|
9
|
-
super
|
10
|
-
@destination_root = @name
|
11
|
-
end
|
12
|
-
|
13
|
-
protected
|
14
|
-
def banner
|
15
|
-
<<-EOS.split("\n").map{|x| x.strip}.join("\n")
|
16
|
-
Creates a flat Merb application stub.
|
17
|
-
|
18
|
-
USAGE: #{spec.name} path --flat"
|
19
|
-
EOS
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require "merb-gen/helpers"
|
2
|
-
require "merb-gen/base"
|
3
|
-
|
4
|
-
class MerbPluginGenerator < Merb::GeneratorBase
|
5
|
-
|
6
|
-
def initialize(args, runtime_options = {})
|
7
|
-
@base = File.dirname(__FILE__)
|
8
|
-
@name = args.first
|
9
|
-
super
|
10
|
-
@destination_root = @name
|
11
|
-
end
|
12
|
-
|
13
|
-
protected
|
14
|
-
def banner
|
15
|
-
<<-EOS.split("\n").map{|x| x.strip}.join("\n")
|
16
|
-
Creates a Merb plugin stub.
|
17
|
-
|
18
|
-
USAGE: #{spec.name} --generate-plugin path"
|
19
|
-
EOS
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'rake/gempackagetask'
|
3
|
-
|
4
|
-
PLUGIN = "<%= base_name %>"
|
5
|
-
NAME = "<%= base_name %>"
|
6
|
-
VERSION = "0.0.1"
|
7
|
-
AUTHOR = "Your Name"
|
8
|
-
EMAIL = "Your Email"
|
9
|
-
HOMEPAGE = "http://merb-plugins.rubyforge.org/<%= base_name %>/"
|
10
|
-
SUMMARY = "Merb plugin that provides ..."
|
11
|
-
|
12
|
-
spec = Gem::Specification.new do |s|
|
13
|
-
s.name = NAME
|
14
|
-
s.version = VERSION
|
15
|
-
s.platform = Gem::Platform::RUBY
|
16
|
-
s.has_rdoc = true
|
17
|
-
s.extra_rdoc_files = ["README", "LICENSE", 'TODO']
|
18
|
-
s.summary = SUMMARY
|
19
|
-
s.description = s.summary
|
20
|
-
s.author = AUTHOR
|
21
|
-
s.email = EMAIL
|
22
|
-
s.homepage = HOMEPAGE
|
23
|
-
s.add_dependency('merb', '>= 0.4.0')
|
24
|
-
s.require_path = 'lib'
|
25
|
-
s.autorequire = PLUGIN
|
26
|
-
s.files = %w(LICENSE README Rakefile TODO) + Dir.glob("{lib,spec}/**/*")
|
27
|
-
end
|
28
|
-
|
29
|
-
Rake::GemPackageTask.new(spec) do |pkg|
|
30
|
-
pkg.gem_spec = spec
|
31
|
-
end
|
32
|
-
|
33
|
-
task :install => [:package] do
|
34
|
-
sh %{sudo gem install pkg/#{NAME}-#{VERSION} --no-update-sources}
|
35
|
-
end
|
36
|
-
|
37
|
-
namespace :jruby do
|
38
|
-
|
39
|
-
desc "Run :package and install the resulting .gem with jruby"
|
40
|
-
task :install => :package do
|
41
|
-
sh %{#{SUDO} jruby -S gem install pkg/#{NAME}-#{Merb::VERSION}.gem --no-rdoc --no-ri}
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require "merb-gen/helpers"
|
2
|
-
require "merb-gen/base"
|
3
|
-
|
4
|
-
class MerbVeryFlatGenerator < Merb::GeneratorBase
|
5
|
-
attr_reader :app_file_name
|
6
|
-
|
7
|
-
def initialize(args, runtime_options = {})
|
8
|
-
@base = File.dirname(__FILE__)
|
9
|
-
@name = args.first
|
10
|
-
@app_file_name = File.basename(@name).snake_case
|
11
|
-
super
|
12
|
-
@destination_root = @name
|
13
|
-
end
|
14
|
-
|
15
|
-
def manifest
|
16
|
-
record do |m|
|
17
|
-
|
18
|
-
@m = m
|
19
|
-
|
20
|
-
@assigns = { :app_file_name => app_file_name }
|
21
|
-
|
22
|
-
FileUtils.mkdir_p @name
|
23
|
-
copy_dirs
|
24
|
-
copy_files
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
protected
|
29
|
-
def banner
|
30
|
-
<<-EOS.split("\n").map{|x| x.strip}.join("\n")
|
31
|
-
Creates a very flat Merb application stub.
|
32
|
-
|
33
|
-
USAGE: #{spec.name} path --very-flat"
|
34
|
-
EOS
|
35
|
-
end
|
36
|
-
|
37
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
Merb::Router.prepare do |r|
|
2
|
-
r.match('/').to(:controller => '<%= app_file_name %>', :action =>'index')
|
3
|
-
end
|
4
|
-
|
5
|
-
class <%= app_file_name.camel_case %> < Merb::Controller
|
6
|
-
def index
|
7
|
-
"hi"
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
Merb::Config.use { |c|
|
12
|
-
c[:framework] = {},
|
13
|
-
c[:session_store] = 'none',
|
14
|
-
c[:exception_details] = true
|
15
|
-
}
|