trusty-cms 4.1.5 → 4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +122 -115
- data/INSTALL.md +2 -0
- data/app/views/admin/assets/edit.html.haml +3 -0
- data/config/environments/development.rb +2 -0
- data/config/locales/en.yml +1 -0
- data/lib/generators/extension/USAGE +30 -0
- data/lib/generators/extension/extension_generator.rb +97 -0
- data/lib/generators/extension/templates/README.md +6 -0
- data/lib/generators/extension/templates/RSpecRakefile +109 -0
- data/lib/generators/extension/templates/Rakefile +25 -0
- data/lib/generators/extension/templates/cucumber.yml +1 -0
- data/lib/generators/extension/templates/cucumber_env.rb +11 -0
- data/lib/generators/extension/templates/cucumber_paths.rb +22 -0
- data/lib/generators/extension/templates/en.yml +3 -0
- data/lib/generators/extension/templates/extension.rb +21 -0
- data/lib/generators/extension/templates/functional_test.rb +15 -0
- data/lib/generators/extension/templates/gemspec.rb +29 -0
- data/lib/generators/extension/templates/lib.rb +8 -0
- data/lib/generators/extension/templates/migration.rb +9 -0
- data/lib/generators/extension/templates/radiant_config.rb +3 -0
- data/lib/generators/extension/templates/routes.rb +5 -0
- data/lib/generators/extension/templates/spec.opts +6 -0
- data/lib/generators/extension/templates/spec_helper.rb +42 -0
- data/lib/generators/extension/templates/tasks.rake +47 -0
- data/lib/generators/extension/templates/test_helper.rb +26 -0
- data/lib/generators/extension_controller/USAGE +36 -0
- data/lib/generators/extension_controller/extension_controller_generator.rb +84 -0
- data/lib/generators/extension_controller/templates/controller.rb +10 -0
- data/lib/generators/extension_controller/templates/controller_spec.rb +23 -0
- data/lib/generators/extension_controller/templates/functional_test.rb +11 -0
- data/lib/generators/extension_controller/templates/helper.rb +2 -0
- data/lib/generators/extension_controller/templates/helper_spec.rb +11 -0
- data/lib/generators/extension_controller/templates/helper_test.rb +4 -0
- data/lib/generators/extension_controller/templates/view.html.erb +2 -0
- data/lib/generators/extension_controller/templates/view_spec.rb +12 -0
- data/lib/generators/extension_mailer/USAGE +17 -0
- data/lib/generators/extension_mailer/extension_mailer_generator.rb +68 -0
- data/lib/generators/extension_mailer/templates/fixture.erb +3 -0
- data/lib/generators/extension_mailer/templates/mailer.rb +15 -0
- data/lib/generators/extension_mailer/templates/unit_test.rb +21 -0
- data/lib/generators/extension_mailer/templates/view.erb +3 -0
- data/lib/generators/extension_migration/USAGE +34 -0
- data/lib/generators/extension_migration/extension_migration_generator.rb +25 -0
- data/lib/generators/extension_migration/templates/migration.rb +11 -0
- data/lib/generators/extension_model/USAGE +35 -0
- data/lib/generators/extension_model/extension_model_generator.rb +68 -0
- data/lib/generators/extension_model/templates/fixtures.yml +19 -0
- data/lib/generators/extension_model/templates/migration.rb +16 -0
- data/lib/generators/extension_model/templates/model.rb +2 -0
- data/lib/generators/extension_model/templates/model_spec.rb +11 -0
- data/lib/generators/extension_model/templates/unit_test.rb +8 -0
- data/lib/generators/generator_base_extension.rb +18 -0
- data/lib/generators/instance/instance_generator.rb +148 -0
- data/lib/generators/instance/templates/databases/db2.yml +40 -0
- data/lib/generators/instance/templates/databases/mysql.yml +47 -0
- data/lib/generators/instance/templates/databases/postgresql.yml +44 -0
- data/lib/generators/instance/templates/databases/sqlite3.yml +16 -0
- data/lib/generators/instance/templates/databases/sqlserver.yml +21 -0
- data/lib/generators/instance/templates/instance_boot.rb +122 -0
- data/lib/generators/instance/templates/instance_config.ru +2 -0
- data/lib/generators/instance/templates/instance_environment.rb +93 -0
- data/lib/generators/instance/templates/instance_gemfile +78 -0
- data/lib/generators/instance/templates/instance_generate +6 -0
- data/lib/generators/instance/templates/instance_radiant_config.rb +16 -0
- data/lib/generators/instance/templates/instance_rakefile +3 -0
- data/lib/generators/instance/templates/instance_routes.rb +1 -0
- data/lib/generators/language_extension/USAGE +27 -0
- data/lib/generators/language_extension/language_extension_generator.rb +71 -0
- data/lib/generators/language_extension/templates/README +3 -0
- data/lib/generators/language_extension/templates/RSpecRakefile +123 -0
- data/lib/generators/language_extension/templates/Rakefile +25 -0
- data/lib/generators/language_extension/templates/available_tags.yml +553 -0
- data/lib/generators/language_extension/templates/cucumber.yml +1 -0
- data/lib/generators/language_extension/templates/cucumber_env.rb +16 -0
- data/lib/generators/language_extension/templates/cucumber_paths.rb +14 -0
- data/lib/generators/language_extension/templates/extension.rb +12 -0
- data/lib/generators/language_extension/templates/functional_test.rb +15 -0
- data/lib/generators/language_extension/templates/gemspec.rb +24 -0
- data/lib/generators/language_extension/templates/lang.yml +181 -0
- data/lib/generators/language_extension/templates/lib.rb +8 -0
- data/lib/generators/language_extension/templates/spec.opts +6 -0
- data/lib/generators/language_extension/templates/spec_helper.rb +36 -0
- data/lib/generators/language_extension/templates/tasks.rake +28 -0
- data/lib/generators/language_extension/templates/test_helper.rb +26 -0
- data/lib/generators/trusty_cms/USAGE +8 -0
- data/lib/generators/trusty_cms/templates/Rakefile.erb +7 -0
- data/lib/generators/trusty_cms/templates/application.rb.erb +149 -0
- data/lib/generators/trusty_cms/templates/boot.rb.erb +9 -0
- data/lib/generators/trusty_cms/templates/config.ru.erb +4 -0
- data/lib/generators/trusty_cms/templates/database.yml.erb +28 -0
- data/lib/generators/trusty_cms/templates/environment.rb.erb +5 -0
- data/lib/generators/trusty_cms/templates/environments/development.rb.erb +24 -0
- data/lib/generators/trusty_cms/templates/environments/production.rb.erb +26 -0
- data/lib/generators/trusty_cms/templates/environments/test.rb.erb +35 -0
- data/lib/generators/trusty_cms/templates/initializers/secret_token.rb.erb +13 -0
- data/lib/generators/trusty_cms/templates/initializers/session_store.rb.erb +8 -0
- data/lib/generators/trusty_cms/templates/initializers/trusty_cms_config.rb.erb +16 -0
- data/lib/generators/trusty_cms/templates/preinitializer.rb.erb +18 -0
- data/lib/generators/trusty_cms/templates/routes.rb.erb +0 -0
- data/lib/generators/trusty_cms/trusty_cms_generator.rb +32 -0
- data/lib/trusty_cms.rb +1 -1
- data/lib/trusty_cms/setup.rb +7 -7
- data/trusty_cms.gemspec +4 -4
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/base.rb +195 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/check_box.rb +65 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/checkable.rb +18 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/collection_check_boxes.rb +35 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/collection_helpers.rb +118 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/collection_radio_buttons.rb +30 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/collection_select.rb +30 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/color_field.rb +26 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/date_field.rb +14 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/date_select.rb +73 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/datetime_field.rb +31 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/datetime_local_field.rb +20 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/datetime_select.rb +10 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/email_field.rb +10 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/file_field.rb +10 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/grouped_collection_select.rb +31 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/hidden_field.rb +10 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/label.rb +80 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/month_field.rb +14 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/number_field.rb +20 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/password_field.rb +14 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/placeholderable.rb +24 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/radio_button.rb +32 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/range_field.rb +10 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/search_field.rb +27 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/select.rb +42 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/tel_field.rb +10 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/text_area.rb +24 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/text_field.rb +33 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/time_field.rb +14 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/time_select.rb +10 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/time_zone_select.rb +22 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/translator.rb +39 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/url_field.rb +10 -0
- data/vendor/bundle/ruby/2.6.0/gems/actionview-6.0.3.4/lib/action_view/helpers/tags/week_field.rb +14 -0
- data/yarn.lock +3 -3
- metadata +296 -71
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/core.js +0 -126
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/index.js +0 -4
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/map.js +0 -56
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/seq.js +0 -43
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/failsafe/string.js +0 -28
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/index.js +0 -36
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/json.js +0 -76
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/options.js +0 -23
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/binary.js +0 -87
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/index.js +0 -157
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/omap.js +0 -142
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/pairs.js +0 -81
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/set.js +0 -114
- data/spec/spec/dummy/node_modules/yaml/browser/dist/tags/yaml-1.1/timestamp.js +0 -97
- data/spec/spec/dummy/node_modules/yaml/dist/tags/core.js +0 -114
- data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/index.js +0 -17
- data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/map.js +0 -37
- data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/seq.js +0 -34
- data/spec/spec/dummy/node_modules/yaml/dist/tags/failsafe/string.js +0 -40
- data/spec/spec/dummy/node_modules/yaml/dist/tags/index.js +0 -62
- data/spec/spec/dummy/node_modules/yaml/dist/tags/json.js +0 -60
- data/spec/spec/dummy/node_modules/yaml/dist/tags/options.js +0 -35
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/binary.js +0 -97
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/index.js +0 -131
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/omap.js +0 -105
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/pairs.js +0 -80
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/set.js +0 -91
- data/spec/spec/dummy/node_modules/yaml/dist/tags/yaml-1.1/timestamp.js +0 -93
@@ -0,0 +1,47 @@
|
|
1
|
+
namespace :radiant do
|
2
|
+
namespace :extensions do
|
3
|
+
namespace :<%= file_name %> do
|
4
|
+
|
5
|
+
desc "Runs the migration of the <%= extension_name %> extension"
|
6
|
+
task :migrate => :environment do
|
7
|
+
require 'trusty_cms/extension_migrator'
|
8
|
+
if ENV["VERSION"]
|
9
|
+
<%= class_name %>.migrator.migrate(ENV["VERSION"].to_i)
|
10
|
+
Rake::Task['db:schema:dump'].invoke
|
11
|
+
else
|
12
|
+
<%= class_name %>.migrator.migrate
|
13
|
+
Rake::Task['db:schema:dump'].invoke
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
desc "Copies public assets of the <%= extension_name %> to the instance public/ directory."
|
18
|
+
task :update => :environment do
|
19
|
+
is_svn_or_dir = proc {|path| path =~ /\.svn/ || File.directory?(path) }
|
20
|
+
puts "Copying assets from <%= class_name %>"
|
21
|
+
Dir[<%= class_name %>.root + "/public/**/*"].reject(&is_svn_or_dir).each do |file|
|
22
|
+
path = file.sub(<%= class_name %>.root, '')
|
23
|
+
directory = File.dirname(path)
|
24
|
+
mkdir_p Rails.root + directory, :verbose => false
|
25
|
+
cp file, Rails.root + path, :verbose => false
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
desc "Syncs all available translations for this ext to the English ext master"
|
30
|
+
task :sync => :environment do
|
31
|
+
# The main translation root, basically where English is kept
|
32
|
+
language_root = <%= class_name %>.root + "/config/locales"
|
33
|
+
words = TranslationSupport.get_translation_keys(language_root)
|
34
|
+
|
35
|
+
Dir["#{language_root}/*.yml"].each do |filename|
|
36
|
+
next if filename.match('_available_tags')
|
37
|
+
basename = File.basename(filename, '.yml')
|
38
|
+
puts "Syncing #{basename}"
|
39
|
+
(comments, other) = TranslationSupport.read_file(filename, basename)
|
40
|
+
words.each { |k,v| other[k] ||= words[k] } # Initializing hash variable as empty if it does not exist
|
41
|
+
other.delete_if { |k,v| !words[k] } # Remove if not defined in en.yml
|
42
|
+
TranslationSupport.write_file(filename, basename, comments, other)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
# Load the environment
|
3
|
+
unless defined? TRUSTY_CMS_ROOT
|
4
|
+
ENV["Rails.env"] = "test"
|
5
|
+
case
|
6
|
+
when ENV["RADIANT_ENV_FILE"]
|
7
|
+
require ENV["RADIANT_ENV_FILE"]
|
8
|
+
when File.dirname(__FILE__) =~ %r{vendor/trusty_cms/vendor/extensions}
|
9
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../../../")}/config/environment"
|
10
|
+
else
|
11
|
+
require "#{File.expand_path(File.dirname(__FILE__) + "/../../../../")}/config/environment"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
require "#{TRUSTY_CMS_ROOT}/test/test_helper"
|
15
|
+
|
16
|
+
class ActiveSupport::TestCase
|
17
|
+
|
18
|
+
# Include a helper to make testing Radius tags easier
|
19
|
+
test_helper :extension_tags
|
20
|
+
|
21
|
+
# Add the fixture directory to the fixture path
|
22
|
+
self.fixture_path << File.dirname(__FILE__) + "/fixtures"
|
23
|
+
|
24
|
+
# Add more helper methods to be used by all extension tests here...
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
Description:
|
2
|
+
The extension_controller generator creates stubs for a new controller and
|
3
|
+
its views for an extension.
|
4
|
+
|
5
|
+
The generator takes an extension name, controller name, and a list of
|
6
|
+
views as arguments. The controller name may be given in CamelCase or
|
7
|
+
under_score and should not be suffixed with 'Controller'. To create a
|
8
|
+
controller within a module, specify the controller name as
|
9
|
+
'module/controller'.
|
10
|
+
|
11
|
+
The generator creates a controller class in
|
12
|
+
vendor/extension_name/app/controllers with view templates in
|
13
|
+
vendor/extension_name/app/views/controller_name, a helper class in
|
14
|
+
vendor/extension_name/app/helpers, and a functional test suite in
|
15
|
+
vendor/extension_name/test/functional.
|
16
|
+
|
17
|
+
Example:
|
18
|
+
./script/generate extension_controller MyExt Assets list show
|
19
|
+
|
20
|
+
Controller: vendor/my_ext/app/controllers/assets_controller.rb
|
21
|
+
Views: vendor/my_ext/app/views/assets/list.rhtml [...]
|
22
|
+
Helper: vendor/my_ext/app/helpers/assets_helper.rb
|
23
|
+
Spec: vendor/my_ext/spec/controllers/assets_controller_spec.rb
|
24
|
+
Test: vendor/my_ext/test/functional/assets_test.rb (if extension created with "--with-test-unit")
|
25
|
+
|
26
|
+
Modules Example:
|
27
|
+
./script/generate extension_controller MyExt 'admin/assets' upload remove
|
28
|
+
|
29
|
+
Controller: vendor/my_ext/app/controllers/admin/assets_controller.rb
|
30
|
+
Views: vendor/my_ext/app/views/admin/assets/upload.rhtml [...]
|
31
|
+
Helper: vendor/my_ext/app/helpers/admin/assets_helper.rb
|
32
|
+
Spec: vendor/my_ext/spec/controllers/admin/assets_controller_spec.rb
|
33
|
+
Test: vendor/my_ext/test/functional/admin/assets_controller_test.rb (if extension created with "--with-test-unit")
|
34
|
+
|
35
|
+
Note: Once you have created an extension controller you will still need to
|
36
|
+
map routes to the controller in the extension file.
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'rails_generator/base'
|
2
|
+
require 'rails_generator/generators/components/controller/controller_generator'
|
3
|
+
|
4
|
+
class ExtensionControllerGenerator < ControllerGenerator
|
5
|
+
|
6
|
+
attr_accessor :extension_name
|
7
|
+
default_options :with_test_unit => false
|
8
|
+
|
9
|
+
def initialize(runtime_args, runtime_options = {})
|
10
|
+
runtime_args = runtime_args.dup
|
11
|
+
@extension_name = runtime_args.shift
|
12
|
+
super(runtime_args, runtime_options)
|
13
|
+
end
|
14
|
+
|
15
|
+
def manifest
|
16
|
+
if extension_uses_rspec?
|
17
|
+
rspec_manifest
|
18
|
+
else
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def rspec_manifest
|
24
|
+
record do |m|
|
25
|
+
# Check for class naming collisions.
|
26
|
+
m.class_collisions class_path, "#{class_name}Controller", "#{class_name}Helper"
|
27
|
+
|
28
|
+
# Controller, helper, views, and spec directories.
|
29
|
+
m.directory File.join('app/controllers', class_path)
|
30
|
+
m.directory File.join('app/helpers', class_path)
|
31
|
+
m.directory File.join('app/views', class_path, file_name)
|
32
|
+
m.directory File.join('spec/controllers', class_path)
|
33
|
+
m.directory File.join('spec/helpers', class_path)
|
34
|
+
m.directory File.join('spec/views', class_path, file_name)
|
35
|
+
|
36
|
+
# Controller spec, class, and helper.
|
37
|
+
m.template 'controller_spec.rb',
|
38
|
+
File.join('spec/controllers', class_path, "#{file_name}_controller_spec.rb")
|
39
|
+
|
40
|
+
m.template 'helper_spec.rb',
|
41
|
+
File.join('spec/helpers', class_path, "#{file_name}_helper_spec.rb")
|
42
|
+
|
43
|
+
m.template 'controller:controller.rb',
|
44
|
+
File.join('app/controllers', class_path, "#{file_name}_controller.rb")
|
45
|
+
|
46
|
+
m.template 'controller:helper.rb',
|
47
|
+
File.join('app/helpers', class_path, "#{file_name}_helper.rb")
|
48
|
+
|
49
|
+
# Spec and view template for each action.
|
50
|
+
actions.each do |action|
|
51
|
+
m.template 'view_spec.rb',
|
52
|
+
File.join('spec/views', class_path, file_name, "#{action}_view_spec.rb"),
|
53
|
+
:assigns => { :action => action, :model => file_name }
|
54
|
+
path = File.join('app/views', class_path, file_name, "#{action}.html.erb")
|
55
|
+
m.template 'controller:view.html.erb',
|
56
|
+
path,
|
57
|
+
:assigns => { :action => action, :path => path }
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def banner
|
63
|
+
"Usage: #{$0} #{spec.name} ExtensionName #{spec.name.camelize}Name [options]"
|
64
|
+
end
|
65
|
+
|
66
|
+
def extension_path
|
67
|
+
File.join('vendor', 'extensions', @extension_name.underscore)
|
68
|
+
end
|
69
|
+
|
70
|
+
def destination_root
|
71
|
+
File.join(Rails.root, extension_path)
|
72
|
+
end
|
73
|
+
|
74
|
+
def extension_uses_rspec?
|
75
|
+
File.exists?(File.join(destination_root, 'spec')) && !options[:with_test_unit]
|
76
|
+
end
|
77
|
+
|
78
|
+
def add_options!(opt)
|
79
|
+
opt.separator ''
|
80
|
+
opt.separator 'Options:'
|
81
|
+
opt.on("--with-test-unit",
|
82
|
+
"Use Test::Unit tests instead sof RSpec.") { |v| options[:with_test_unit] = v }
|
83
|
+
end
|
84
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper'
|
2
|
+
|
3
|
+
describe <%= class_name %>Controller do
|
4
|
+
|
5
|
+
<% if actions.empty? -%>
|
6
|
+
#Delete this example and add some real ones
|
7
|
+
<% else -%>
|
8
|
+
#Delete these examples and add some real ones
|
9
|
+
<% end -%>
|
10
|
+
it "should use <%= class_name %>Controller" do
|
11
|
+
controller.should be_an_instance_of(<%= class_name %>Controller)
|
12
|
+
end
|
13
|
+
|
14
|
+
<% unless actions.empty? -%>
|
15
|
+
<% for action in actions -%>
|
16
|
+
|
17
|
+
it "GET '<%= action %>' should be successful" do
|
18
|
+
get '<%= action %>'
|
19
|
+
response.should be_success
|
20
|
+
end
|
21
|
+
<% end -%>
|
22
|
+
<% end -%>
|
23
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../test_helper'
|
2
|
+
|
3
|
+
# Re-raise errors caught by the controller.
|
4
|
+
<%= class_name %>Controller.class_eval { def rescue_action(e) raise e end }
|
5
|
+
|
6
|
+
class <%= class_name %>ControllerTest < ActionController::TestCase
|
7
|
+
# Replace this with your real tests.
|
8
|
+
def test_truth
|
9
|
+
assert true
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../spec_helper'
|
2
|
+
|
3
|
+
describe <%= class_name %>Helper do
|
4
|
+
|
5
|
+
#Delete this example and add some real ones or delete this file
|
6
|
+
it "should include the <%= class_name %>Helper" do
|
7
|
+
included_modules = self.metaclass.send :included_modules
|
8
|
+
included_modules.should include(<%= class_name %>Helper)
|
9
|
+
end
|
10
|
+
|
11
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../../spec_helper'
|
2
|
+
|
3
|
+
describe "/<%= class_name.underscore %>/<%= action %>" do
|
4
|
+
before do
|
5
|
+
render '<%= class_name.underscore %>/<%= action %>'
|
6
|
+
end
|
7
|
+
|
8
|
+
#Delete this example and add some real ones or delete this file
|
9
|
+
it "should tell you where to find the file" do
|
10
|
+
response.should have_tag('p', 'Find me in app/views/<%= class_name.underscore %>/<%= action %>.rhtml')
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
Description:
|
2
|
+
Stubs out a new mailer and its views for the given extension.
|
3
|
+
Pass the mailer name, either CamelCased or under_scored,
|
4
|
+
and an optional list of emails as arguments.
|
5
|
+
|
6
|
+
This generates a mailer class in app/models, view templates in
|
7
|
+
app/views/mailer_name, a unit test in test/unit, and fixtures in
|
8
|
+
test/fixtures.
|
9
|
+
|
10
|
+
Example:
|
11
|
+
`./script/generate extension_mailer MyExt Notifications signup forgot_password invoice`
|
12
|
+
|
13
|
+
creates a Notifications mailer class, views, test, and fixtures:
|
14
|
+
Mailer: vendor/my_ext/app/models/notifications.rb
|
15
|
+
Views: vendor/my_ext/app/views/notifications/signup.erb [...]
|
16
|
+
Test: vendor/my_ext/test/unit/test/unit/notifications_test.rb
|
17
|
+
Fixtures: vendor/my_ext/test/fixtures/notifications/signup [...]
|
@@ -0,0 +1,68 @@
|
|
1
|
+
require 'rails_generator/base'
|
2
|
+
require 'rails_generator/generators/components/mailer/mailer_generator'
|
3
|
+
|
4
|
+
class ExtensionMailerGenerator < MailerGenerator
|
5
|
+
|
6
|
+
attr_accessor :extension_name
|
7
|
+
default_options :with_test_unit => false
|
8
|
+
|
9
|
+
def initialize(runtime_args, runtime_options = {})
|
10
|
+
runtime_args = runtime_args.dup
|
11
|
+
@extension_name = runtime_args.shift
|
12
|
+
super(runtime_args, runtime_options)
|
13
|
+
end
|
14
|
+
|
15
|
+
def manifest
|
16
|
+
if extension_uses_rspec?
|
17
|
+
rspec_manifest
|
18
|
+
else
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def rspec_manifest
|
24
|
+
record do |m|
|
25
|
+
# Check for class naming collisions.
|
26
|
+
m.class_collisions class_path, class_name
|
27
|
+
|
28
|
+
# Mailer, view, test, and fixture directories.
|
29
|
+
m.directory File.join('app/models', class_path)
|
30
|
+
m.directory File.join('app/views', file_path)
|
31
|
+
|
32
|
+
# Mailer class and unit test.
|
33
|
+
m.template "mailer:mailer.rb", File.join('app/models', class_path, "#{file_name}.rb")
|
34
|
+
|
35
|
+
# View template and fixture for each action.
|
36
|
+
actions.each do |action|
|
37
|
+
relative_path = File.join(file_path, action)
|
38
|
+
view_path = File.join('app/views', "#{relative_path}.erb")
|
39
|
+
|
40
|
+
m.template "mailer:view.erb", view_path,
|
41
|
+
:assigns => { :action => action, :path => view_path }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def banner
|
47
|
+
"Usage: #{$0} #{spec.name} ExtensionName #{spec.name.camelize}Name [options]"
|
48
|
+
end
|
49
|
+
|
50
|
+
def extension_path
|
51
|
+
File.join('vendor', 'extensions', @extension_name.underscore)
|
52
|
+
end
|
53
|
+
|
54
|
+
def destination_root
|
55
|
+
File.join(Rails.root, extension_path)
|
56
|
+
end
|
57
|
+
|
58
|
+
def extension_uses_rspec?
|
59
|
+
File.exists?(File.join(destination_root, 'spec')) && !options[:with_test_unit]
|
60
|
+
end
|
61
|
+
|
62
|
+
def add_options!(opt)
|
63
|
+
opt.separator ''
|
64
|
+
opt.separator 'Options:'
|
65
|
+
opt.on("--with-test-unit",
|
66
|
+
"Use Test::Unit tests instead sof RSpec.") { |v| options[:with_test_unit] = v }
|
67
|
+
end
|
68
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class <%= class_name %> < ActionMailer::Base
|
2
|
+
|
3
|
+
<% for action in actions -%>
|
4
|
+
|
5
|
+
def <%= action %>(sent_at = Time.now)
|
6
|
+
subject '<%= class_name %>#<%= action %>'
|
7
|
+
recipients ''
|
8
|
+
from ''
|
9
|
+
sent_on sent_at
|
10
|
+
|
11
|
+
body :greeting => 'Hi,'
|
12
|
+
end
|
13
|
+
<% end -%>
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require File.dirname(__FILE__) + '<%= '/..' * class_nesting_depth %>/../test_helper'
|
2
|
+
|
3
|
+
class <%= class_name %>Test < ActionMailer::TestCase
|
4
|
+
tests <%= class_name %>
|
5
|
+
<% for action in actions -%>
|
6
|
+
def test_<%= action %>
|
7
|
+
@expected.subject = '<%= class_name %>#<%= action %>'
|
8
|
+
@expected.body = read_fixture('<%= action %>')
|
9
|
+
@expected.date = Time.now
|
10
|
+
|
11
|
+
assert_equal @expected.encoded, <%= class_name %>.create_<%= action %>(@expected.date).encoded
|
12
|
+
end
|
13
|
+
|
14
|
+
<% end -%>
|
15
|
+
<% if actions.blank? -%>
|
16
|
+
# replace this with your real tests
|
17
|
+
def test_truth
|
18
|
+
assert true
|
19
|
+
end
|
20
|
+
<% end -%>
|
21
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
Description:
|
2
|
+
The extension_migration generator creates a stub for a new migration for an
|
3
|
+
extension.
|
4
|
+
|
5
|
+
The generator takes the extension name, a migration name as its arguments,
|
6
|
+
and an optional list of attribute pairs as arguments. The migration name
|
7
|
+
may be given in CamelCase or under_score.
|
8
|
+
|
9
|
+
You can name your migration in either of these formats to generate add/remove
|
10
|
+
column lines from supplied attributes: AddColumnsToTable or RemoveColumnsFromTable
|
11
|
+
|
12
|
+
A migration class is generated in vendor/extensions/extension_name/db/migrate
|
13
|
+
prefixed by a timestamp of the current date and time.
|
14
|
+
|
15
|
+
Examples:
|
16
|
+
`./script/generate extension_migration MyExt AddSslFlag`
|
17
|
+
|
18
|
+
If the current date is May 14, 2008 and the current time 09:09:12, this creates the AddSslFlag migration
|
19
|
+
vendor/extensions/my_ext/db/migrate/20080514090912_add_ssl_flag.rb
|
20
|
+
|
21
|
+
`./script/generate migration MyExt AddTitleBodyToPost title:string body:text published:boolean`
|
22
|
+
|
23
|
+
This will create the AddTitleBodyToPost in vendor/extensions/my_ext/db/migrate/20080514090912_add_title_body_to_post.rb
|
24
|
+
with this in the Up migration:
|
25
|
+
|
26
|
+
add_column :posts, :title, :string
|
27
|
+
add_column :posts, :body, :text
|
28
|
+
add_column :posts, :published, :boolean
|
29
|
+
|
30
|
+
And this in the Down migration:
|
31
|
+
|
32
|
+
remove_column :posts, :published
|
33
|
+
remove_column :posts, :body
|
34
|
+
remove_column :posts, :title
|