nifty-generators 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. data/CHANGELOG +9 -0
  2. data/LICENSE +1 -1
  3. data/README.rdoc +16 -24
  4. data/Rakefile +0 -13
  5. data/test/test_helper.rb +4 -2
  6. data/test/test_nifty_authentication_generator.rb +39 -1
  7. metadata +18 -114
  8. data/Manifest +0 -100
  9. data/TODO +0 -7
  10. data/nifty-generators.gemspec +0 -169
  11. data/rails_generators/nifty_authentication/USAGE +0 -50
  12. data/rails_generators/nifty_authentication/lib/insert_commands.rb +0 -74
  13. data/rails_generators/nifty_authentication/nifty_authentication_generator.rb +0 -128
  14. data/rails_generators/nifty_authentication/templates/authentication.rb +0 -61
  15. data/rails_generators/nifty_authentication/templates/authlogic_session.rb +0 -2
  16. data/rails_generators/nifty_authentication/templates/fixtures.yml +0 -24
  17. data/rails_generators/nifty_authentication/templates/migration.rb +0 -20
  18. data/rails_generators/nifty_authentication/templates/sessions_controller.rb +0 -45
  19. data/rails_generators/nifty_authentication/templates/sessions_helper.rb +0 -2
  20. data/rails_generators/nifty_authentication/templates/tests/rspec/sessions_controller.rb +0 -39
  21. data/rails_generators/nifty_authentication/templates/tests/rspec/user.rb +0 -83
  22. data/rails_generators/nifty_authentication/templates/tests/rspec/users_controller.rb +0 -26
  23. data/rails_generators/nifty_authentication/templates/tests/shoulda/sessions_controller.rb +0 -40
  24. data/rails_generators/nifty_authentication/templates/tests/shoulda/user.rb +0 -85
  25. data/rails_generators/nifty_authentication/templates/tests/shoulda/users_controller.rb +0 -27
  26. data/rails_generators/nifty_authentication/templates/tests/testunit/sessions_controller.rb +0 -36
  27. data/rails_generators/nifty_authentication/templates/tests/testunit/user.rb +0 -88
  28. data/rails_generators/nifty_authentication/templates/tests/testunit/users_controller.rb +0 -23
  29. data/rails_generators/nifty_authentication/templates/user.rb +0 -42
  30. data/rails_generators/nifty_authentication/templates/users_controller.rb +0 -18
  31. data/rails_generators/nifty_authentication/templates/users_helper.rb +0 -2
  32. data/rails_generators/nifty_authentication/templates/views/erb/login.html.erb +0 -30
  33. data/rails_generators/nifty_authentication/templates/views/erb/signup.html.erb +0 -24
  34. data/rails_generators/nifty_authentication/templates/views/haml/login.html.haml +0 -30
  35. data/rails_generators/nifty_authentication/templates/views/haml/signup.html.haml +0 -24
  36. data/rails_generators/nifty_config/USAGE +0 -23
  37. data/rails_generators/nifty_config/nifty_config_generator.rb +0 -32
  38. data/rails_generators/nifty_config/templates/config.yml +0 -8
  39. data/rails_generators/nifty_config/templates/load_config.rb +0 -2
  40. data/rails_generators/nifty_layout/USAGE +0 -25
  41. data/rails_generators/nifty_layout/nifty_layout_generator.rb +0 -44
  42. data/rails_generators/nifty_layout/templates/helper.rb +0 -22
  43. data/rails_generators/nifty_layout/templates/layout.html.erb +0 -22
  44. data/rails_generators/nifty_layout/templates/layout.html.haml +0 -19
  45. data/rails_generators/nifty_layout/templates/stylesheet.css +0 -81
  46. data/rails_generators/nifty_layout/templates/stylesheet.sass +0 -67
  47. data/rails_generators/nifty_scaffold/USAGE +0 -51
  48. data/rails_generators/nifty_scaffold/nifty_scaffold_generator.rb +0 -232
  49. data/rails_generators/nifty_scaffold/templates/actions/create.rb +0 -9
  50. data/rails_generators/nifty_scaffold/templates/actions/destroy.rb +0 -6
  51. data/rails_generators/nifty_scaffold/templates/actions/edit.rb +0 -3
  52. data/rails_generators/nifty_scaffold/templates/actions/index.rb +0 -3
  53. data/rails_generators/nifty_scaffold/templates/actions/new.rb +0 -3
  54. data/rails_generators/nifty_scaffold/templates/actions/show.rb +0 -3
  55. data/rails_generators/nifty_scaffold/templates/actions/update.rb +0 -9
  56. data/rails_generators/nifty_scaffold/templates/controller.rb +0 -3
  57. data/rails_generators/nifty_scaffold/templates/fixtures.yml +0 -9
  58. data/rails_generators/nifty_scaffold/templates/helper.rb +0 -2
  59. data/rails_generators/nifty_scaffold/templates/migration.rb +0 -16
  60. data/rails_generators/nifty_scaffold/templates/model.rb +0 -3
  61. data/rails_generators/nifty_scaffold/templates/tests/rspec/actions/create.rb +0 -11
  62. data/rails_generators/nifty_scaffold/templates/tests/rspec/actions/destroy.rb +0 -6
  63. data/rails_generators/nifty_scaffold/templates/tests/rspec/actions/edit.rb +0 -4
  64. data/rails_generators/nifty_scaffold/templates/tests/rspec/actions/index.rb +0 -4
  65. data/rails_generators/nifty_scaffold/templates/tests/rspec/actions/new.rb +0 -4
  66. data/rails_generators/nifty_scaffold/templates/tests/rspec/actions/show.rb +0 -4
  67. data/rails_generators/nifty_scaffold/templates/tests/rspec/actions/update.rb +0 -11
  68. data/rails_generators/nifty_scaffold/templates/tests/rspec/controller.rb +0 -8
  69. data/rails_generators/nifty_scaffold/templates/tests/rspec/model.rb +0 -7
  70. data/rails_generators/nifty_scaffold/templates/tests/shoulda/actions/create.rb +0 -13
  71. data/rails_generators/nifty_scaffold/templates/tests/shoulda/actions/destroy.rb +0 -8
  72. data/rails_generators/nifty_scaffold/templates/tests/shoulda/actions/edit.rb +0 -6
  73. data/rails_generators/nifty_scaffold/templates/tests/shoulda/actions/index.rb +0 -6
  74. data/rails_generators/nifty_scaffold/templates/tests/shoulda/actions/new.rb +0 -6
  75. data/rails_generators/nifty_scaffold/templates/tests/shoulda/actions/show.rb +0 -6
  76. data/rails_generators/nifty_scaffold/templates/tests/shoulda/actions/update.rb +0 -13
  77. data/rails_generators/nifty_scaffold/templates/tests/shoulda/controller.rb +0 -5
  78. data/rails_generators/nifty_scaffold/templates/tests/shoulda/model.rb +0 -7
  79. data/rails_generators/nifty_scaffold/templates/tests/testunit/actions/create.rb +0 -11
  80. data/rails_generators/nifty_scaffold/templates/tests/testunit/actions/destroy.rb +0 -6
  81. data/rails_generators/nifty_scaffold/templates/tests/testunit/actions/edit.rb +0 -4
  82. data/rails_generators/nifty_scaffold/templates/tests/testunit/actions/index.rb +0 -4
  83. data/rails_generators/nifty_scaffold/templates/tests/testunit/actions/new.rb +0 -4
  84. data/rails_generators/nifty_scaffold/templates/tests/testunit/actions/show.rb +0 -4
  85. data/rails_generators/nifty_scaffold/templates/tests/testunit/actions/update.rb +0 -11
  86. data/rails_generators/nifty_scaffold/templates/tests/testunit/controller.rb +0 -5
  87. data/rails_generators/nifty_scaffold/templates/tests/testunit/model.rb +0 -7
  88. data/rails_generators/nifty_scaffold/templates/views/erb/_form.html.erb +0 -10
  89. data/rails_generators/nifty_scaffold/templates/views/erb/edit.html.erb +0 -14
  90. data/rails_generators/nifty_scaffold/templates/views/erb/index.html.erb +0 -29
  91. data/rails_generators/nifty_scaffold/templates/views/erb/new.html.erb +0 -7
  92. data/rails_generators/nifty_scaffold/templates/views/erb/show.html.erb +0 -20
  93. data/rails_generators/nifty_scaffold/templates/views/haml/_form.html.haml +0 -10
  94. data/rails_generators/nifty_scaffold/templates/views/haml/edit.html.haml +0 -14
  95. data/rails_generators/nifty_scaffold/templates/views/haml/index.html.haml +0 -25
  96. data/rails_generators/nifty_scaffold/templates/views/haml/new.html.haml +0 -7
  97. data/rails_generators/nifty_scaffold/templates/views/haml/show.html.haml +0 -20
  98. data/tasks/deployment.rake +0 -2
