flexi_generators 0.2.8 → 0.2.10

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.
Files changed (94) hide show
  1. data/README.textile +1 -1
  2. data/VERSION +1 -1
  3. data/flexi_generators.gemspec +77 -78
  4. data/lib/generators/flexi/auth/USAGE +5 -0
  5. data/lib/generators/flexi/auth/auth_generator.rb +122 -0
  6. data/lib/generators/{flexi_auth → flexi/auth}/templates/authentication.rb +0 -0
  7. data/lib/generators/{flexi_auth → flexi/auth}/templates/authlogic_session.rb +0 -0
  8. data/lib/generators/{flexi_auth → flexi/auth}/templates/fixtures.yml +0 -0
  9. data/lib/generators/{flexi_auth → flexi/auth}/templates/migration.rb +0 -0
  10. data/lib/generators/{flexi_auth → flexi/auth}/templates/sessions_controller.rb +0 -0
  11. data/lib/generators/{flexi_auth → flexi/auth}/templates/sessions_helper.rb +0 -0
  12. data/lib/generators/{flexi_auth → flexi/auth}/templates/tests/testunit/sessions_controller.rb +0 -0
  13. data/lib/generators/{flexi_auth → flexi/auth}/templates/tests/testunit/user.rb +0 -0
  14. data/lib/generators/{flexi_auth → flexi/auth}/templates/tests/testunit/users_controller.rb +0 -0
  15. data/lib/generators/{flexi_auth → flexi/auth}/templates/user.rb +0 -0
  16. data/lib/generators/{flexi_auth → flexi/auth}/templates/users_controller.rb +0 -0
  17. data/lib/generators/{flexi_auth → flexi/auth}/templates/users_helper.rb +0 -0
  18. data/lib/generators/{flexi_auth → flexi/auth}/templates/views/erb/_error_messages.html.erb +0 -0
  19. data/lib/generators/flexi/auth/templates/views/erb/_menu.html.erb +16 -0
  20. data/lib/generators/{flexi_auth → flexi/auth}/templates/views/erb/application.html.erb +1 -19
  21. data/lib/generators/{flexi_auth → flexi/auth}/templates/views/erb/edit.html.erb +1 -1
  22. data/lib/generators/{flexi_auth → flexi/auth}/templates/views/erb/index.html.erb +0 -0
  23. data/lib/generators/{flexi_auth → flexi/auth}/templates/views/erb/login.html.erb +0 -0
  24. data/lib/generators/{flexi_auth → flexi/auth}/templates/views/erb/new.html.erb +1 -1
  25. data/lib/generators/{flexi_auth → flexi/auth}/templates/views/erb/show.html.erb +0 -0
  26. data/lib/generators/flexi/prepare/USAGE +6 -0
  27. data/lib/generators/flexi/prepare/prepare_generator.rb +68 -0
  28. data/lib/generators/{flexi_prepare → flexi/prepare}/templates/add.png +0 -0
  29. data/lib/generators/{flexi_prepare → flexi/prepare}/templates/admin_home_controller.rb +0 -0
  30. data/lib/generators/{flexi_prepare → flexi/prepare}/templates/admin_home_index.html.erb +0 -0
  31. data/lib/generators/{flexi_prepare → flexi/prepare}/templates/application.css +3 -1
  32. data/lib/generators/{flexi_prepare → flexi/prepare}/templates/application_helper.rb +0 -0
  33. data/lib/generators/{flexi_prepare → flexi/prepare}/templates/back.png +0 -0
  34. data/lib/generators/{flexi_prepare → flexi/prepare}/templates/bg.png +0 -0
  35. data/lib/generators/{flexi_prepare → flexi/prepare}/templates/bg2.png +0 -0
  36. data/lib/generators/{flexi_prepare → flexi/prepare}/templates/boxheader.gif +0 -0
  37. data/lib/generators/{flexi_prepare → flexi/prepare}/templates/btn-bg-hover.png +0 -0
  38. data/lib/generators/{flexi_prepare → flexi/prepare}/templates/btn-bg.png +0 -0
  39. data/lib/generators/{flexi_prepare → flexi/prepare}/templates/custom_field_error.rb +0 -0
  40. data/lib/generators/flexi/prepare/templates/delete.png +0 -0
  41. data/lib/generators/flexi/prepare/templates/edit.png +0 -0
  42. data/lib/generators/{flexi_prepare → flexi/prepare}/templates/inflector_portuguese.rb +0 -0
  43. data/lib/generators/{flexi_prepare → flexi/prepare}/templates/login.css +0 -0
  44. data/lib/generators/{flexi_prepare → flexi/prepare}/templates/login.html.erb +0 -0
  45. data/lib/generators/{flexi_prepare → flexi/prepare}/templates/logo.png +0 -0
  46. data/lib/generators/flexi/prepare/templates/menu.png +0 -0
  47. data/lib/generators/{flexi_prepare → flexi/prepare}/templates/messages/Thumbs.db +0 -0
  48. data/lib/generators/{flexi_prepare → flexi/prepare}/templates/messages/error.png +0 -0
  49. data/lib/generators/{flexi_prepare → flexi/prepare}/templates/messages/info.png +0 -0
  50. data/lib/generators/{flexi_prepare → flexi/prepare}/templates/messages/success.png +0 -0
  51. data/lib/generators/{flexi_prepare → flexi/prepare}/templates/messages/tip.png +0 -0
  52. data/lib/generators/{flexi_prepare → flexi/prepare}/templates/messages/warning.png +0 -0
  53. data/lib/generators/{flexi_prepare → flexi/prepare}/templates/pt-BR.yml +1 -1
  54. data/lib/generators/{flexi_prepare → flexi/prepare}/templates/routes.rb +0 -0
  55. data/lib/generators/flexi/prepare/templates/show.png +0 -0
  56. data/lib/generators/{flexi_prepare → flexi/prepare}/templates/site.css +0 -0
  57. data/lib/generators/{flexi_prepare → flexi/prepare}/templates/site.html.erb +0 -0
  58. data/lib/generators/{flexi_prepare → flexi/prepare}/templates/site_controller.rb +0 -0
  59. data/lib/generators/{flexi_prepare → flexi/prepare}/templates/site_helper.rb +0 -0
  60. data/lib/generators/{flexi_prepare → flexi/prepare}/templates/site_index.html.erb +0 -0
  61. data/lib/generators/flexi/prepare/templates/users.png +0 -0
  62. data/lib/generators/flexi/scaffold/USAGE +5 -0
  63. data/lib/generators/flexi/scaffold/scaffold_generator.rb +110 -0
  64. data/lib/generators/{flexi_scaffold → flexi/scaffold}/templates/controller.rb +0 -0
  65. data/lib/generators/{flexi_scaffold → flexi/scaffold}/templates/fixtures.yml +0 -0
  66. data/lib/generators/{flexi_scaffold → flexi/scaffold}/templates/helper.rb +0 -0
  67. data/lib/generators/{flexi_scaffold → flexi/scaffold}/templates/migration.rb +0 -0
  68. data/lib/generators/{flexi_scaffold → flexi/scaffold}/templates/model.rb +0 -0
  69. data/lib/generators/{flexi_scaffold → flexi/scaffold}/templates/tests/controller.rb +0 -0
  70. data/lib/generators/{flexi_scaffold → flexi/scaffold}/templates/tests/helper.rb +0 -0
  71. data/lib/generators/{flexi_scaffold → flexi/scaffold}/templates/tests/model.rb +0 -0
  72. data/lib/generators/{flexi_scaffold → flexi/scaffold}/templates/views/erb/_error_messages.html.erb +0 -0
  73. data/lib/generators/{flexi_scaffold → flexi/scaffold}/templates/views/erb/_form.html.erb +1 -1
  74. data/lib/generators/{flexi_scaffold → flexi/scaffold}/templates/views/erb/edit.html.erb +0 -0
  75. data/lib/generators/{flexi_scaffold → flexi/scaffold}/templates/views/erb/index.html.erb +0 -0
  76. data/lib/generators/{flexi_scaffold → flexi/scaffold}/templates/views/erb/new.html.erb +0 -0
  77. data/lib/generators/{flexi_scaffold → flexi/scaffold}/templates/views/erb/show.html.erb +0 -0
  78. data/lib/generators/flexi.rb +16 -0
  79. data/template.rb +15 -5
  80. metadata +79 -80
  81. data/init.rb +0 -1
  82. data/lib/flexi_generators.rb +0 -2
  83. data/lib/generators/flexi_auth/USAGE +0 -5
  84. data/lib/generators/flexi_auth/flexi_auth_generator.rb +0 -118
  85. data/lib/generators/flexi_prepare/USAGE +0 -6
  86. data/lib/generators/flexi_prepare/flexi_prepare_generator.rb +0 -62
  87. data/lib/generators/flexi_prepare/templates/application.html.erb +0 -57
  88. data/lib/generators/flexi_prepare/templates/delete.png +0 -0
  89. data/lib/generators/flexi_prepare/templates/edit.png +0 -0
  90. data/lib/generators/flexi_prepare/templates/menu.png +0 -0
  91. data/lib/generators/flexi_prepare/templates/show.png +0 -0
  92. data/lib/generators/flexi_prepare/templates/users.png +0 -0
  93. data/lib/generators/flexi_scaffold/USAGE +0 -8
  94. data/lib/generators/flexi_scaffold/flexi_scaffold_generator.rb +0 -99
