iain-pizza-generators 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +113 -0
- data/README.rdoc +34 -12
- data/Rakefile +2 -2
- data/pizza-generators.gemspec +16 -13
- data/rails_generators/pizza_authentication/pizza_authentication_generator.rb +32 -24
- data/rails_generators/pizza_authentication/templates/authentication.rb +35 -9
- data/rails_generators/pizza_authentication/templates/factories.rb +24 -0
- data/rails_generators/pizza_authentication/templates/initializer.rb +5 -0
- data/rails_generators/pizza_authentication/templates/migration.rb +14 -4
- data/rails_generators/pizza_authentication/templates/session.rb +1 -0
- data/rails_generators/pizza_authentication/templates/sessions_controller.rb +17 -15
- data/rails_generators/pizza_authentication/templates/tests/rspec/sessions_controller.rb +104 -21
- data/rails_generators/pizza_authentication/templates/tests/rspec/user.rb +81 -29
- data/rails_generators/pizza_authentication/templates/tests/rspec/users_controller.rb +1 -1
- data/rails_generators/pizza_authentication/templates/tests/testunit/sessions_controller.rb +8 -4
- data/rails_generators/pizza_authentication/templates/tests/testunit/users_controller.rb +2 -2
- data/rails_generators/pizza_authentication/templates/user.rb +16 -1
- data/rails_generators/pizza_authentication/templates/users_controller.rb +32 -7
- data/rails_generators/pizza_authentication/templates/views/haml/edit.html.haml +21 -0
- data/rails_generators/pizza_authentication/templates/views/haml/login.html.haml +2 -2
- data/rails_generators/pizza_authentication/templates/views/haml/new.html.haml +19 -0
- data/rails_generators/pizza_authentication/templates/views/haml/show.html.haml +15 -0
- data/rails_generators/pizza_authentication/templates/views/haml/signup.html.haml +3 -2
- data/rails_generators/pizza_scaffold/pizza_scaffold_generator.rb +4 -5
- data/rails_generators/pizza_scaffold/templates/actions/create.rb +15 -3
- data/rails_generators/pizza_scaffold/templates/actions/destroy.rb +10 -3
- data/rails_generators/pizza_scaffold/templates/actions/edit.rb +4 -0
- data/rails_generators/pizza_scaffold/templates/actions/index.rb +9 -2
- data/rails_generators/pizza_scaffold/templates/actions/new.rb +10 -0
- data/rails_generators/pizza_scaffold/templates/actions/show.rb +10 -0
- data/rails_generators/pizza_scaffold/templates/actions/update.rb +15 -3
- data/rails_generators/pizza_scaffold/templates/controller.rb +1 -7
- data/rails_generators/pizza_scaffold/templates/tests/rspec/actions/create.rb +78 -10
- data/rails_generators/pizza_scaffold/templates/tests/rspec/actions/destroy.rb +28 -6
- data/rails_generators/pizza_scaffold/templates/tests/rspec/actions/edit.rb +12 -4
- data/rails_generators/pizza_scaffold/templates/tests/rspec/actions/index.rb +29 -4
- data/rails_generators/pizza_scaffold/templates/tests/rspec/actions/new.rb +29 -4
- data/rails_generators/pizza_scaffold/templates/tests/rspec/actions/show.rb +26 -4
- data/rails_generators/pizza_scaffold/templates/tests/rspec/actions/update.rb +72 -10
- data/rails_generators/pizza_scaffold/templates/tests/rspec/controller.rb +3 -3
- data/rails_generators/pizza_scaffold/templates/views/haml/_form.html.haml +4 -5
- data/rails_generators/pizza_scaffold/templates/views/haml/edit.html.haml +3 -5
- data/rails_generators/pizza_scaffold/templates/views/haml/index.html.haml +7 -6
- data/rails_generators/pizza_scaffold/templates/views/haml/new.html.haml +2 -4
- data/rails_generators/pizza_scaffold/templates/views/haml/show.html.haml +3 -5
- metadata +127 -104
data/Manifest
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
README.rdoc
|
2
|
+
Manifest
|
3
|
+
lib/pizza_generators.rb
|
4
|
+
TODO
|
5
|
+
LICENSE
|
6
|
+
test/test_helper.rb
|
7
|
+
test/test_pizza_authentication_generator.rb
|
8
|
+
test/test_pizza_config_generator.rb
|
9
|
+
test/test_pizza_layout_generator.rb
|
10
|
+
test/test_pizza_scaffold_generator.rb
|
11
|
+
CHANGELOG
|
12
|
+
Rakefile
|
13
|
+
tasks/deployment.rake
|
14
|
+
rails_generators/pizza_scaffold/USAGE
|
15
|
+
rails_generators/pizza_scaffold/templates/helper.rb
|
16
|
+
rails_generators/pizza_scaffold/templates/fixtures.yml
|
17
|
+
rails_generators/pizza_scaffold/templates/actions/edit.rb
|
18
|
+
rails_generators/pizza_scaffold/templates/actions/index.rb
|
19
|
+
rails_generators/pizza_scaffold/templates/actions/update.rb
|
20
|
+
rails_generators/pizza_scaffold/templates/actions/show.rb
|
21
|
+
rails_generators/pizza_scaffold/templates/actions/destroy.rb
|
22
|
+
rails_generators/pizza_scaffold/templates/actions/create.rb
|
23
|
+
rails_generators/pizza_scaffold/templates/actions/new.rb
|
24
|
+
rails_generators/pizza_scaffold/templates/migration.rb
|
25
|
+
rails_generators/pizza_scaffold/templates/controller.rb
|
26
|
+
rails_generators/pizza_scaffold/templates/views/erb/edit.html.erb
|
27
|
+
rails_generators/pizza_scaffold/templates/views/erb/index.html.erb
|
28
|
+
rails_generators/pizza_scaffold/templates/views/erb/new.html.erb
|
29
|
+
rails_generators/pizza_scaffold/templates/views/erb/_form.html.erb
|
30
|
+
rails_generators/pizza_scaffold/templates/views/erb/show.html.erb
|
31
|
+
rails_generators/pizza_scaffold/templates/views/haml/new.html.haml
|
32
|
+
rails_generators/pizza_scaffold/templates/views/haml/_form.html.haml
|
33
|
+
rails_generators/pizza_scaffold/templates/views/haml/edit.html.haml
|
34
|
+
rails_generators/pizza_scaffold/templates/views/haml/show.html.haml
|
35
|
+
rails_generators/pizza_scaffold/templates/views/haml/index.html.haml
|
36
|
+
rails_generators/pizza_scaffold/templates/model.rb
|
37
|
+
rails_generators/pizza_scaffold/templates/tests/shoulda/actions/edit.rb
|
38
|
+
rails_generators/pizza_scaffold/templates/tests/shoulda/actions/index.rb
|
39
|
+
rails_generators/pizza_scaffold/templates/tests/shoulda/actions/update.rb
|
40
|
+
rails_generators/pizza_scaffold/templates/tests/shoulda/actions/show.rb
|
41
|
+
rails_generators/pizza_scaffold/templates/tests/shoulda/actions/destroy.rb
|
42
|
+
rails_generators/pizza_scaffold/templates/tests/shoulda/actions/create.rb
|
43
|
+
rails_generators/pizza_scaffold/templates/tests/shoulda/actions/new.rb
|
44
|
+
rails_generators/pizza_scaffold/templates/tests/shoulda/controller.rb
|
45
|
+
rails_generators/pizza_scaffold/templates/tests/shoulda/model.rb
|
46
|
+
rails_generators/pizza_scaffold/templates/tests/rspec/actions/edit.rb
|
47
|
+
rails_generators/pizza_scaffold/templates/tests/rspec/actions/index.rb
|
48
|
+
rails_generators/pizza_scaffold/templates/tests/rspec/actions/update.rb
|
49
|
+
rails_generators/pizza_scaffold/templates/tests/rspec/actions/show.rb
|
50
|
+
rails_generators/pizza_scaffold/templates/tests/rspec/actions/destroy.rb
|
51
|
+
rails_generators/pizza_scaffold/templates/tests/rspec/actions/create.rb
|
52
|
+
rails_generators/pizza_scaffold/templates/tests/rspec/actions/new.rb
|
53
|
+
rails_generators/pizza_scaffold/templates/tests/rspec/controller.rb
|
54
|
+
rails_generators/pizza_scaffold/templates/tests/rspec/model.rb
|
55
|
+
rails_generators/pizza_scaffold/templates/tests/testunit/actions/edit.rb
|
56
|
+
rails_generators/pizza_scaffold/templates/tests/testunit/actions/index.rb
|
57
|
+
rails_generators/pizza_scaffold/templates/tests/testunit/actions/update.rb
|
58
|
+
rails_generators/pizza_scaffold/templates/tests/testunit/actions/show.rb
|
59
|
+
rails_generators/pizza_scaffold/templates/tests/testunit/actions/destroy.rb
|
60
|
+
rails_generators/pizza_scaffold/templates/tests/testunit/actions/create.rb
|
61
|
+
rails_generators/pizza_scaffold/templates/tests/testunit/actions/new.rb
|
62
|
+
rails_generators/pizza_scaffold/templates/tests/testunit/controller.rb
|
63
|
+
rails_generators/pizza_scaffold/templates/tests/testunit/model.rb
|
64
|
+
rails_generators/pizza_scaffold/pizza_scaffold_generator.rb
|
65
|
+
rails_generators/pizza_layout/USAGE
|
66
|
+
rails_generators/pizza_layout/templates/helper.rb
|
67
|
+
rails_generators/pizza_layout/templates/stylesheet.css
|
68
|
+
rails_generators/pizza_layout/templates/will_paginate.rb
|
69
|
+
rails_generators/pizza_layout/templates/layout.html.erb
|
70
|
+
rails_generators/pizza_layout/templates/application.sass
|
71
|
+
rails_generators/pizza_layout/templates/layout.sass
|
72
|
+
rails_generators/pizza_layout/templates/_menu.html.haml
|
73
|
+
rails_generators/pizza_layout/templates/required.png
|
74
|
+
rails_generators/pizza_layout/templates/layout.html.haml
|
75
|
+
rails_generators/pizza_layout/templates/reset.sass
|
76
|
+
rails_generators/pizza_layout/templates/tables.sass
|
77
|
+
rails_generators/pizza_layout/templates/forms.sass
|
78
|
+
rails_generators/pizza_layout/templates/definition_lists.sass
|
79
|
+
rails_generators/pizza_layout/pizza_layout_generator.rb
|
80
|
+
rails_generators/pizza_authentication/lib/insert_commands.rb
|
81
|
+
rails_generators/pizza_authentication/USAGE
|
82
|
+
rails_generators/pizza_authentication/templates/authentication.rb
|
83
|
+
rails_generators/pizza_authentication/templates/fixtures.yml
|
84
|
+
rails_generators/pizza_authentication/templates/users_controller.rb
|
85
|
+
rails_generators/pizza_authentication/templates/session.rb
|
86
|
+
rails_generators/pizza_authentication/templates/migration.rb
|
87
|
+
rails_generators/pizza_authentication/templates/users_helper.rb
|
88
|
+
rails_generators/pizza_authentication/templates/views/erb/login.html.erb
|
89
|
+
rails_generators/pizza_authentication/templates/views/erb/signup.html.erb
|
90
|
+
rails_generators/pizza_authentication/templates/views/haml/new.html.haml
|
91
|
+
rails_generators/pizza_authentication/templates/views/haml/signup.html.haml
|
92
|
+
rails_generators/pizza_authentication/templates/views/haml/login.html.haml
|
93
|
+
rails_generators/pizza_authentication/templates/views/haml/edit.html.haml
|
94
|
+
rails_generators/pizza_authentication/templates/views/haml/show.html.haml
|
95
|
+
rails_generators/pizza_authentication/templates/user.rb
|
96
|
+
rails_generators/pizza_authentication/templates/sessions_controller.rb
|
97
|
+
rails_generators/pizza_authentication/templates/initializer.rb
|
98
|
+
rails_generators/pizza_authentication/templates/factories.rb
|
99
|
+
rails_generators/pizza_authentication/templates/sessions_helper.rb
|
100
|
+
rails_generators/pizza_authentication/templates/tests/shoulda/users_controller.rb
|
101
|
+
rails_generators/pizza_authentication/templates/tests/shoulda/user.rb
|
102
|
+
rails_generators/pizza_authentication/templates/tests/shoulda/sessions_controller.rb
|
103
|
+
rails_generators/pizza_authentication/templates/tests/rspec/users_controller.rb
|
104
|
+
rails_generators/pizza_authentication/templates/tests/rspec/user.rb
|
105
|
+
rails_generators/pizza_authentication/templates/tests/rspec/sessions_controller.rb
|
106
|
+
rails_generators/pizza_authentication/templates/tests/testunit/users_controller.rb
|
107
|
+
rails_generators/pizza_authentication/templates/tests/testunit/user.rb
|
108
|
+
rails_generators/pizza_authentication/templates/tests/testunit/sessions_controller.rb
|
109
|
+
rails_generators/pizza_authentication/pizza_authentication_generator.rb
|
110
|
+
rails_generators/pizza_config/USAGE
|
111
|
+
rails_generators/pizza_config/templates/config.yml
|
112
|
+
rails_generators/pizza_config/templates/load_config.rb
|
113
|
+
rails_generators/pizza_config/pizza_config_generator.rb
|
data/README.rdoc
CHANGED
@@ -15,19 +15,30 @@ Here is what is Pizza compared to Nifty:
|
|
15
15
|
|
16
16
|
==== Done
|
17
17
|
|
18
|
+
|
19
|
+
===== Global
|
20
|
+
|
18
21
|
* Haml is default for pizza_scaffold, use <tt>--erb</tt> to switch back to erb
|
22
|
+
* usage of the pizza form builder (from http://github.com/iain/pizza-form_builder)
|
23
|
+
* Using Shoulda matchers in RSpec (http://dev.thoughtbot.com/shoulda/)
|
24
|
+
* Using RR as mocking framework (http://github.com/btakita/rr)
|
25
|
+
|
26
|
+
===== pizza_scaffold
|
27
|
+
|
19
28
|
* definition_list_for (from http://github.com/iain/model_based_html)
|
20
29
|
* table_for (from http://github.com/iain/model_based_html)
|
21
|
-
* form_for (from http://github.com/iain/fieldset_helper)
|
22
|
-
* ResourceController (from http://github.com/giraffesoft/resource_controller)
|
23
30
|
* Rails i18n and supposes Mr. T (from http://github.com/iain/mr.-t)
|
24
31
|
* WillPaginate (from http://github.com/mislav/will_paginate)
|
25
32
|
* Some validations for models automaticly entered and some belongs_to stuff too
|
33
|
+
|
34
|
+
===== pizza_layout
|
35
|
+
|
26
36
|
* reset.sass for layout will keep your view tidy
|
27
37
|
* A main menu was added in app/views/shared/_menu.html.haml
|
28
|
-
* Provides a cancel_link helper
|
29
38
|
* Added WillPaginate.translate! to support i18n (see below)
|
30
|
-
|
39
|
+
|
40
|
+
===== pizza_authentication
|
41
|
+
|
31
42
|
* AuthLogic usage with pizza_authentication (from http://github.com/binarylogic/authlogic)
|
32
43
|
* Added gem dependencies to pizza-generators (my first try, so hopefully that works)
|
33
44
|
|
@@ -37,27 +48,38 @@ Here is what is Pizza compared to Nifty:
|
|
37
48
|
* Add message_block gem (from http://github.com/railsgarden/message_block)
|
38
49
|
* Use a FactoryGirl instead of fixtures
|
39
50
|
* Cucumber stories for RESTful controller in scaffold
|
40
|
-
* Update ERB, Test::Unit and Shoulda all over the place
|
51
|
+
* Update ERB, Test::Unit and Shoulda all over the place (I hardly touched those)
|
41
52
|
* Do something with Rails shiny new feature: Templates
|
42
53
|
* Make the required plugins gems so they can be a gem dependency (not sure though)
|
43
54
|
|
55
|
+
=== No longer in it
|
56
|
+
|
57
|
+
* ResourceController (from http://github.com/giraffesoft/resource_controller)
|
58
|
+
* Provides a cancel_link helper
|
59
|
+
* A cancel link for every form
|
60
|
+
|
61
|
+
|
44
62
|
== Setting up
|
45
63
|
|
46
64
|
Before doing anything, add these lines to <tt>config/environment.rb</tt>
|
47
65
|
|
48
66
|
config.gem "haml"
|
49
67
|
config.gem "authlogic"
|
50
|
-
config.gem "giraffesoft-resource_controller", :lib => "resource_controller", :source => "http://gems.github.com"
|
51
68
|
config.gem "mislav-will_paginate", :lib => "will_paginate", :source => "http://gems.github.com"
|
52
|
-
|
53
|
-
|
54
|
-
|
69
|
+
|
70
|
+
And in <tt>config/environments/test.rb</tt>
|
71
|
+
|
72
|
+
config.gem "rspec", :lib => false, :version => ">= 1.2.2"
|
73
|
+
config.gem "rspec-rails", :lib => false, :version => ">= 1.2.2"
|
74
|
+
config.gem "rr", :lib => false, :version => ">= 0.8.1"
|
75
|
+
config.gem "thoughtbot-factory_girl", :lib => "factory_girl", :version => ">= 1.2.0", :source => "http://gems.github.com"
|
76
|
+
config.gem "thoughtbot-shoulda", :lib => "shoulda", :version => ">= 2.10.1", :source => "http://gems.github.com"
|
55
77
|
|
56
78
|
Then run these commands:
|
57
79
|
|
58
80
|
sudo rake gems:install # this should have already been done via the gem dependencies
|
81
|
+
sudo rake gems:install RAILS_ENV=test
|
59
82
|
rake gems:unpack
|
60
|
-
haml --rails .
|
61
83
|
./script/generate rspec
|
62
84
|
|
63
85
|
Install plugins:
|
@@ -67,9 +89,9 @@ Install plugins:
|
|
67
89
|
./script/plugin install git://github.com/iain/model_based_html.git
|
68
90
|
./script/plugin install git://github.com/iain/i18n_label.git
|
69
91
|
|
70
|
-
Configure rspec to use
|
92
|
+
Configure rspec to use rr, in <tt>spec/spec_helper.rb</tt>
|
71
93
|
|
72
|
-
config.mock_with :
|
94
|
+
config.mock_with :rr
|
73
95
|
|
74
96
|
Generate layout (required for all other generators):
|
75
97
|
|
data/Rakefile
CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
|
|
2
2
|
require 'rake'
|
3
3
|
require 'echoe'
|
4
4
|
|
5
|
-
Echoe.new('pizza-generators', '0.1.
|
5
|
+
Echoe.new('pizza-generators', '0.1.3') do |p|
|
6
6
|
p.project = "pizzagenerators"
|
7
7
|
p.description = "A collection of useful generator scripts for Rails."
|
8
8
|
p.url = "http://github.com/iain/pizza-generators"
|
@@ -10,7 +10,7 @@ Echoe.new('pizza-generators', '0.1.2') do |p|
|
|
10
10
|
p.email = "iain@iain.nl"
|
11
11
|
p.ignore_pattern = ["script/*"]
|
12
12
|
p.development_dependencies = []
|
13
|
-
p.runtime_dependencies = ["authlogic", "
|
13
|
+
p.runtime_dependencies = ["authlogic", "mislav-will_paginate", "rspec", "rspec-rails", "rr", "haml", "thoughtbot-shoulda", "thoughtbot-factory_girl"]
|
14
14
|
end
|
15
15
|
|
16
16
|
Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
|
data/pizza-generators.gemspec
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{pizza-generators}
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.3"
|
6
6
|
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 1.
|
8
|
-
s.authors = ["Ryan Bates, Iain Hecker"]
|
9
|
-
s.date = %q{2009-
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 1.3") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Ryan Bates", "Iain Hecker"]
|
9
|
+
s.date = %q{2009-04-17}
|
10
10
|
s.description = %q{A collection of useful generator scripts for Rails.}
|
11
11
|
s.email = %q{iain@iain.nl}
|
12
|
-
s.extra_rdoc_files = ["lib/pizza_generators.rb", "
|
13
|
-
s.files = ["
|
12
|
+
s.extra_rdoc_files = ["README.rdoc", "lib/pizza_generators.rb", "TODO", "LICENSE", "CHANGELOG", "tasks/deployment.rake"]
|
13
|
+
s.files = ["README.rdoc", "Manifest", "lib/pizza_generators.rb", "TODO", "LICENSE", "test/test_helper.rb", "test/test_pizza_authentication_generator.rb", "test/test_pizza_config_generator.rb", "test/test_pizza_layout_generator.rb", "test/test_pizza_scaffold_generator.rb", "CHANGELOG", "Rakefile", "tasks/deployment.rake", "rails_generators/pizza_scaffold/USAGE", "rails_generators/pizza_scaffold/templates/helper.rb", "rails_generators/pizza_scaffold/templates/fixtures.yml", "rails_generators/pizza_scaffold/templates/actions/edit.rb", "rails_generators/pizza_scaffold/templates/actions/index.rb", "rails_generators/pizza_scaffold/templates/actions/update.rb", "rails_generators/pizza_scaffold/templates/actions/show.rb", "rails_generators/pizza_scaffold/templates/actions/destroy.rb", "rails_generators/pizza_scaffold/templates/actions/create.rb", "rails_generators/pizza_scaffold/templates/actions/new.rb", "rails_generators/pizza_scaffold/templates/migration.rb", "rails_generators/pizza_scaffold/templates/controller.rb", "rails_generators/pizza_scaffold/templates/views/erb/edit.html.erb", "rails_generators/pizza_scaffold/templates/views/erb/index.html.erb", "rails_generators/pizza_scaffold/templates/views/erb/new.html.erb", "rails_generators/pizza_scaffold/templates/views/erb/_form.html.erb", "rails_generators/pizza_scaffold/templates/views/erb/show.html.erb", "rails_generators/pizza_scaffold/templates/views/haml/new.html.haml", "rails_generators/pizza_scaffold/templates/views/haml/_form.html.haml", "rails_generators/pizza_scaffold/templates/views/haml/edit.html.haml", "rails_generators/pizza_scaffold/templates/views/haml/show.html.haml", "rails_generators/pizza_scaffold/templates/views/haml/index.html.haml", "rails_generators/pizza_scaffold/templates/model.rb", "rails_generators/pizza_scaffold/templates/tests/shoulda/actions/edit.rb", "rails_generators/pizza_scaffold/templates/tests/shoulda/actions/index.rb", "rails_generators/pizza_scaffold/templates/tests/shoulda/actions/update.rb", "rails_generators/pizza_scaffold/templates/tests/shoulda/actions/show.rb", "rails_generators/pizza_scaffold/templates/tests/shoulda/actions/destroy.rb", "rails_generators/pizza_scaffold/templates/tests/shoulda/actions/create.rb", "rails_generators/pizza_scaffold/templates/tests/shoulda/actions/new.rb", "rails_generators/pizza_scaffold/templates/tests/shoulda/controller.rb", "rails_generators/pizza_scaffold/templates/tests/shoulda/model.rb", "rails_generators/pizza_scaffold/templates/tests/rspec/actions/edit.rb", "rails_generators/pizza_scaffold/templates/tests/rspec/actions/index.rb", "rails_generators/pizza_scaffold/templates/tests/rspec/actions/update.rb", "rails_generators/pizza_scaffold/templates/tests/rspec/actions/show.rb", "rails_generators/pizza_scaffold/templates/tests/rspec/actions/destroy.rb", "rails_generators/pizza_scaffold/templates/tests/rspec/actions/create.rb", "rails_generators/pizza_scaffold/templates/tests/rspec/actions/new.rb", "rails_generators/pizza_scaffold/templates/tests/rspec/controller.rb", "rails_generators/pizza_scaffold/templates/tests/rspec/model.rb", "rails_generators/pizza_scaffold/templates/tests/testunit/actions/edit.rb", "rails_generators/pizza_scaffold/templates/tests/testunit/actions/index.rb", "rails_generators/pizza_scaffold/templates/tests/testunit/actions/update.rb", "rails_generators/pizza_scaffold/templates/tests/testunit/actions/show.rb", "rails_generators/pizza_scaffold/templates/tests/testunit/actions/destroy.rb", "rails_generators/pizza_scaffold/templates/tests/testunit/actions/create.rb", "rails_generators/pizza_scaffold/templates/tests/testunit/actions/new.rb", "rails_generators/pizza_scaffold/templates/tests/testunit/controller.rb", "rails_generators/pizza_scaffold/templates/tests/testunit/model.rb", "rails_generators/pizza_scaffold/pizza_scaffold_generator.rb", "rails_generators/pizza_layout/USAGE", "rails_generators/pizza_layout/templates/helper.rb", "rails_generators/pizza_layout/templates/stylesheet.css", "rails_generators/pizza_layout/templates/will_paginate.rb", "rails_generators/pizza_layout/templates/layout.html.erb", "rails_generators/pizza_layout/templates/application.sass", "rails_generators/pizza_layout/templates/layout.sass", "rails_generators/pizza_layout/templates/_menu.html.haml", "rails_generators/pizza_layout/templates/required.png", "rails_generators/pizza_layout/templates/layout.html.haml", "rails_generators/pizza_layout/templates/reset.sass", "rails_generators/pizza_layout/templates/tables.sass", "rails_generators/pizza_layout/templates/forms.sass", "rails_generators/pizza_layout/templates/definition_lists.sass", "rails_generators/pizza_layout/pizza_layout_generator.rb", "rails_generators/pizza_authentication/lib/insert_commands.rb", "rails_generators/pizza_authentication/USAGE", "rails_generators/pizza_authentication/templates/authentication.rb", "rails_generators/pizza_authentication/templates/fixtures.yml", "rails_generators/pizza_authentication/templates/users_controller.rb", "rails_generators/pizza_authentication/templates/session.rb", "rails_generators/pizza_authentication/templates/migration.rb", "rails_generators/pizza_authentication/templates/users_helper.rb", "rails_generators/pizza_authentication/templates/views/erb/login.html.erb", "rails_generators/pizza_authentication/templates/views/erb/signup.html.erb", "rails_generators/pizza_authentication/templates/views/haml/new.html.haml", "rails_generators/pizza_authentication/templates/views/haml/signup.html.haml", "rails_generators/pizza_authentication/templates/views/haml/login.html.haml", "rails_generators/pizza_authentication/templates/views/haml/edit.html.haml", "rails_generators/pizza_authentication/templates/views/haml/show.html.haml", "rails_generators/pizza_authentication/templates/user.rb", "rails_generators/pizza_authentication/templates/sessions_controller.rb", "rails_generators/pizza_authentication/templates/initializer.rb", "rails_generators/pizza_authentication/templates/factories.rb", "rails_generators/pizza_authentication/templates/sessions_helper.rb", "rails_generators/pizza_authentication/templates/tests/shoulda/users_controller.rb", "rails_generators/pizza_authentication/templates/tests/shoulda/user.rb", "rails_generators/pizza_authentication/templates/tests/shoulda/sessions_controller.rb", "rails_generators/pizza_authentication/templates/tests/rspec/users_controller.rb", "rails_generators/pizza_authentication/templates/tests/rspec/user.rb", "rails_generators/pizza_authentication/templates/tests/rspec/sessions_controller.rb", "rails_generators/pizza_authentication/templates/tests/testunit/users_controller.rb", "rails_generators/pizza_authentication/templates/tests/testunit/user.rb", "rails_generators/pizza_authentication/templates/tests/testunit/sessions_controller.rb", "rails_generators/pizza_authentication/pizza_authentication_generator.rb", "rails_generators/pizza_config/USAGE", "rails_generators/pizza_config/templates/config.yml", "rails_generators/pizza_config/templates/load_config.rb", "rails_generators/pizza_config/pizza_config_generator.rb", "pizza-generators.gemspec"]
|
14
14
|
s.has_rdoc = true
|
15
15
|
s.homepage = %q{http://github.com/iain/pizza-generators}
|
16
16
|
s.rdoc_options = ["--line-numbers", "--inline-source", "--title", "Pizza-generators", "--main", "README.rdoc"]
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.rubyforge_project = %q{pizzagenerators}
|
19
19
|
s.rubygems_version = %q{1.3.1}
|
20
20
|
s.summary = %q{A collection of useful generator scripts for Rails.}
|
21
|
-
s.test_files = ["test/
|
21
|
+
s.test_files = ["test/test_helper.rb", "test/test_pizza_authentication_generator.rb", "test/test_pizza_config_generator.rb", "test/test_pizza_layout_generator.rb", "test/test_pizza_scaffold_generator.rb"]
|
22
22
|
|
23
23
|
if s.respond_to? :specification_version then
|
24
24
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
@@ -26,28 +26,31 @@ Gem::Specification.new do |s|
|
|
26
26
|
|
27
27
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
28
28
|
s.add_runtime_dependency(%q<authlogic>, [">= 0"])
|
29
|
-
s.add_runtime_dependency(%q<giraffesoft-resource_controller>, [">= 0"])
|
30
29
|
s.add_runtime_dependency(%q<mislav-will_paginate>, [">= 0"])
|
31
30
|
s.add_runtime_dependency(%q<rspec>, [">= 0"])
|
32
31
|
s.add_runtime_dependency(%q<rspec-rails>, [">= 0"])
|
33
|
-
s.add_runtime_dependency(%q<
|
32
|
+
s.add_runtime_dependency(%q<rr>, [">= 0"])
|
34
33
|
s.add_runtime_dependency(%q<haml>, [">= 0"])
|
34
|
+
s.add_runtime_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
35
|
+
s.add_runtime_dependency(%q<thoughtbot-factory_girl>, [">= 0"])
|
35
36
|
else
|
36
37
|
s.add_dependency(%q<authlogic>, [">= 0"])
|
37
|
-
s.add_dependency(%q<giraffesoft-resource_controller>, [">= 0"])
|
38
38
|
s.add_dependency(%q<mislav-will_paginate>, [">= 0"])
|
39
39
|
s.add_dependency(%q<rspec>, [">= 0"])
|
40
40
|
s.add_dependency(%q<rspec-rails>, [">= 0"])
|
41
|
-
s.add_dependency(%q<
|
41
|
+
s.add_dependency(%q<rr>, [">= 0"])
|
42
42
|
s.add_dependency(%q<haml>, [">= 0"])
|
43
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
44
|
+
s.add_dependency(%q<thoughtbot-factory_girl>, [">= 0"])
|
43
45
|
end
|
44
46
|
else
|
45
47
|
s.add_dependency(%q<authlogic>, [">= 0"])
|
46
|
-
s.add_dependency(%q<giraffesoft-resource_controller>, [">= 0"])
|
47
48
|
s.add_dependency(%q<mislav-will_paginate>, [">= 0"])
|
48
49
|
s.add_dependency(%q<rspec>, [">= 0"])
|
49
50
|
s.add_dependency(%q<rspec-rails>, [">= 0"])
|
50
|
-
s.add_dependency(%q<
|
51
|
+
s.add_dependency(%q<rr>, [">= 0"])
|
51
52
|
s.add_dependency(%q<haml>, [">= 0"])
|
53
|
+
s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
|
54
|
+
s.add_dependency(%q<thoughtbot-factory_girl>, [">= 0"])
|
52
55
|
end
|
53
56
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + "/lib/insert_commands.rb")
|
2
2
|
class PizzaAuthenticationGenerator < Rails::Generator::Base
|
3
3
|
attr_accessor :user_name, :user_session_name
|
4
|
-
|
4
|
+
|
5
5
|
def initialize(runtime_args, runtime_options = {})
|
6
6
|
super
|
7
|
-
|
8
|
-
@user_name = @args[0] || '
|
9
|
-
@user_session_name = @user_name + '_session'
|
7
|
+
|
8
|
+
@user_name = @args[0] || 'account'
|
9
|
+
@user_session_name = @args[1] || @user_name + '_session'
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
def manifest
|
13
13
|
record do |m|
|
14
14
|
m.directory "app/models"
|
@@ -16,56 +16,64 @@ class PizzaAuthenticationGenerator < Rails::Generator::Base
|
|
16
16
|
m.directory "app/helpers"
|
17
17
|
m.directory "app/views"
|
18
18
|
m.directory "lib"
|
19
|
-
|
19
|
+
|
20
20
|
m.directory "app/views/#{user_plural_name}"
|
21
21
|
m.template "user.rb", "app/models/#{user_singular_name}.rb"
|
22
22
|
m.template "users_controller.rb", "app/controllers/#{user_plural_name}_controller.rb"
|
23
23
|
m.template "users_helper.rb", "app/helpers/#{user_plural_name}_helper.rb"
|
24
24
|
m.template "views/#{view_language}/signup.html.#{view_language}", "app/views/#{user_plural_name}/new.html.#{view_language}"
|
25
|
-
|
25
|
+
|
26
26
|
m.directory "app/views/#{user_session_plural_name}"
|
27
27
|
m.template "session.rb", "app/models/#{user_session_singular_name}.rb"
|
28
28
|
m.template "sessions_controller.rb", "app/controllers/#{user_session_plural_name}_controller.rb"
|
29
|
+
|
29
30
|
m.template "sessions_helper.rb", "app/helpers/#{user_session_plural_name}_helper.rb"
|
30
31
|
m.template "views/#{view_language}/login.html.#{view_language}", "app/views/#{user_session_plural_name}/new.html.#{view_language}"
|
31
|
-
|
32
|
+
|
32
33
|
m.template "authentication.rb", "lib/authentication.rb"
|
33
34
|
m.migration_template "migration.rb", "db/migrate", :migration_file_name => "create_#{user_plural_name}"
|
34
|
-
|
35
|
+
|
35
36
|
m.route_resources user_plural_name
|
36
37
|
m.route_resources user_session_plural_name
|
37
38
|
m.route_name :login, 'login', :controller => user_session_plural_name, :action => 'new'
|
38
39
|
m.route_name :logout, 'logout', :controller => user_session_plural_name, :action => 'destroy'
|
39
40
|
m.route_name :signup, 'signup', :controller => user_plural_name, :action => 'new'
|
40
|
-
|
41
|
-
m.insert_into
|
42
|
-
|
41
|
+
|
42
|
+
m.insert_into application_controller, "filter_parameter_logging :password, :password_confirmation"
|
43
|
+
m.insert_into application_controller, 'include Authentication'
|
44
|
+
m.insert_into application_controller, 'unloadable'
|
45
|
+
|
46
|
+
m.directory "app/factories"
|
47
|
+
m.directory "config/initializers"
|
48
|
+
m.file 'initializer.rb', 'config/initializers/factories.rb', :collision => :skip
|
49
|
+
m.template "factories.rb", "app/factories/#{user_plural_name}.rb"
|
50
|
+
|
43
51
|
if test_framework == :rspec
|
44
52
|
m.directory "spec"
|
45
|
-
m.directory "spec/fixtures"
|
46
53
|
m.directory "spec/controllers"
|
47
54
|
m.directory "spec/models"
|
48
|
-
m.template "fixtures.yml", "spec/fixtures/#{user_plural_name}.yml"
|
49
55
|
m.template "tests/rspec/user.rb", "spec/models/#{user_singular_name}_spec.rb"
|
50
56
|
m.template "tests/rspec/users_controller.rb", "spec/controllers/#{user_plural_name}_controller_spec.rb"
|
51
57
|
m.template "tests/rspec/sessions_controller.rb", "spec/controllers/#{user_session_plural_name}_controller_spec.rb"
|
52
58
|
else
|
53
59
|
m.directory "test"
|
54
|
-
m.directory "test/fixtures"
|
55
60
|
m.directory "test/functional"
|
56
61
|
m.directory "test/unit"
|
57
|
-
m.template "fixtures.yml", "test/fixtures/#{user_plural_name}.yml"
|
58
62
|
m.template "tests/#{test_framework}/user.rb", "test/unit/#{user_singular_name}_test.rb"
|
59
63
|
m.template "tests/#{test_framework}/users_controller.rb", "test/functional/#{user_plural_name}_controller_test.rb"
|
60
64
|
m.template "tests/#{test_framework}/sessions_controller.rb", "test/functional/#{user_session_plural_name}_controller_test.rb"
|
61
65
|
end
|
62
66
|
end
|
63
67
|
end
|
64
|
-
|
68
|
+
|
69
|
+
def application_controller
|
70
|
+
"app/controllers/#{Rails.version.to_f < 2.3 ? "application" : "application_controller"}.rb"
|
71
|
+
end
|
72
|
+
|
65
73
|
def user_singular_name
|
66
74
|
user_name.underscore
|
67
75
|
end
|
68
|
-
|
76
|
+
|
69
77
|
def user_plural_name
|
70
78
|
user_singular_name.pluralize
|
71
79
|
end
|
@@ -73,7 +81,7 @@ class PizzaAuthenticationGenerator < Rails::Generator::Base
|
|
73
81
|
def user_class_name
|
74
82
|
user_name.camelize
|
75
83
|
end
|
76
|
-
|
84
|
+
|
77
85
|
def user_plural_class_name
|
78
86
|
user_plural_name.camelize
|
79
87
|
end
|
@@ -95,15 +103,15 @@ class PizzaAuthenticationGenerator < Rails::Generator::Base
|
|
95
103
|
end
|
96
104
|
|
97
105
|
protected
|
98
|
-
|
106
|
+
|
99
107
|
def view_language
|
100
108
|
options[:erb] ? 'erb' : 'haml'
|
101
109
|
end
|
102
|
-
|
110
|
+
|
103
111
|
def test_framework
|
104
112
|
options[:test_framework] ||= File.exist?(destination_path("spec")) ? :rspec : :testunit
|
105
113
|
end
|
106
|
-
|
114
|
+
|
107
115
|
def add_options!(opt)
|
108
116
|
opt.separator ''
|
109
117
|
opt.separator 'Options:'
|
@@ -112,12 +120,12 @@ protected
|
|
112
120
|
opt.on("--shoulda", "Use Shoulda for test files.") { options[:test_framework] = :shoulda }
|
113
121
|
opt.on("--erb", "Generate ERB views instead of HAML.") { |v| options[:erb] = true }
|
114
122
|
end
|
115
|
-
|
123
|
+
|
116
124
|
def banner
|
117
125
|
<<-EOS
|
118
126
|
Creates user model and controllers to handle registration and authentication.
|
119
127
|
|
120
|
-
USAGE: #{$0} #{spec.name} [user_name] [
|
128
|
+
USAGE: #{$0} #{spec.name} [user_name] [session_name]
|
121
129
|
EOS
|
122
130
|
end
|
123
131
|
end
|
@@ -18,26 +18,52 @@ module Authentication
|
|
18
18
|
|
19
19
|
def self.included(controller)
|
20
20
|
controller.send :helper_method, :current_<%= user_singular_name %>, :logged_in?, :current_<%= user_session_singular_name %>
|
21
|
+
controller.send :before_filter, :activate_authlogic
|
22
|
+
controller.send :before_filter, :load_<%= user_session_singular_name %>
|
21
23
|
end
|
22
|
-
|
23
|
-
def
|
24
|
-
|
25
|
-
@current_<%= user_singular_name %> =
|
24
|
+
|
25
|
+
def load_<%= user_session_singular_name %>
|
26
|
+
@<%= user_session_singular_name %> = <%= user_session_class_name %>.find
|
27
|
+
@current_<%= user_singular_name %> = @<%= user_session_singular_name %> && @<%= user_session_singular_name %>.<%= user_singular_name %>
|
26
28
|
end
|
27
29
|
|
28
30
|
def current_<%= user_session_singular_name %>
|
29
|
-
|
30
|
-
@current_<%= user_session_singular_name %> = <%= user_session_class_name %>.find
|
31
|
+
@<%= user_session_singular_name %>
|
31
32
|
end
|
32
|
-
|
33
|
+
|
34
|
+
def current_<%= user_singular_name %>
|
35
|
+
@current_<%= user_singular_name %>
|
36
|
+
end
|
37
|
+
|
33
38
|
def logged_in?
|
34
|
-
current_<%= user_singular_name %>
|
39
|
+
!!current_<%= user_singular_name %>
|
35
40
|
end
|
36
|
-
|
41
|
+
|
37
42
|
def login_required
|
38
43
|
unless logged_in?
|
39
44
|
flash[:error] = I18n.t("<%= user_session_plural_name %>.login_required")
|
40
45
|
redirect_to login_url
|
41
46
|
end
|
42
47
|
end
|
48
|
+
|
49
|
+
def logout_required
|
50
|
+
if logged_in?
|
51
|
+
flash[:error] = I18n.t("<%= user_session_plural_name %>.logout_required")
|
52
|
+
redirect_to root_url
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def activate_authlogic
|
57
|
+
Authlogic::Session::Base.controller = Authlogic::ControllerAdapters::RailsAdapter.new(self)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Uncomment this method when you have an admin and want to filter for it.
|
61
|
+
# def admin_required
|
62
|
+
# return login_required unless logged_in?
|
63
|
+
# unless current_<%= user_singular_name %>.admin?
|
64
|
+
# flash[:error] = I18n.t("<%= user_session_plural_name %>.admin_required")
|
65
|
+
# redirect_to root_url
|
66
|
+
# end
|
67
|
+
# end
|
68
|
+
|
43
69
|
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
Factory.sequence :<%= user_singular_name %>_login do |n|
|
2
|
+
"user#{n unless n == 1}"
|
3
|
+
end
|
4
|
+
|
5
|
+
Factory.define :<%= user_singular_name %> do |f|
|
6
|
+
f.login { Factory.next(:<%= user_singular_name %>_login) }
|
7
|
+
f.password { |o| o.login.gsub(/W+/, "_") }
|
8
|
+
f.password_confirmation { |o| o.password }
|
9
|
+
f.email { |o| o.login.gsub(/W+/, "_") + "@test.com" }
|
10
|
+
end
|
11
|
+
|
12
|
+
# Create factories for additional roles like this:
|
13
|
+
#
|
14
|
+
# Factory.sequence :admin_login do |n|
|
15
|
+
# "admin#{n unless n == 1}"
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# Factory.define :admin, :class => <%= user_class_name %> do |f|
|
19
|
+
# f.login { Factory.next(:admin_login) }
|
20
|
+
# f.password { |o| o.login.gsub(/W+/, "_") }
|
21
|
+
# f.password_confirmation { |o| o.password }
|
22
|
+
# f.email { |o| o.login.gsub(/W+/, "_") + "@test.com" }
|
23
|
+
# f.admin true
|
24
|
+
# end
|
@@ -4,11 +4,12 @@ class Create<%= user_plural_class_name %> < ActiveRecord::Migration
|
|
4
4
|
|
5
5
|
# Required database fields
|
6
6
|
t.string :login, :null => false
|
7
|
+
t.string :email, :null => false
|
7
8
|
t.string :crypted_password, :null => false
|
8
9
|
t.string :password_salt, :null => false
|
9
10
|
t.string :persistence_token, :null => false
|
10
11
|
|
11
|
-
# Optional tokens
|
12
|
+
# Optional tokens
|
12
13
|
# t.string :single_access_token, :null => false # or: rss_feed_token
|
13
14
|
# t.string :perishable_token, :null => false # or: pw_reset_token, activation_token
|
14
15
|
|
@@ -20,14 +21,23 @@ class Create<%= user_plural_class_name %> < ActiveRecord::Migration
|
|
20
21
|
t.string :current_login_ip
|
21
22
|
t.string :last_login_ip
|
22
23
|
|
23
|
-
#
|
24
|
-
t.boolean :active, :null => false, :default => true
|
24
|
+
# Magic states
|
25
|
+
# t.boolean :active, :null => false, :default => true
|
26
|
+
# t.boolean :approved, :null => false, :default => false
|
27
|
+
# t.boolean :confirmed, :null => false, :default => false
|
25
28
|
|
26
29
|
t.timestamps
|
27
30
|
end
|
31
|
+
|
32
|
+
add_index :<%= user_plural_name %>, :login, :unique => true
|
33
|
+
add_index :<%= user_plural_name %>, :email, :unique => true
|
34
|
+
add_index :<%= user_plural_name %>, :persistence_token
|
28
35
|
end
|
29
36
|
|
30
37
|
def self.down
|
31
|
-
|
38
|
+
remove_index :<%= user_plural_name %>, :login
|
39
|
+
remove_index :<%= user_plural_name %>, :email
|
40
|
+
remove_index :<%= user_plural_name %>, :persistence_token
|
41
|
+
drop_table :<%= user_plural_name %>
|
32
42
|
end
|
33
43
|
end
|