flexi_generators 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.textile CHANGED
@@ -1,64 +1,64 @@
1
- h1. Flexi Generators
2
-
3
- My Rails generator scripts. Generates controllers, views, layouts and stylesheets with:
4
-
5
- * Login layout
6
- * App layout
7
- * Menus with Menu Builder plugin
8
- * Pagination with Will Paginate plugin
9
-
10
- h2. Instalation
11
-
12
- Rail2
13
-
14
- For more details about configuration in Rails 2 look "here":http://github.com/leandroo/flexi_generators/tree/v0.1.0
15
-
16
- Rails3
17
-
18
- <pre>
19
- gem "flexi_generators", '0.2.1'
20
- </pre>
21
-
22
- h2. Included Generators
23
-
24
- * flexi_prepare: generates initial files anda configurations.
25
- * flexi_auth: generates user model with sign up and log in.
26
- * flexi_scaffold: generates custom scaffold.
27
-
28
- h2. Quickstart Rails 3
29
-
30
- These 4 simple steps are the essentials to get you smoothly up and running…
31
-
32
- 1. Create your app and configure all dependencies
33
- @rails new appname -m http://github.com/leandroo/flexi_generators/raw/v0.2.1/template.rb@
34
- 2. Run @bundle install@, @rake db:migrate@ and @rake db:seed@ to installs all required gems and create your database
35
- 3. Start your server with @rails server@
36
- 4. Open up "http://localhost:3000":http://localhost:3000
37
-
38
- h2. Usage
39
-
40
- <pre>
41
- rails g flexi_prepare
42
- ...
43
- rails g flexi_auth
44
- ...
45
- rails g flexi_scaffold Post title:string body:text
46
- </pre>
47
-
48
- h2. Screenshots
49
-
50
- !http://img697.imageshack.us/img697/1245/flexigenerators.jpg(Flexi)!
51
-
52
- h2. TODO
53
-
54
- * i18n
55
- * Tests, tests, tests
56
-
57
- h2. Autor
58
-
59
- *Leandro de Oliveira*
60
-
61
- Blog: "http://leandroo.com.br":http://leandroo.com.br
62
- Github: "http://github.com/leandroo":http://github.com/leandroo
63
-
1
+ h1. Flexi Generators
2
+
3
+ My Rails generator scripts. Generates controllers, views, layouts and stylesheets with:
4
+
5
+ * Login layout
6
+ * App layout
7
+ * Menus with Menu Builder plugin
8
+ * Pagination with Will Paginate plugin
9
+
10
+ h2. Instalation
11
+
12
+ Rail2
13
+
14
+ For more details about configuration in Rails 2 look "here":http://github.com/leandroo/flexi_generators/tree/v0.1.0
15
+
16
+ Rails3
17
+
18
+ <pre>
19
+ gem "flexi_generators"
20
+ </pre>
21
+
22
+ h2. Included Generators
23
+
24
+ * flexi_prepare: generates initial files anda configurations.
25
+ * flexi_auth: generates user model with sign up and log in.
26
+ * flexi_scaffold: generates custom scaffold.
27
+
28
+ h2. Quickstart Rails 3
29
+
30
+ These 4 simple steps are the essentials to get you smoothly up and running…
31
+
32
+ 1. Create your app and configure all dependencies
33
+ @rails new appname -m http://github.com/leandroo/flexi_generators/raw/master/template.rb@
34
+ 2. Run @bundle install@, @rake db:migrate@ and @rake db:seed@ to installs all required gems and create your database
35
+ 3. Start your server with @rails server@
36
+ 4. Open up "http://localhost:3000":http://localhost:3000
37
+
38
+ h2. Usage
39
+
40
+ <pre>
41
+ rails g flexi_prepare
42
+ ...
43
+ rails g flexi_auth
44
+ ...
45
+ rails g flexi_scaffold Post title:string body:text
46
+ </pre>
47
+
48
+ h2. Screenshots
49
+
50
+ !http://img697.imageshack.us/img697/1245/flexigenerators.jpg(Flexi)!
51
+
52
+ h2. TODO
53
+
54
+ * i18n
55
+ * Tests, tests, tests
56
+
57
+ h2. Autor
58
+
59
+ *Leandro de Oliveira*
60
+
61
+ Blog: "http://leandroo.com.br":http://leandroo.com.br
62
+ Github: "http://github.com/leandroo":http://github.com/leandroo
63
+
64
64
  Copyright (c) 2009 Leandro de Oliveira, released under the MIT license