@@ -0,0 +1,110 @@
1
+ require 'generators/flexi'
2
+ require 'rails/generators/migration'
3
+ require 'rails/generators/generated_attribute'
4
+
5
+ module Flexi
6
+ module Generators
7
+ class ScaffoldGenerator < Base
8
+ include Rails::Generators::Migration
9
+
10
+ no_tasks { attr_accessor :model_name, :model_attributes }
11
+ argument :model_name, :type => :string, :required => true, :banner => 'ModelName'
12
+ argument :args_for_m, :type => :array, :default => [], :banner => 'model:attributes'
13
+
14
+ def initialize(*args, &block)
15
+ super
16
+ @model_attributes = []
17
+
18
+ args_for_m.each do |arg|
19
+ if arg.include?(':')
20
+ @model_attributes << Rails::Generators::GeneratedAttribute.new(*arg.split(':'))
21
+ end
22
+ end
23
+
24
+ @model_attributes.uniq!
25
+
26
+ if @model_attributes.empty?
27
+ if model_exists?
28
+ model_columns_for_attributes.each do |column|
29
+ @model_attributes << Rails::Generators::GeneratedAttribute.new(column.name.to_s, column.type.to_s)
30
+ end
31
+ else
32
+ @model_attributes << Rails::Generators::GeneratedAttribute.new('name', 'string')
33
+ end
34
+ end
35
+ end
36
+
37
+ def create_model
38
+ template 'model.rb', "app/models/#{singular_name}.rb"
39
+ template "tests/model.rb", "test/unit/#{singular_name}_test.rb"
40
+ template 'fixtures.yml', "test/fixtures/#{plural_name}.yml"
41
+ end
42
+
43
+ def create_controller
44
+ template "controller.rb", "app/controllers/admin/#{plural_name}_controller.rb"
45
+ inject_into_file "config/routes.rb", "\n\tresources #{plural_name.to_sym.inspect}",
46
+ :after => 'namespace :admin do'
47
+ template "tests/controller.rb", "test/functional/#{plural_name}_controller_test.rb"
48
+ template 'helper.rb', "app/helpers/#{plural_name}_helper.rb"
49
+ template "tests/helper.rb", "test/unit/helpers/#{plural_name}_controller_test.rb"
50
+ end
51
+
52
+ def create_view_files
53
+ template "views/erb/index.html.erb", "app/views/admin/#{plural_name}/index.html.erb"
54
+ template "views/erb/_form.html.erb", "app/views/admin/#{plural_name}/_form.html.erb"
55
+ template "views/erb/show.html.erb", "app/views/admin/#{plural_name}/show.html.erb"
56
+ template "views/erb/new.html.erb", "app/views/admin/#{plural_name}/new.html.erb"
57
+ template "views/erb/edit.html.erb", "app/views/admin/#{plural_name}/edit.html.erb"
58
+ template "views/erb/_error_messages.html.erb", "app/views/shared/_error_messages.html.erb"
59
+ end
60
+
61
+ def create_menu
62
+ inject_into_file "app/views/layouts/_menu.html.erb", :after => "<%= menu do |m| %>" do
63
+ "\n\t<%= m.#{plural_name} admin_#{plural_name}_path do %>
64
+ <%= image_tag '#{plural_name}.png' %> #{plural_class_name}
65
+ <% end %>"
66
+ end
67
+ end
68
+
69
+ def create_migration
70
+ migration_template 'migration.rb', "db/migrate/create_#{plural_name}.rb"
71
+ end
72
+
73
+ private
74
+ def singular_name
75
+ model_name.underscore
76
+ end
77
+
78
+ def plural_name
79
+ model_name.underscore.pluralize
80
+ end
81
+
82
+ def class_name
83
+ model_name.camelize
84
+ end
85
+
86
+ def plural_class_name
87
+ plural_name.camelize
88
+ end
89
+
90
+ def model_exists?
91
+ File.exist? destination_path("app/models/#{singular_name}.rb")
92
+ end
93
+
94
+ def model_columns_for_attributes
95
+ class_name.constantize.columns.reject do |column|
96
+ column.name.to_s =~ /^(id|created_at|updated_at)$/
97
+ end
98
+ end
99
+
100
+ def self.next_migration_number(dirname) #:nodoc:
101
+ if ActiveRecord::Base.timestamped_migrations
102
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
103
+ else
104
+ "%.3d" % (current_migration_number(dirname) + 1)
105
+ end
106
+ end
107
+
108
+ end
109
+ end
110
+ end
@@ -8,6 +8,6 @@
8
8
  </div>
