rails3-generators 0.17.6 → 1.0.0
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/CHANGELOG.rdoc +8 -1
- data/Gemfile.lock +73 -65
- data/README.rdoc +6 -8
- data/lib/rails3-generators.rb +3 -10
- data/lib/rails3-generators/version.rb +1 -1
- data/rails3-generators.gemspec +8 -1
- data/test/test_helper.rb +0 -8
- metadata +21 -58
- data/lib/generators/authlogic.rb +0 -11
- data/lib/generators/authlogic/session/session_generator.rb +0 -19
- data/lib/generators/authlogic/session/templates/session.rb +0 -2
- data/lib/generators/erubis.rb +0 -9
- data/lib/generators/erubis/controller/controller_generator.rb +0 -10
- data/lib/generators/erubis/controller/templates/view.html.erb +0 -2
- data/lib/generators/erubis/scaffold/scaffold_generator.rb +0 -25
- data/lib/generators/erubis/scaffold/templates/_form.html.erb +0 -23
- data/lib/generators/erubis/scaffold/templates/edit.html.erb +0 -6
- data/lib/generators/erubis/scaffold/templates/index.html.erb +0 -27
- data/lib/generators/erubis/scaffold/templates/new.html.erb +0 -5
- data/lib/generators/erubis/scaffold/templates/show.html.erb +0 -12
- data/lib/generators/formtastic.rb +0 -29
- data/lib/generators/formtastic/scaffold/scaffold_generator.rb +0 -25
- data/lib/generators/formtastic/scaffold/templates/_form.html.erb.erb +0 -12
- data/lib/generators/formtastic/scaffold/templates/_form.html.haml.erb +0 -10
- data/lib/generators/mongo_mapper.rb +0 -59
- data/lib/generators/mongo_mapper/install/install_generator.rb +0 -30
- data/lib/generators/mongo_mapper/install/templates/database.mongo.yml +0 -25
- data/lib/generators/mongo_mapper/install/templates/mongo_mapper.rb +0 -9
- data/lib/generators/mongo_mapper/model/model_generator.rb +0 -84
- data/lib/generators/mongo_mapper/model/templates/model.rb +0 -36
- data/lib/generators/mongo_mapper/observer/observer_generator.rb +0 -15
- data/lib/generators/mongo_mapper/observer/templates/observer.rb +0 -3
- data/lib/generators/simple_form.rb +0 -30
- data/lib/generators/simple_form/scaffold/scaffold_generator.rb +0 -25
- data/lib/generators/simple_form/scaffold/templates/_form.html.erb.erb +0 -21
- data/lib/generators/simple_form/scaffold/templates/_form.html.haml.erb +0 -15
- data/test/lib/generators/authlogic/session_generator_test.rb +0 -14
- data/test/lib/generators/erubis/controller_generator_test.rb +0 -16
- data/test/lib/generators/erubis/scaffold_generator_test.rb +0 -30
- data/test/lib/generators/formtastic/scaffold_generators_test.rb +0 -19
- data/test/lib/generators/mongo_mapper/install_generator_test.rb +0 -17
- data/test/lib/generators/mongo_mapper/model_generator_test.rb +0 -73
- data/test/lib/generators/mongo_mapper/observer_generator_test.rb +0 -20
- data/test/lib/generators/mongo_mapper/testing_helper.rb +0 -1
- data/test/lib/generators/simple_form/scaffold_generators_test.rb +0 -19
@@ -1,36 +0,0 @@
|
|
1
|
-
class <%= class_name %><%= "< #{options[:parent].classify}" if parent? %>
|
2
|
-
<% unless parent? -%>
|
3
|
-
include MongoMapper::Document
|
4
|
-
<% end -%>
|
5
|
-
<%= statements %>
|
6
|
-
<% unless parent? -%>
|
7
|
-
# Validations :::::::::::::::::::::::::::::::::::::::::::::::::::::
|
8
|
-
# validates_presence_of :attribute
|
9
|
-
|
10
|
-
# Assocations :::::::::::::::::::::::::::::::::::::::::::::::::::::
|
11
|
-
# belongs_to :model
|
12
|
-
# many :model
|
13
|
-
# one :model
|
14
|
-
|
15
|
-
# Callbacks :::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
16
|
-
# before_create :your_model_method
|
17
|
-
# after_create :your_model_method
|
18
|
-
# before_update :your_model_method
|
19
|
-
|
20
|
-
# Attribute options extras ::::::::::::::::::::::::::::::::::::::::
|
21
|
-
# attr_accessible :first_name, :last_name, :email
|
22
|
-
|
23
|
-
# Validations
|
24
|
-
# key :name, :required => true
|
25
|
-
|
26
|
-
# Defaults
|
27
|
-
# key :done, :default => false
|
28
|
-
|
29
|
-
# Typecast
|
30
|
-
# key :user_ids, Array, :typecast => 'ObjectId'
|
31
|
-
|
32
|
-
<% end -%>
|
33
|
-
<% model_attributes.each_with_index do |attribute, i| -%>
|
34
|
-
key :<%= attribute.name %>, <%= attribute.type_class %><%= ", :index => true" if model_indexes[attribute.name] %>
|
35
|
-
<% end -%>
|
36
|
-
end
|
@@ -1,15 +0,0 @@
|
|
1
|
-
require 'generators/mongo_mapper'
|
2
|
-
|
3
|
-
module MongoMapper
|
4
|
-
module Generators
|
5
|
-
class ObserverGenerator < Base
|
6
|
-
check_class_collision :suffix => "Observer"
|
7
|
-
|
8
|
-
def create_observer_file
|
9
|
-
template 'observer.rb', File.join('app/models', class_path, "#{file_name}_observer.rb")
|
10
|
-
end
|
11
|
-
|
12
|
-
hook_for :test_framework
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'rails/generators/named_base'
|
2
|
-
|
3
|
-
module SimpleForm
|
4
|
-
module Generators
|
5
|
-
class Base < Rails::Generators::NamedBase #:nodoc:
|
6
|
-
# include Rails::Generators::ResourceHelpers
|
7
|
-
|
8
|
-
def self.source_root
|
9
|
-
@_simple_form_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'simple_form', generator_name, 'templates'))
|
10
|
-
end
|
11
|
-
protected
|
12
|
-
|
13
|
-
def format
|
14
|
-
:html
|
15
|
-
end
|
16
|
-
|
17
|
-
def handler
|
18
|
-
:erb
|
19
|
-
end
|
20
|
-
|
21
|
-
def filename_with_extensions(name)
|
22
|
-
[name, format, handler].compact.join(".")
|
23
|
-
end
|
24
|
-
|
25
|
-
def template_filename_with_extensions(name)
|
26
|
-
[name, format, handler, :erb].compact.join(".")
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'generators/simple_form'
|
2
|
-
require 'rails/generators/resource_helpers'
|
3
|
-
|
4
|
-
module SimpleForm
|
5
|
-
module Generators
|
6
|
-
class ScaffoldGenerator < Base
|
7
|
-
include Rails::Generators::ResourceHelpers
|
8
|
-
|
9
|
-
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
|
10
|
-
|
11
|
-
class_option :template_engine
|
12
|
-
|
13
|
-
def copy_form_file
|
14
|
-
filename = filename_with_extensions("_form")
|
15
|
-
template template_filename_with_extensions("_form"), File.join("app/views", controller_file_path, filename)
|
16
|
-
end
|
17
|
-
|
18
|
-
protected
|
19
|
-
|
20
|
-
def handler
|
21
|
-
options[:template_engine].to_s.gsub('erubis', 'erb')
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
<%%= simple_form_for @<%= file_name %> do |form| %>
|
2
|
-
|
3
|
-
<%% if @<%= file_name %>.errors.any? -%>
|
4
|
-
<div id="errorExplanation">
|
5
|
-
<h2><%%= "#{pluralize(@<%= file_name %>.errors.count, "error")} prohibited this #{<%= class_name %>.name.titleize} from being saved:" %></h2>
|
6
|
-
<ul>
|
7
|
-
<%%- @<%= file_name %>.errors.full_messages.each do |msg| -%>
|
8
|
-
<li><%%= msg %></li>
|
9
|
-
<%%- end -%>
|
10
|
-
</ul>
|
11
|
-
</div>
|
12
|
-
<%% end -%>
|
13
|
-
|
14
|
-
<%- for attribute in attributes -%>
|
15
|
-
<%%= form.input :<%= attribute.name %>, :label => '<%= attribute.name.titleize %>' %>
|
16
|
-
<%- end -%>
|
17
|
-
|
18
|
-
<div class="actions">
|
19
|
-
<%%= form.button :submit %>
|
20
|
-
</div>
|
21
|
-
<%% end %>
|
@@ -1,15 +0,0 @@
|
|
1
|
-
= simple_form_for @<%= file_name %> do |form|
|
2
|
-
|
3
|
-
-if @<%= file_name %>.errors.any?
|
4
|
-
#errorExplanation
|
5
|
-
%h2= "#{pluralize(@<%= file_name %>.errors.count, "error")} prohibited this #{<%= class_name %>.name.titleize} from being saved:"
|
6
|
-
%ul
|
7
|
-
- @<%= file_name %>.errors.full_messages.each do |msg|
|
8
|
-
%li= msg
|
9
|
-
|
10
|
-
<%- for attribute in attributes -%>
|
11
|
-
= form.input :<%= attribute.name %>, :label => '<%= attribute.name.titleize %>'
|
12
|
-
<%- end -%>
|
13
|
-
|
14
|
-
.actions
|
15
|
-
= form.button :submit
|
@@ -1,14 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class Authlogic::Generators::SessionGeneratorTest < Rails::Generators::TestCase
|
4
|
-
destination File.join(Rails.root)
|
5
|
-
tests Authlogic::Generators::SessionGenerator
|
6
|
-
arguments %w(user_session)
|
7
|
-
|
8
|
-
setup :prepare_destination
|
9
|
-
|
10
|
-
test 'Authlogic is installed' do
|
11
|
-
content = run_generator
|
12
|
-
assert_file "app/models/user_session.rb"
|
13
|
-
end
|
14
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class Erubis::Generators::ControllerGeneratorTest < Rails::Generators::TestCase
|
4
|
-
destination File.join(Rails.root)
|
5
|
-
tests Rails::Generators::ControllerGenerator
|
6
|
-
arguments %w(Account foo bar --template-engine erubis)
|
7
|
-
|
8
|
-
setup :prepare_destination
|
9
|
-
setup :copy_routes
|
10
|
-
|
11
|
-
test "should invoke template engine" do
|
12
|
-
run_generator
|
13
|
-
assert_file "app/views/account/foo.html.erb", %r(app/views/account/foo\.html\.erb)
|
14
|
-
assert_file "app/views/account/bar.html.erb", %r(app/views/account/bar\.html\.erb)
|
15
|
-
end
|
16
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class Erubis::Generators::ScaffoldGeneratorTest < Rails::Generators::TestCase
|
4
|
-
destination File.join(Rails.root)
|
5
|
-
tests Rails::Generators::ScaffoldGenerator
|
6
|
-
arguments %w(product_line title:string price:integer --template-engine erubis)
|
7
|
-
|
8
|
-
setup :prepare_destination
|
9
|
-
setup :copy_routes
|
10
|
-
|
11
|
-
test "should invoke template engine" do
|
12
|
-
run_generator
|
13
|
-
|
14
|
-
%w(index edit new show _form).each { |view| assert_file "app/views/product_lines/#{view}.html.erb" }
|
15
|
-
assert_no_file "app/views/layouts/product_lines.html.erb"
|
16
|
-
end
|
17
|
-
|
18
|
-
test "should revoke template engine" do
|
19
|
-
run_generator
|
20
|
-
run_generator ["product_line"], :behavior => :revoke
|
21
|
-
|
22
|
-
assert_no_file "app/views/product_lines"
|
23
|
-
assert_no_file "app/views/layouts/product_lines.html.erb"
|
24
|
-
end
|
25
|
-
|
26
|
-
test "should invoke form builder" do
|
27
|
-
run_generator %w(product_line title:string price:integer --template-engine erubis --form-builder some-form-builder)
|
28
|
-
assert_no_file "app/views/product_lines/_form.html.erb"
|
29
|
-
end
|
30
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class Formtastic::Generators::FormBuilderGeneratorTest < Rails::Generators::TestCase
|
4
|
-
destination File.join(Rails.root)
|
5
|
-
tests Rails::Generators::ScaffoldGenerator
|
6
|
-
|
7
|
-
setup :prepare_destination
|
8
|
-
setup :copy_routes
|
9
|
-
|
10
|
-
test "should invoke form builder and output haml form" do
|
11
|
-
run_generator %w(product_line title:string price:integer --template-engine haml --form-builder formtastic)
|
12
|
-
assert_file "app/views/product_lines/_form.html.haml"
|
13
|
-
end
|
14
|
-
|
15
|
-
test "should invoke form builder and output erubis form" do
|
16
|
-
run_generator %w(product_line title:string price:integer --template-engine erubis --form-builder formtastic)
|
17
|
-
assert_file "app/views/product_lines/_form.html.erb"
|
18
|
-
end
|
19
|
-
end
|
@@ -1,17 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'lib/generators/mongo_mapper/testing_helper'
|
3
|
-
|
4
|
-
class MongoMapper::Generators::InstallGeneratorTest < Rails::Generators::TestCase
|
5
|
-
destination File.join(Rails.root)
|
6
|
-
tests MongoMapper::Generators::InstallGenerator
|
7
|
-
|
8
|
-
setup :prepare_destination
|
9
|
-
setup :copy_routes
|
10
|
-
|
11
|
-
test "invoke" do
|
12
|
-
run_generator ['test-db']
|
13
|
-
assert_file "config/initializers/mongo_mapper.rb" do |initializer|
|
14
|
-
assert_match /MongoMapper.connection = Mongo::Connection.new(\S+)/, initializer
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,73 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'lib/generators/mongo_mapper/testing_helper'
|
3
|
-
|
4
|
-
class MongoMapper::Generators::ModelGeneratorTest < Rails::Generators::TestCase
|
5
|
-
destination File.join(Rails.root)
|
6
|
-
tests MongoMapper::Generators::ModelGenerator
|
7
|
-
|
8
|
-
setup :prepare_destination
|
9
|
-
setup :copy_routes
|
10
|
-
|
11
|
-
test "invoke with model name" do
|
12
|
-
content = run_generator %w(Account)
|
13
|
-
|
14
|
-
assert_file "app/models/account.rb" do |account|
|
15
|
-
assert_class "Account", account do |klass|
|
16
|
-
assert_match /include MongoMapper::Document/, klass
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
test "invoke with model name and attributes" do
|
22
|
-
content = run_generator %w(Account name:string age:integer)
|
23
|
-
|
24
|
-
assert_file "app/models/account.rb" do |account|
|
25
|
-
assert_class "Account", account do |klass|
|
26
|
-
assert_match /key :name, String/, klass
|
27
|
-
assert_match /key :age, Integer/, klass
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
test "invoke with model name and --embedded option" do
|
33
|
-
content = run_generator %w(Account --embedded)
|
34
|
-
|
35
|
-
assert_file "app/models/account.rb" do |account|
|
36
|
-
assert_class "Account", account do |klass|
|
37
|
-
assert_match /include MongoMapper::EmbeddedDocument/, klass
|
38
|
-
end
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
test "invoke with model name and --timestamps option" do
|
43
|
-
content = run_generator %w(Account --timestamps)
|
44
|
-
|
45
|
-
assert_file "app/models/account.rb" do |account|
|
46
|
-
assert_class "Account", account do |klass|
|
47
|
-
assert_match /timestamps!/, klass
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
test "invoke with model name and --version option" do
|
53
|
-
content = run_generator %w(Account --version)
|
54
|
-
|
55
|
-
assert_file "app/models/account.rb" do |account|
|
56
|
-
assert_class "Account", account do |klass|
|
57
|
-
assert_match /include Versioned/, klass
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
|
63
|
-
test "invoke with model name and --parent option" do
|
64
|
-
content = run_generator %w(Admin --parent User)
|
65
|
-
|
66
|
-
assert_file "app/models/admin.rb" do |account|
|
67
|
-
assert_class "Admin", account do |klass|
|
68
|
-
assert_no_match /include MongoMapper::Document/, klass
|
69
|
-
assert_match /<\s+User/, klass
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
require 'lib/generators/mongo_mapper/testing_helper'
|
3
|
-
|
4
|
-
class MongoMapper::Generators::ObserverGeneratorTest < Rails::Generators::TestCase
|
5
|
-
destination File.join(Rails.root)
|
6
|
-
tests MongoMapper::Generators::ObserverGenerator
|
7
|
-
|
8
|
-
setup :prepare_destination
|
9
|
-
setup :copy_routes
|
10
|
-
|
11
|
-
test "invoke with name Account" do
|
12
|
-
name = 'account'
|
13
|
-
run_generator [name]
|
14
|
-
assert_file "app/models/#{name}_observer.rb" do |file_content|
|
15
|
-
assert_class "Account", file_content do |klass|
|
16
|
-
assert_match /< MongoMapper::Observer/, klass
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
require_generators :mongo_mapper => ['model', 'observer', 'install']
|
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'test_helper'
|
2
|
-
|
3
|
-
class SimpleForm::Generators::FormBuilderGeneratorTest < Rails::Generators::TestCase
|
4
|
-
destination File.join(Rails.root)
|
5
|
-
tests Rails::Generators::ScaffoldGenerator
|
6
|
-
|
7
|
-
setup :prepare_destination
|
8
|
-
setup :copy_routes
|
9
|
-
|
10
|
-
test "should invoke form builder and output haml form" do
|
11
|
-
run_generator %w(product_line title:string price:integer --template-engine haml --form-builder simple_form)
|
12
|
-
assert_file "app/views/product_lines/_form.html.haml"
|
13
|
-
end
|
14
|
-
|
15
|
-
test "should invoke form builder and output erubis form" do
|
16
|
-
run_generator %w(product_line title:string price:integer --template-engine erubis --form-builder simple_form)
|
17
|
-
assert_file "app/views/product_lines/_form.html.erb"
|
18
|
-
end
|
19
|
-
end
|