data/Rakefile CHANGED
@@ -1,16 +1,16 @@
1
- require 'rake'
2
-
3
- begin
4
- require 'jeweler'
5
- Jeweler::Tasks.new do |gemspec|
6
- gemspec.name = "flexi_generators"
7
- gemspec.summary = "My useful Rails generator scripts."
8
- gemspec.description = "Generates authentication and custom scaffold templates."
9
- gemspec.email = "ol.leandro@gmail.com"
10
- gemspec.homepage = "http://github.com/leandroo/flexi_generators"
11
- gemspec.authors = ["Leandro de Oliveira"]
12
- end
13
- Jeweler::GemcutterTasks.new
14
- rescue LoadError
15
- puts "Jeweler not available. Install it with: gem install jeweler"
16
- end
1
+ require 'rake'
2
+
3
+ begin
4
+ require 'jeweler'
5
+ Jeweler::Tasks.new do |gemspec|
6
+ gemspec.name = "flexi_generators"
7
+ gemspec.summary = "My useful Rails generator scripts."
8
+ gemspec.description = "Generates authentication and custom scaffold templates."
9
+ gemspec.email = "ol.leandro@gmail.com"
10
+ gemspec.homepage = "http://github.com/leandroo/flexi_generators"
11
+ gemspec.authors = ["Leandro de Oliveira"]
12
+ end
13
+ Jeweler::GemcutterTasks.new
14
+ rescue LoadError
15
+ puts "Jeweler not available. Install it with: gem install jeweler"
16
+ end
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.2.3
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{flexi_generators}
8
- s.version = "0.2.2"
8
+ s.version = "0.2.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Leandro de Oliveira"]
@@ -1,2 +1,2 @@
1
- module FlexiGenerators
2
- end
1
+ module FlexiGenerators
2
+ end
@@ -1,5 +1,5 @@
1
- Description:
2
- The flexi_auth generator creates a custom authentication and users CRUD.
3
-
4
- Example:
5
- rails generate flexi_auth
1
+ Description:
2
+ The flexi_auth generator creates a custom authentication and users CRUD.
3
+
4
+ Example:
5
+ rails generate flexi_auth
@@ -1,117 +1,117 @@
1
- require 'rails/generators/migration'
2
-
3
- class FlexiAuthGenerator < Rails::Generators::Base
4
- include Rails::Generators::Migration
5
-
6
- source_root File.expand_path('../templates', __FILE__)
7
-
8
- argument :user_name, :type => :string, :default => 'user', :banner => 'user_name'
9
- argument :session_name, :type => :string, :default => "user_session", :banner => 'sessions_controller_name'
10
-
11
- def generate_flexi_auth
12
- gem 'authlogic', :git => 'git://github.com/binarylogic/authlogic.git'
13
- end
14
-
15
- def create_model_files
16
- template 'user.rb', "app/models/#{user_singular_name}.rb"
17
- template 'authlogic_session.rb', "app/models/#{user_singular_name}_session.rb"
18
- end
19
-
20
- def create_controller_files
21
- template 'users_controller.rb', "app/controllers/admin/#{user_plural_name}_controller.rb"
22
- template 'sessions_controller.rb', "app/controllers/#{session_plural_name}_controller.rb"
23
- end
24
-
25
- def create_helper_files
26
- template 'users_helper.rb', "app/helpers/#{user_plural_name}_helper.rb"
27
- template 'sessions_helper.rb', "app/helpers/#{session_plural_name}_helper.rb"
28
- end
29
-
30
- def create_view_files
31
- template "views/erb/login.html.erb", "app/views/#{session_plural_name}/new.html.erb"
32
- template "views/erb/index.html.erb", "app/views/admin/#{user_plural_name}/index.html.erb"
33
- template "views/erb/show.html.erb", "app/views/admin/#{user_plural_name}/show.html.erb"
34
- template "views/erb/new.html.erb", "app/views/admin/#{user_plural_name}/new.html.erb"
35
- template "views/erb/_error_messages.html.erb", "app/views/shared/_error_messages.html.erb"
36
- template "views/erb/edit.html.erb", "app/views/admin/#{user_plural_name}/edit.html.erb"
37
- end
38
-
39
- def create_lib_files
40
- template 'authentication.rb', 'config/initializers/authentication.rb'
41
- end
42
-
43
- def create_routes
44
- route "match 'admin' => 'user_sessions#new'"
45
- route "resources #{session_plural_name.to_sym.inspect}"
46
- route "match 'login' => '#{session_plural_name}#new', :as => :login"
47
- route "match 'logout' => '#{session_plural_name}#destroy', :as => :logout"
48
- inject_into_file "config/routes.rb", "\n\tresources #{user_plural_name.to_sym.inspect}", :after => 'match "home" => "home#index"'
49
- end
50
-
51
- def create_include_line
52
- inject_into_class "app/controllers/application_controller.rb", "ApplicationController", " before_filter :login_required\n"
53
- inject_into_class "app/controllers/application_controller.rb", "ApplicationController", " include Authentication\n"
54
- end
55
-
56
- def create_test_files
57
- template 'fixtures.yml', "test/fixtures/#{user_plural_name}.yml"
58
- template "tests/testunit/user.rb", "test/unit/#{user_singular_name}_test.rb"
59
- template "tests/testunit/users_controller.rb", "test/functional/#{user_plural_name}_controller_test.rb"
60
- template "tests/testunit/sessions_controller.rb", "test/functional/#{session_plural_name}_controller_test.rb"
61
- end
62
-
63
- def create_migration
64
- migration_template 'migration.rb', "db/migrate/create_#{user_plural_name}.rb"
65
- end
66
-
67
- def create_seed
68
- append_file "db/seeds.rb","#{user_class_name}.create(:username => 'admin', :password => 'admin123', :password_confirmation => 'admin123', :email => 'admin@example.com')"
69
- end
70
-
71
- private
72
-
73
- def session_name
74
- user_name + '_session'
75
- end
76
-
77
- def user_singular_name
78
- user_name.underscore
79
- end
80
-
81
- def user_plural_name
82
- user_singular_name.pluralize
83
- end
84
-
85
- def user_class_name
86
- user_name.camelize
87
- end
88
-
89
- def user_plural_class_name
90
- user_plural_name.camelize
91
- end
92
-
93
- def session_singular_name
94
- session_name.underscore
95
- end
96
-
97
- def session_plural_name
98
- session_singular_name.pluralize
99
- end
100
-
101
- def session_class_name
102
- session_name.camelize
103
- end
104
-
105
- def session_plural_class_name
106
- session_plural_name.camelize
107
- end
108
-
109
- def self.next_migration_number(dirname) #:nodoc:
110
- if ActiveRecord::Base.timestamped_migrations
111
- Time.now.utc.strftime("%Y%m%d%H%M%S")
112
- else
113
- "%.3d" % (current_migration_number(dirname) + 1)
114
- end
115
- end
116
-
1
+ require 'rails/generators/migration'
2
+
3
+ class FlexiAuthGenerator < Rails::Generators::Base
4
+ include Rails::Generators::Migration
5
+
6
+ source_root File.expand_path('../templates', __FILE__)
7
+
8
+ argument :user_name, :type => :string, :default => 'user', :banner => 'user_name'
9
+ argument :session_name, :type => :string, :default => "user_session", :banner => 'sessions_controller_name'
10
+
11
+ def generate_flexi_auth
12
+ gem 'authlogic', :git => 'git://github.com/binarylogic/authlogic.git'
13
+ end
14
+
15
+ def create_model_files
16
+ template 'user.rb', "app/models/#{user_singular_name}.rb"
17
+ template 'authlogic_session.rb', "app/models/#{user_singular_name}_session.rb"
18
+ end
19
+
20
+ def create_controller_files
21
+ template 'users_controller.rb', "app/controllers/admin/#{user_plural_name}_controller.rb"
22
+ template 'sessions_controller.rb', "app/controllers/#{session_plural_name}_controller.rb"
23
+ end
24
+
25
+ def create_helper_files
26
+ template 'users_helper.rb', "app/helpers/#{user_plural_name}_helper.rb"
27
+ template 'sessions_helper.rb', "app/helpers/#{session_plural_name}_helper.rb"
28
+ end
29
+
30
+ def create_view_files
31
+ template "views/erb/login.html.erb", "app/views/#{session_plural_name}/new.html.erb"
32
+ template "views/erb/index.html.erb", "app/views/admin/#{user_plural_name}/index.html.erb"
33
+ template "views/erb/show.html.erb", "app/views/admin/#{user_plural_name}/show.html.erb"
34
+ template "views/erb/new.html.erb", "app/views/admin/#{user_plural_name}/new.html.erb"
35
+ template "views/erb/_error_messages.html.erb", "app/views/shared/_error_messages.html.erb"
36
+ template "views/erb/edit.html.erb", "app/views/admin/#{user_plural_name}/edit.html.erb"
37
+ end
38
+
39
+ def create_lib_files
40
+ template 'authentication.rb', 'config/initializers/authentication.rb'
41
+ end
42
+
43
+ def create_routes
44
+ route "match 'admin' => 'user_sessions#new'"
45
+ route "resources #{session_plural_name.to_sym.inspect}"
46
+ route "match 'login' => '#{session_plural_name}#new', :as => :login"
47
+ route "match 'logout' => '#{session_plural_name}#destroy', :as => :logout"
48
+ inject_into_file "config/routes.rb", "\n\tresources #{user_plural_name.to_sym.inspect}", :after => 'match "home" => "home#index"'
49
+ end
50
+
51
+ def create_include_line
52
+ inject_into_class "app/controllers/application_controller.rb", "ApplicationController", " before_filter :login_required\n"
53
+ inject_into_class "app/controllers/application_controller.rb", "ApplicationController", " include Authentication\n"
54
+ end
55
+
56
+ def create_test_files
57
+ template 'fixtures.yml', "test/fixtures/#{user_plural_name}.yml"
58
+ template "tests/testunit/user.rb", "test/unit/#{user_singular_name}_test.rb"
59
+ template "tests/testunit/users_controller.rb", "test/functional/#{user_plural_name}_controller_test.rb"
60
+ template "tests/testunit/sessions_controller.rb", "test/functional/#{session_plural_name}_controller_test.rb"
61
+ end
62
+
63
+ def create_migration
64
+ migration_template 'migration.rb', "db/migrate/create_#{user_plural_name}.rb"
65
+ end
66
+
67
+ def create_seed
68
+ append_file "db/seeds.rb","#{user_class_name}.create(:username => 'admin', :password => 'admin123', :password_confirmation => 'admin123', :email => 'admin@example.com')"
69
+ end
70
+
71
+ private
72
+
73
+ def session_name
74
+ user_name + '_session'
75
+ end
76
+
77
+ def user_singular_name
78
+ user_name.underscore
79
+ end
80
+
81
+ def user_plural_name
82
+ user_singular_name.pluralize
83
+ end
84
+
85
+ def user_class_name
86
+ user_name.camelize
87
+ end
88
+
89
+ def user_plural_class_name
90
+ user_plural_name.camelize
91
+ end
92
+
93
+ def session_singular_name
94
+ session_name.underscore
95
+ end
96
+
97
+ def session_plural_name
98
+ session_singular_name.pluralize
99
+ end
100
+
101
+ def session_class_name
102
+ session_name.camelize
103
+ end
104
+
105
+ def session_plural_class_name
106
+ session_plural_name.camelize
107
+ end
108
+
109
+ def self.next_migration_number(dirname) #:nodoc:
110
+ if ActiveRecord::Base.timestamped_migrations
111
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
112
+ else
113
+ "%.3d" % (current_migration_number(dirname) + 1)
114
+ end
115
+ end
116
+
117
117
  end