9
9
  <%- end -%>
10
10
  <div id="control_box">
11
- <%%= f.submit "Salvar", :class => "button medium save blue" %> | <%%= link_to("Cancelar", admin_<%= plural_name %>_path, :class => "button medium red") %>
11
+ <%%= f.submit "Salvar", :class => "button medium blue" %> | <%%= link_to("Cancelar", admin_<%= plural_name %>_path, :class => "button medium red") %>
12
12
  </div>
13
13
  <%% end %>
@@ -0,0 +1,16 @@
1
+ require 'rails/generators/base'
2
+
3
+ module Flexi
4
+ module Generators
5
+ class Base < Rails::Generators::Base #:nodoc:
6
+ def self.source_root
7
+ @_flexi_source_root ||= File.expand_path(File.join(File.dirname(__FILE__), 'flexi', generator_name, 'templates'))
8
+ end
9
+
10
+ def self.banner
11
+ "#{$0} flexi:#{generator_name} #{self.arguments.map{ |a| a.usage }.join(' ')} [options]"
12
+ end
13
+ end
14
+ end
15
+ end
16
+
data/template.rb CHANGED
@@ -1,5 +1,15 @@
1
- gem "flexi_generators"
2
- run "bundle install"
3
- generate :flexi_prepare
4
- generate :flexi_auth
5
- run "bundle install"
1
+ # Check prerequisites
2
+ %w{bundler flexi_generators}.each do |component|
3
+ unless Gem.available?(component)
4
+ run "gem install #{component}"
5
+ Gem.refresh
6
+ Gem.activate(component)
7
+ end
8
+ end
9
+ # Add flexi_generators to Gemfile
10
+ gem "flexi_generators", "0.2.10"
11
+ # Flexi Genertors
12
+ generate 'flexi:prepare'
13
+ generate 'flexi:auth'
14
+ # Bundle
15
+ run "bundle install"
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: flexi_generators
3
3
  version: !ruby/object:Gem::Version