@@ -1,23 +0,0 @@
1
- require 'test_helper'
2
-
3
- class <%= user_plural_class_name %>ControllerTest < ActionController::TestCase
4
- def test_new
5
- get :new
6
- assert_template 'new'
7
- end
8
-
9
- def test_create_invalid
10
- <%= user_class_name %>.any_instance.stubs(:valid?).returns(false)
11
- post :create
12
- assert_template 'new'
13
- end
14
-
15
- def test_create_valid
16
- <%= user_class_name %>.any_instance.stubs(:valid?).returns(true)
17
- post :create
18
- assert_redirected_to root_url
19
- <%- unless options[:authlogic] -%>
20
- assert_equal assigns['<%= user_singular_name %>'].id, session['<%= user_singular_name %>_id']
21
- <%- end -%>
22
- end
23
- end
@@ -1,42 +0,0 @@
1
- class <%= user_class_name %> < ActiveRecord::Base
2
- <%- if options[:authlogic] -%>
3
- acts_as_authentic
4
- <%- else -%>
5
- # new columns need to be added here to be writable through mass assignment
6
- attr_accessible :username, :email, :password, :password_confirmation
7
-
8
- attr_accessor :password
9
- before_save :prepare_password
10
-
11
- validates_presence_of :username
12
- validates_uniqueness_of :username, :email, :allow_blank => true
13
- validates_format_of :username, :with => /^[-\w\._@]+$/i, :allow_blank => true, :message => "should only contain letters, numbers, or .-_@"
14
- validates_format_of :email, :with => /^[-a-z0-9_+\.]+\@([-a-z0-9]+\.)+[a-z0-9]{2,4}$/i
15
- validates_presence_of :password, :on => :create
16
- validates_confirmation_of :password
17
- validates_length_of :password, :minimum => 4, :allow_blank => true
18
-
19
- # login can be either username or email address
20
- def self.authenticate(login, pass)
21
- <%= user_singular_name %> = find_by_username(login) || find_by_email(login)
22
- return <%= user_singular_name %> if <%= user_singular_name %> && <%= user_singular_name %>.matching_password?(pass)
23
- end
24
-
25
- def matching_password?(pass)
26
- self.password_hash == encrypt_password(pass)
27
- end
28
-
29
- private
30
-
31
- def prepare_password
32
- unless password.blank?
33
- self.password_salt = Digest::SHA1.hexdigest([Time.now, rand].join)
34
- self.password_hash = encrypt_password(password)
35
- end
36
- end
37
-
38
- def encrypt_password(pass)
39
- Digest::SHA1.hexdigest([pass, password_salt].join)
40
- end
41
- <%- end -%>
42
- end
@@ -1,18 +0,0 @@
1
- class <%= user_plural_class_name %>Controller < ApplicationController
2
- def new
3
- @<%= user_singular_name %> = <%= user_class_name %>.new
4
- end
5
-
6
- def create
7
- @<%= user_singular_name %> = <%= user_class_name %>.new(params[:<%= user_singular_name %>])
8
- if @<%= user_singular_name %>.save
9
- <%- unless options[:authlogic] -%>
10
- session[:<%= user_singular_name %>_id] = @<%= user_singular_name %>.id
11
- <%- end -%>
12
- flash[:notice] = "Thank you for signing up! You are now logged in."
13
- redirect_to root_url
14
- else
15
- render :action => 'new'
16
- end
17
- end
18
- end
@@ -1,2 +0,0 @@
1
- module <%= user_plural_class_name %>Helper
2
- end
@@ -1,30 +0,0 @@
1
- <%% title "Log in" %>
2
-
3
- <p>Don't have an account? <%%= link_to "Sign up!", signup_path %></p>
4
-
5
- <%- if options[:authlogic] -%>
6
- <%% form_for @<%= session_singular_name %> do |f| %>
7
- <%%= f.error_messages %>
8
- <p>
9
- <%%= f.label :username %><br />
10
- <%%= f.text_field :username %>
11
- </p>
12
- <p>
13
- <%%= f.label :password %><br />
14
- <%%= f.password_field :password %>
15
- </p>
16
- <p><%%= f.submit "Log in" %></p>
17
- <%% end %>
18
- <%- else -%>
19
- <%% form_tag <%= session_plural_name %>_path do %>
20
- <p>
21
- <%%= label_tag :login, "Username or Email Address" %><br />
22
- <%%= text_field_tag :login, params[:login] %>
23
- </p>
24
- <p>
25
- <%%= label_tag :password %><br />
26
- <%%= password_field_tag :password %>
27
- </p>
28
- <p><%%= submit_tag "Log in" %></p>
29
- <%% end %>
30
- <%- end -%>
@@ -1,24 +0,0 @@
1
- <%% title "Sign up" %>
2
-
3
- <p>Already have an account? <%%= link_to "Log in", login_path %>.</p>
4
-
5
- <%% form_for @<%= user_singular_name %> do |f| %>
6
- <%%= f.error_messages %>
7
- <p>
8
- <%%= f.label :username %><br />
9
- <%%= f.text_field :username %>
10
- </p>
11
- <p>
12
- <%%= f.label :email, "Email Address" %><br />
13
- <%%= f.text_field :email %>
14
- </p>
15
- <p>
16
- <%%= f.label :password %><br />
17
- <%%= f.password_field :password %>
18
- </p>
19
- <p>
20
- <%%= f.label :password_confirmation, "Confirm Password" %><br />
21
- <%%= f.password_field :password_confirmation %>
22
- </p>
23
- <p><%%= f.submit "Sign up" %></p>
24
- <%% end %>
@@ -1,30 +0,0 @@
1
- - title "Log in"
2
-
3
- %p== Don't have an account? #{link_to "Sign up!", signup_path}
4
-
5
- <%- if options[:authlogic] -%>
6
- - form_for @<%= session_singular_name %> do |f|
7
- = f.error_messages
8
- %p
9
- = f.label :username
10
- %br
11
- = f.text_field :login
12
- %p
13
- = f.label :password
14
- %br
15
- = f.password_field :password
16
- %p
17
- = f.submit "Log in"
18
- <%- else -%>
19
- - form_tag <%= session_plural_name %>_path do
20
- %p
21
- = label_tag :login, "Username or Email Address"
22
- %br
23
- = text_field_tag :login, params[:login]
24
- %p
25
- = label_tag :password
26
- %br
27
- = password_field_tag :password
28
- %p
29
- = submit_tag "Log in"
30
- <%- end -%>
@@ -1,24 +0,0 @@
1
- - title "Sign up"
2
-
3
- %p== Already have an account? #{link_to "Log in", login_path}.
4
-
5
- - form_for @<%= user_singular_name %> do |f|
6
- = f.error_messages
7
- %p
8
- = f.label :username
9
- %br
10
- = f.text_field :username
11
- %p
12
- = f.label :email, "Email Address"
13
- %br
14
- = f.text_field :email
15
- %p
16
- = f.label :password
17
- %br
18
- = f.password_field :password
19
- %p
20
- = f.label :password_confirmation, "Confirm Password"
21
- %br
22
- = f.password_field :password_confirmation
23
- %p
24
- = f.submit "Sign up"
@@ -1,23 +0,0 @@
1
- Description:
2
- The nifty_config generator creates YAML file in your config
3
- directory and an initializer to load this config. The config has a
4
- separate section for each environment. This is a great place to put
5
- any config settings you don't want in your app.
6
-
7
- The config is loaded into a constant called APP_CONFIG by default,
8
- this changes depending on the name you choose to pass the generator.
9
- Use this constant to access the config settings like this.
10
-
11
- APP_CONFIG[:some_setting]
12
-
13
-
14
- Examples:
15
- script/generate nifty_config
16
-
17
- Config: config/app_config.yml
18
- Initializer: config/initializers/load_app_config.rb
19
-
20
- script/generate nifty_config passwords
21
-
22
- Config: config/passwords_config.yml
23
- Initializer: config/initializers/load_passwords_config.rb
@@ -1,32 +0,0 @@
1
- class NiftyConfigGenerator < Rails::Generator::Base
2
- def initialize(runtime_args, runtime_options = {})
3
- super
4
- @name = @args.first || 'app'
5
- end
6
-
7
- def manifest
8
- record do |m|
9
- m.directory 'config/initializers'
10
-
11
- m.template "load_config.rb", "config/initializers/load_#{file_name}_config.rb"
12
- m.file "config.yml", "config/#{file_name}_config.yml"
13
- end
14
- end
15
-
16
- def file_name
17
- @name.underscore
18
- end
19
-
20
- def constant_name
21
- @name.underscore.upcase
22
- end
23
-
24
- protected
25
- def banner
26
- <<-EOS
27
- Creates config and loader files.
28
-
29
- USAGE: #{$0} #{spec.name} [config_name]
30
- EOS
31
- end
32
- end
@@ -1,8 +0,0 @@
1
- development:
2
- domain: localhost:3000
3
-
4
- test:
5
- domain: test.host
6
-
7
- production:
8
- domain: example.com
@@ -1,2 +0,0 @@
1
- raw_config = File.read(RAILS_ROOT + "/config/<%= file_name %>_config.yml")
2
- <%= constant_name %>_CONFIG = YAML.load(raw_config)[RAILS_ENV].symbolize_keys
@@ -1,25 +0,0 @@
1
- Description:
2
- The nifty_layout generator creates a basic layout, stylesheet and
3
- helper which will give some structure to a starting Rails app.
4
-
5
- The generator takes one argument which will be the name of the
6
- layout and stylesheet files. If no argument is passed then it defaults
7
- to "application".
8
-
9
- The helper module includes some methods which can be called in any
10
- template or partial to set variables to be used in the layout, such as
11
- page title and javascript/stylesheet includes.
12
-
13
- Examples:
14
- script/generate nifty_layout
15
-
16
- Layout: app/views/layouts/application.html.erb
17
- Stylesheet: public/stylesheets/application.css
18
- Helper: app/helpers/layout_helper.rb
19
-
20
-
21
- script/generate nifty_layout admin
22
-
23
- Layout: app/views/layouts/admin.html.erb
24
- Stylesheet: public/stylesheets/admin.css
25
- Helper: app/helpers/layout_helper.rb
@@ -1,44 +0,0 @@
1
- class NiftyLayoutGenerator < Rails::Generator::Base
2
- def initialize(runtime_args, runtime_options = {})
3
- super
4
- @name = @args.first || 'application'
5
- end
6
-
7
- def manifest
8
- record do |m|
9
- m.directory 'app/views/layouts'
10
- m.directory 'public/stylesheets'
11
- m.directory 'app/helpers'
12
-
13
- if options[:haml]
14
- m.directory 'public/stylesheets/sass'
15
- m.template "layout.html.haml", "app/views/layouts/#{file_name}.html.haml"
16
- m.file "stylesheet.sass", "public/stylesheets/sass/#{file_name}.sass"
17
- else
18
- m.template "layout.html.erb", "app/views/layouts/#{file_name}.html.erb"
19
- m.file "stylesheet.css", "public/stylesheets/#{file_name}.css"
20
- end
21
- m.file "helper.rb", "app/helpers/layout_helper.rb"
22
- end
23
- end
24
-
25
- def file_name
26
- @name.underscore
27
- end
28
-
29
- protected
30
-
31
- def add_options!(opt)
32
- opt.separator ''
33
- opt.separator 'Options:'
34
- opt.on("--haml", "Generate HAML for view, and SASS for stylesheet.") { |v| options[:haml] = v }
35
- end
36
-
37
- def banner
38
- <<-EOS
39
- Creates generic layout, stylesheet, and helper files.
40
-
41
- USAGE: #{$0} #{spec.name} [layout_name]
42
- EOS
43
- end
44
- end
@@ -1,22 +0,0 @@
1
- # These helper methods can be called in your template to set variables to be used in the layout
2
- # This module should be included in all views globally,
3
- # to do so you may need to add this line to your ApplicationController
4
- # helper :layout
5
- module LayoutHelper
6
- def title(page_title, show_title = true)
7
- @content_for_title = page_title.to_s
8
- @show_title = show_title
9
- end
10
-
11
- def show_title?
12
- @show_title
13
- end
14
-
15
- def stylesheet(*args)
16
- content_for(:head) { stylesheet_link_tag(*args) }
17
- end
18
-
19
- def javascript(*args)
20
- content_for(:head) { javascript_include_tag(*args) }
21
- end
22
- end
@@ -1,22 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
- "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
- <html>
4
- <head>
5
- <title><%%= h(yield(:title) || "Untitled") %></title>
6
- <%%= stylesheet_link_tag '<%= file_name %>' %>
7
- <%%= yield(:head) %>
8
- </head>
9
- <body>
10
- <div id="container">
11
- <%%- flash.each do |name, msg| -%>
12
- <%%= content_tag :div, msg, :id => "flash_#{name}" %>
13
- <%%- end -%>
14
-
15
- <%%- if show_title? -%>
16
- <h1><%%=h yield(:title) %></h1>
17
- <%%- end -%>
18
-
19
- <%%= yield %>
20
- </div>
21
- </body>
22
- </html>
@@ -1,19 +0,0 @@
1
- !!! Strict
2
- %html{html_attrs}
3
-
4
- %head
5
- %title
6
- = h(yield(:title) || "Untitled")
7
- %meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}/
8
- = stylesheet_link_tag '<%= file_name %>'
9
- = yield(:head)
10
-
11
- %body
12
- #container
13
- - flash.each do |name, msg|
14
- = content_tag :div, msg, :id => "flash_#{name}"
15
-
16
- - if show_title?
17
- %h1=h yield(:title)
18
-
19
- = yield
@@ -1,81 +0,0 @@
1
- body {
2
- background-color: #4B7399;
3
- font-family: Verdana, Helvetica, Arial;
4
- font-size: 14px;
5
- }
6
-
7
- a img {
8
- border: none;
9
- }
10
-
11
- a {
12
- color: #0000FF;
13
- }
14
-
15
- .clear {
16
- clear: both;
17
- height: 0;
18
- overflow: hidden;
19
- }
20
-
21
- #container {
22
- width: 75%;
23
- margin: 0 auto;
24
- background-color: #FFF;
25
- padding: 20px 40px;
26
- border: solid 1px black;
27
- margin-top: 20px;
28
- }
29
-
30
- #flash_notice, #flash_error {
31
- padding: 5px 8px;
32
- margin: 10px 0;
33
- }
34
-
35
- #flash_notice {
36
- background-color: #CFC;
37
- border: solid 1px #6C6;
38
- }
39
-
40
- #flash_error {
41
- background-color: #FCC;
42
- border: solid 1px #C66;
43
- }
44
-
45
- .fieldWithErrors {
46
- display: inline;
47
- }
48
-
49
- #errorExplanation {
50
- width: 400px;
51
- border: 2px solid #CF0000;
52
- padding: 0px;
53
- padding-bottom: 12px;
54
- margin-bottom: 20px;
55
- background-color: #f0f0f0;
56
- }
57
-
58
- #errorExplanation h2 {
59
- text-align: left;
60
- font-weight: bold;
61
- padding: 5px 5px 5px 15px;
62
- font-size: 12px;
63
- margin: 0;
64
- background-color: #c00;
65
- color: #fff;
66
- }
67
-
68
- #errorExplanation p {
69
- color: #333;
70
- margin-bottom: 0;
71
- padding: 8px;
72
- }
73
-
74
- #errorExplanation ul {
75
- margin: 2px 24px;
76
- }
77
-
78
- #errorExplanation ul li {
79
- font-size: 12px;
80
- list-style: disc;
81
- }