@@ -29,7 +29,7 @@ class Admin::<%= user_plural_class_name %>Controller < ApplicationController
29
29
  end
30
30
 
31
31
  def update
32
- @<%= user_singular_name %> = <%= user_class_name %>.new(params[:id])
32
+ @<%= user_singular_name %> = <%= user_class_name %>.find(params[:id])
33
33
  flash[:notice] = '<%= user_class_name %> foi alterado com sucesso.' if @<%= user_singular_name %>.update_attributes(params[:<%= user_singular_name %>])
34
34
  respond_with(:admin, @<%= user_singular_name %>)
35
35
  end
@@ -1,24 +1,24 @@
1
- <%% title "Editando <%= user_singular_name.titleize %>" %>
2
-
3
- <%%= form_for([:admin, @<%= user_singular_name %>]) do |f| %>
4
- <%%= render "shared/error_messages", :resource => @<%= user_singular_name %> %>
5
- <div class="field">
6
- <%%= f.label :username %><br />
7
- <%%= f.text_field :username, :readonly => true %>
8
- </div>
9
- <div class="field">
10
- <%%= f.label :email %><br />
11
- <%%= f.text_field :email %>
12
- </div>
13
- <div class="field">
14
- <%%= f.label :password %><br />
15
- <%%= f.password_field :password %>
16
- </div>
17
- <div class="field">
18
- <%%= f.label :password_confirmation %><br />
19
- <%%= f.password_field :password_confirmation %>
20
- </div>
21
- <div id="control_box">
22
- <%%= f.submit "Salvar", :class => "button medium save blue" %> | <%%= link_to("Cancelar", admin_<%= user_plural_name %>_path, :class => "button medium red") %>
23
- </div>
24
- <%% end %>
1
+ <%% title "Editando <%= user_singular_name.titleize %>" %>
2
+
3
+ <%%= form_for([:admin, @<%= user_singular_name %>]) do |f| %>
4
+ <%%= render "shared/error_messages", :resource => @<%= user_singular_name %> %>
5
+ <div class="field">
6
+ <%%= f.label :username %><br />
7
+ <%%= f.text_field :username, :readonly => true %>
8
+ </div>
9
+ <div class="field">
10
+ <%%= f.label :email %><br />
11
+ <%%= f.text_field :email %>
12
+ </div>
13
+ <div class="field">
14
+ <%%= f.label :password %><br />
15
+ <%%= f.password_field :password %>
16
+ </div>
17
+ <div class="field">
18
+ <%%= f.label :password_confirmation %><br />
19
+ <%%= f.password_field :password_confirmation %>
20
+ </div>
21
+ <div id="control_box">
22
+ <%%= f.submit "Salvar", :class => "button medium save blue" %> | <%%= link_to("Cancelar", admin_<%= user_plural_name %>_path, :class => "button medium red") %>
23
+ </div>
24
+ <%% end %>