4
- hash: 7
4
+ hash: 3
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 8
10
- version: 0.2.8
9
+ - 10
10
+ version: 0.2.10
11
11
  platform: ruby
12
12
  authors:
13
13
  - Leandro de Oliveira
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-04-14 00:00:00 Z
18
+ date: 2011-04-21 00:00:00 Z
19
19
  dependencies: []
20
20
 
21
21
  description: Generates authentication and custom scaffold templates.
@@ -31,82 +31,81 @@ files:
31
31
  - Rakefile
32
32
  - VERSION
33
33
  - flexi_generators.gemspec
34
- - init.rb
35
- - lib/flexi_generators.rb
36
- - lib/generators/flexi_auth/USAGE
37
- - lib/generators/flexi_auth/flexi_auth_generator.rb
38
- - lib/generators/flexi_auth/templates/authentication.rb
39
- - lib/generators/flexi_auth/templates/authlogic_session.rb
40
- - lib/generators/flexi_auth/templates/fixtures.yml
41
- - lib/generators/flexi_auth/templates/migration.rb
42
- - lib/generators/flexi_auth/templates/sessions_controller.rb
43
- - lib/generators/flexi_auth/templates/sessions_helper.rb
44
- - lib/generators/flexi_auth/templates/tests/testunit/sessions_controller.rb
45
- - lib/generators/flexi_auth/templates/tests/testunit/user.rb
46
- - lib/generators/flexi_auth/templates/tests/testunit/users_controller.rb
47
- - lib/generators/flexi_auth/templates/user.rb
48
- - lib/generators/flexi_auth/templates/users_controller.rb
49
- - lib/generators/flexi_auth/templates/users_helper.rb
50
- - lib/generators/flexi_auth/templates/views/erb/_error_messages.html.erb
51
- - lib/generators/flexi_auth/templates/views/erb/application.html.erb
52
- - lib/generators/flexi_auth/templates/views/erb/edit.html.erb
53
- - lib/generators/flexi_auth/templates/views/erb/index.html.erb
54
- - lib/generators/flexi_auth/templates/views/erb/login.html.erb
55
- - lib/generators/flexi_auth/templates/views/erb/new.html.erb
56
- - lib/generators/flexi_auth/templates/views/erb/show.html.erb
57
- - lib/generators/flexi_prepare/USAGE
58
- - lib/generators/flexi_prepare/flexi_prepare_generator.rb
59
- - lib/generators/flexi_prepare/templates/add.png
60
- - lib/generators/flexi_prepare/templates/admin_home_controller.rb
61
- - lib/generators/flexi_prepare/templates/admin_home_index.html.erb
62
- - lib/generators/flexi_prepare/templates/application.css
63
- - lib/generators/flexi_prepare/templates/application.html.erb
64
- - lib/generators/flexi_prepare/templates/application_helper.rb
65
- - lib/generators/flexi_prepare/templates/back.png
66
- - lib/generators/flexi_prepare/templates/bg.png
67
- - lib/generators/flexi_prepare/templates/bg2.png
68
- - lib/generators/flexi_prepare/templates/boxheader.gif
69
- - lib/generators/flexi_prepare/templates/btn-bg-hover.png
70
- - lib/generators/flexi_prepare/templates/btn-bg.png
71
- - lib/generators/flexi_prepare/templates/custom_field_error.rb
72
- - lib/generators/flexi_prepare/templates/delete.png
73
- - lib/generators/flexi_prepare/templates/edit.png
74
- - lib/generators/flexi_prepare/templates/inflector_portuguese.rb
75
- - lib/generators/flexi_prepare/templates/login.css
76
- - lib/generators/flexi_prepare/templates/login.html.erb
77
- - lib/generators/flexi_prepare/templates/logo.png
78
- - lib/generators/flexi_prepare/templates/menu.png
79
- - lib/generators/flexi_prepare/templates/messages/Thumbs.db
80
- - lib/generators/flexi_prepare/templates/messages/error.png
81
- - lib/generators/flexi_prepare/templates/messages/info.png
82
- - lib/generators/flexi_prepare/templates/messages/success.png
83
- - lib/generators/flexi_prepare/templates/messages/tip.png
84
- - lib/generators/flexi_prepare/templates/messages/warning.png
85
- - lib/generators/flexi_prepare/templates/pt-BR.yml
86
- - lib/generators/flexi_prepare/templates/routes.rb
87
- - lib/generators/flexi_prepare/templates/show.png
88
- - lib/generators/flexi_prepare/templates/site.css
89
- - lib/generators/flexi_prepare/templates/site.html.erb
90
- - lib/generators/flexi_prepare/templates/site_controller.rb
91
- - lib/generators/flexi_prepare/templates/site_helper.rb
92
- - lib/generators/flexi_prepare/templates/site_index.html.erb
93
- - lib/generators/flexi_prepare/templates/users.png
94
- - lib/generators/flexi_scaffold/USAGE
95
- - lib/generators/flexi_scaffold/flexi_scaffold_generator.rb
96
- - lib/generators/flexi_scaffold/templates/controller.rb
97
- - lib/generators/flexi_scaffold/templates/fixtures.yml
98
- - lib/generators/flexi_scaffold/templates/helper.rb
99
- - lib/generators/flexi_scaffold/templates/migration.rb
100
- - lib/generators/flexi_scaffold/templates/model.rb
101
- - lib/generators/flexi_scaffold/templates/tests/controller.rb
102
- - lib/generators/flexi_scaffold/templates/tests/helper.rb
103
- - lib/generators/flexi_scaffold/templates/tests/model.rb
104
- - lib/generators/flexi_scaffold/templates/views/erb/_error_messages.html.erb
105
- - lib/generators/flexi_scaffold/templates/views/erb/_form.html.erb
106
- - lib/generators/flexi_scaffold/templates/views/erb/edit.html.erb
107
- - lib/generators/flexi_scaffold/templates/views/erb/index.html.erb
108
- - lib/generators/flexi_scaffold/templates/views/erb/new.html.erb
109
- - lib/generators/flexi_scaffold/templates/views/erb/show.html.erb
34
+ - lib/generators/flexi.rb
35
+ - lib/generators/flexi/auth/USAGE
36
+ - lib/generators/flexi/auth/auth_generator.rb
37
+ - lib/generators/flexi/auth/templates/authentication.rb
38
+ - lib/generators/flexi/auth/templates/authlogic_session.rb
39
+ - lib/generators/flexi/auth/templates/fixtures.yml
40
+ - lib/generators/flexi/auth/templates/migration.rb
41
+ - lib/generators/flexi/auth/templates/sessions_controller.rb
42
+ - lib/generators/flexi/auth/templates/sessions_helper.rb
43
+ - lib/generators/flexi/auth/templates/tests/testunit/sessions_controller.rb
44
+ - lib/generators/flexi/auth/templates/tests/testunit/user.rb
45
+ - lib/generators/flexi/auth/templates/tests/testunit/users_controller.rb
46
+ - lib/generators/flexi/auth/templates/user.rb
47
+ - lib/generators/flexi/auth/templates/users_controller.rb
48
+ - lib/generators/flexi/auth/templates/users_helper.rb
49
+ - lib/generators/flexi/auth/templates/views/erb/_error_messages.html.erb
50
+ - lib/generators/flexi/auth/templates/views/erb/_menu.html.erb
51
+ - lib/generators/flexi/auth/templates/views/erb/application.html.erb
52
+ - lib/generators/flexi/auth/templates/views/erb/edit.html.erb
53
+ - lib/generators/flexi/auth/templates/views/erb/index.html.erb
54
+ - lib/generators/flexi/auth/templates/views/erb/login.html.erb
55
+ - lib/generators/flexi/auth/templates/views/erb/new.html.erb
56
+ - lib/generators/flexi/auth/templates/views/erb/show.html.erb
57
+ - lib/generators/flexi/prepare/USAGE
58
+ - lib/generators/flexi/prepare/prepare_generator.rb
59
+ - lib/generators/flexi/prepare/templates/add.png
60
+ - lib/generators/flexi/prepare/templates/admin_home_controller.rb
61
+ - lib/generators/flexi/prepare/templates/admin_home_index.html.erb
62
+ - lib/generators/flexi/prepare/templates/application.css
63
+ - lib/generators/flexi/prepare/templates/application_helper.rb
64
+ - lib/generators/flexi/prepare/templates/back.png
65
+ - lib/generators/flexi/prepare/templates/bg.png
66
+ - lib/generators/flexi/prepare/templates/bg2.png
67
+ - lib/generators/flexi/prepare/templates/boxheader.gif
68
+ - lib/generators/flexi/prepare/templates/btn-bg-hover.png
69
+ - lib/generators/flexi/prepare/templates/btn-bg.png
70
+ - lib/generators/flexi/prepare/templates/custom_field_error.rb
71
+ - lib/generators/flexi/prepare/templates/delete.png
72
+ - lib/generators/flexi/prepare/templates/edit.png
73
+ - lib/generators/flexi/prepare/templates/inflector_portuguese.rb
74
+ - lib/generators/flexi/prepare/templates/login.css
75
+ - lib/generators/flexi/prepare/templates/login.html.erb
76
+ - lib/generators/flexi/prepare/templates/logo.png
77
+ - lib/generators/flexi/prepare/templates/menu.png
78
+ - lib/generators/flexi/prepare/templates/messages/Thumbs.db
79
+ - lib/generators/flexi/prepare/templates/messages/error.png
80
+ - lib/generators/flexi/prepare/templates/messages/info.png
81
+ - lib/generators/flexi/prepare/templates/messages/success.png
82
+ - lib/generators/flexi/prepare/templates/messages/tip.png
83
+ - lib/generators/flexi/prepare/templates/messages/warning.png
84
+ - lib/generators/flexi/prepare/templates/pt-BR.yml
85
+ - lib/generators/flexi/prepare/templates/routes.rb
86
+ - lib/generators/flexi/prepare/templates/show.png
87
+ - lib/generators/flexi/prepare/templates/site.css
88
+ - lib/generators/flexi/prepare/templates/site.html.erb
89
+ - lib/generators/flexi/prepare/templates/site_controller.rb
90
+ - lib/generators/flexi/prepare/templates/site_helper.rb
91
+ - lib/generators/flexi/prepare/templates/site_index.html.erb
92
+ - lib/generators/flexi/prepare/templates/users.png
93
+ - lib/generators/flexi/scaffold/USAGE
94
+ - lib/generators/flexi/scaffold/scaffold_generator.rb
95
+ - lib/generators/flexi/scaffold/templates/controller.rb
96
+ - lib/generators/flexi/scaffold/templates/fixtures.yml
97
+ - lib/generators/flexi/scaffold/templates/helper.rb
98
+ - lib/generators/flexi/scaffold/templates/migration.rb
99
+ - lib/generators/flexi/scaffold/templates/model.rb
100
+ - lib/generators/flexi/scaffold/templates/tests/controller.rb
101
+ - lib/generators/flexi/scaffold/templates/tests/helper.rb
102
+ - lib/generators/flexi/scaffold/templates/tests/model.rb
103
+ - lib/generators/flexi/scaffold/templates/views/erb/_error_messages.html.erb
104
+ - lib/generators/flexi/scaffold/templates/views/erb/_form.html.erb
105
+ - lib/generators/flexi/scaffold/templates/views/erb/edit.html.erb
106
+ - lib/generators/flexi/scaffold/templates/views/erb/index.html.erb
107
+ - lib/generators/flexi/scaffold/templates/views/erb/new.html.erb
108
+ - lib/generators/flexi/scaffold/templates/views/erb/show.html.erb
110
109
  - template.rb
111
110
  homepage: http://github.com/leandroo/flexi_generators
112
111
  licenses: []
data/init.rb DELETED
@@ -1 +0,0 @@
1
- require 'flexi_generators'
@@ -1,2 +0,0 @@
1
- module FlexiGenerators
2
- end
@@ -1,5 +0,0 @@
1
- Description:
2
- The flexi_auth generator creates a custom authentication and users CRUD.
3
-
4
- Example:
5
- rails generate flexi_auth
@@ -1,118 +0,0 @@
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
- template "views/erb/application.html.erb", "app/views/layouts/application.html.erb"
38
- end
39
-
40
- def create_lib_files
41
- template 'authentication.rb', 'config/initializers/authentication.rb'
42
- end
43
-
44
- def create_routes
45
- route "match 'admin' => '#{session_plural_name}#new'"
46
- route "resources #{session_plural_name.to_sym.inspect}"
47
- route "match 'login' => '#{session_plural_name}#new', :as => :login"
48
- route "match 'logout' => '#{session_plural_name}#destroy', :as => :logout"
49
- inject_into_file "config/routes.rb", "\n\tresources #{user_plural_name.to_sym.inspect}", :after => 'match "home" => "home#index"'
50
- end
51
-
52
- def create_include_line
53
- inject_into_class "app/controllers/application_controller.rb", "ApplicationController", " before_filter :login_required\n"
54
- inject_into_class "app/controllers/application_controller.rb", "ApplicationController", " include Authentication\n"
55
- end
56
-
57
- def create_test_files
58
- template 'fixtures.yml', "test/fixtures/#{user_plural_name}.yml"
59
- template "tests/testunit/user.rb", "test/unit/#{user_singular_name}_test.rb"
60
- template "tests/testunit/users_controller.rb", "test/functional/#{user_plural_name}_controller_test.rb"
61
- template "tests/testunit/sessions_controller.rb", "test/functional/#{session_plural_name}_controller_test.rb"
62
- end
63
-
64
- def create_migration
65
- migration_template 'migration.rb', "db/migrate/create_#{user_plural_name}.rb"
66
- end
67
-
68
- def create_seed
69
- append_file "db/seeds.rb","#{user_class_name}.create(:username => 'admin', :password => 'admin123', :password_confirmation => 'admin123', :email => 'admin@example.com')"
70
- end
71
-
72
- private
73
-
74
- def session_name
75
- user_name + '_session'
76
- end
77
-
78
- def user_singular_name
79
- user_name.underscore
80
- end
81
-
82
- def user_plural_name
83
- user_singular_name.pluralize
84
- end
85
-
86
- def user_class_name
87
- user_name.camelize
88
- end
89
-
90
- def user_plural_class_name
91
- user_plural_name.camelize
92
- end
93
-
94
- def session_singular_name
95
- session_name.underscore
96
- end
97
-
98
- def session_plural_name
99
- session_singular_name.pluralize
100
- end
101
-
102
- def session_class_name
103
- session_name.camelize
104
- end
105
-
106
- def session_plural_class_name
107
- session_plural_name.camelize
108
- end
109
-
110
- def self.next_migration_number(dirname) #:nodoc:
111
- if ActiveRecord::Base.timestamped_migrations
112
- Time.now.utc.strftime("%Y%m%d%H%M%S")
113
- else
114
- "%.3d" % (current_migration_number(dirname) + 1)
115
- end
116
- end
117
-
118
- end
@@ -1,6 +0,0 @@
1
- Description:
2
- The flexi_prepare generator creates a basic layout and config files and
3
- helper which will give some structure to a starting Rails app.
4
-
5
- Example:
6
- rails generate flexi_prepare
@@ -1,62 +0,0 @@
1
- class FlexiPrepareGenerator < Rails::Generators::Base
2
- source_root File.expand_path('../templates', __FILE__)
3
-
4
- def generate_flexi_prepare
5
- remove_file "app/views/layouts/application.html.erb"
6
- remove_file "app/helpers/application_helper.rb"
7
- remove_file "public/index.html"
8
- remove_file "config/routes.rb"
9
-
10
- copy_file "pt-BR.yml", "config/locales/pt-BR.yml"
11
- copy_file "inflector_portuguese.rb", "config/initializers/inflector_portuguese.rb"
12
- copy_file "custom_field_error.rb", "config/initializers/custom_field_error.rb"
13
- copy_file "application.css", "public/stylesheets/application.css"
14
- copy_file "login.css", "public/stylesheets/login.css"
15
- copy_file "site.css", "public/stylesheets/site.css"
16
- copy_file "logo.png", "public/images/logo.png"
17
- copy_file "add.png", "public/images/add.png"
18
- copy_file "bg.png", "public/images/bg.png"
19
- copy_file "bg2.png", "public/images/bg2.png"
20
- copy_file "users.png", "public/images/users.png"
21
- copy_file "boxheader.gif", "public/images/boxheader.gif"
22
- copy_file "menu.png", "public/images/menu.png"
23
- copy_file "btn-bg.png", "public/images/btn-bg.png"
24
- copy_file "btn-bg-hover.png", "public/images/btn-bg-hover.png"
25
- copy_file "edit.png", "public/images/edit.png"
26
- copy_file "show.png", "public/images/show.png"
27
- copy_file "delete.png", "public/images/delete.png"
28
- copy_file "back.png", "public/images/back.png"
29
- copy_file "messages/error.png", "public/images/messages/error.png"
30
- copy_file "messages/info.png", "public/images/messages/info.png"
31
- copy_file "messages/success.png", "public/images/messages/success.png"
32
- copy_file "messages/tip.png", "public/images/messages/tip.png"
33
- copy_file "messages/warning.png", "public/images/messages/warning.png"
34
- copy_file "admin_home_controller.rb", "app/controllers/admin/home_controller.rb"
35
- copy_file "site_controller.rb", "app/controllers/site_controller.rb"
36
- copy_file "site_helper.rb", "app/helpers/site_helper.rb"
37
- copy_file "application_helper.rb", "app/helpers/application_helper.rb"
38
-
39
- template "routes.rb", "config/routes.rb"
40
- template "login.html.erb", "app/views/layouts/login.html.erb"
41
- template "site.html.erb", "app/views/layouts/site.html.erb"
42
- template "site_index.html.erb", "app/views/site/index.html.erb"
43
- template "admin_home_index.html.erb", "app/views/admin/home/index.html.erb"
44
-
45
- gem 'menu_builder', '=0.3.3'
46
- gem 'will_paginate', '~> 3.0.pre2'
47
-
48
- route 'root :to => "site#index"'
49
- route 'namespace :admin do
50
- match "home" => "home#index"
51
- end'
52
-
53
- inject_into_file "config/application.rb", "\tconfig.i18n.default_locale = 'pt-BR'\n", :after => "class Application < Rails::Application\n"
54
- inject_into_file "config/application.rb", "\tconfig.time_zone = 'Brasilia'\n", :after => "class Application < Rails::Application\n"
55
- end
56
-
57
- private
58
-
59
- def app_name
60
- File.basename(Rails.root).camelize
61
- end
62
- end
@@ -1,57 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
5
- <title><%%= "Área administrativa - #{ yield(:title) }" %></title>
6
- <%%= stylesheet_link_tag 'application' %>
7
- <%%= javascript_include_tag :defaults %>
8
- <%%= yield(:head) %>
9
- <%%= csrf_meta_tag %>
10
- </head>
11
- <body>
12
- <div class="top_nav">
13
- <%% if logged_in? %>
14
- <%%= current_user.username %> | <%%= current_user.email %> | <%%= link_to "» Site", root_path, :target => '_blank' %> | <%%= link_to "» Sair", logout_path, :class => 'logout' %>
15
- <%% else %>
16
- <%%= link_to "» Entrar", login_path, :class => 'login' %>
17
- <%% end %>
18
- </div>
19
- <div id="header">
20
- <%%= link_to image_tag("logo.png"), admin_home_url %>
21
- </div>
22
- <div id="container">
23
- <div id="sidenav">
24
- <div class="menu">
25
- <%%= menu do |m| %>
26
- <%%= m.users admin_users_path do %>
27
- <%%= image_tag 'users.png' %> Usuários
28
- <%% end %>
29
- <%%= m.menu1 "#menu" do %>
30
- <%%= image_tag 'menu.png' %> Menu 1
31
- <%% end %>
32
- <%%= m.menu2 "#menu" do %>
33
- <%%= image_tag 'menu.png' %> Menu 2
34
- <%% end %>
35
- <%%= m.menu3 "#menu" do %>
36
- <%%= image_tag 'menu.png' %> Menu 3
37
- <%% end %>
38
- <%%= m.menu4 "#menu" do %>
39
- <%%= image_tag 'menu.png' %> Menu 4
40
- <%% end %>
41
- <%% end %>
42
- </div>
43
- </div>
44
- <div id="main">
45
- <div class="box-header">
46
- <%% if show_title? %>
47
- <h2><%%= yield(:title) %></h2>
48
- <%% end %>
49
- </div>
50
- <div class="box">
51
- <%%= raw flash_messages %>
52
- <%%= yield %>
53
- </div>
54
- </div>
55
- </div>
56
- </body>
57
- </html>