fetty-generators 1.7.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (167) hide show
  1. data/Gemfile +2 -0
  2. data/README.rdoc +42 -36
  3. data/Rakefile +1 -3
  4. data/lib/generators/fetty.rb +160 -10
  5. data/lib/generators/fetty/authentication/USAGE +4 -0
  6. data/lib/generators/fetty/authentication/authentication_generator.rb +171 -0
  7. data/lib/generators/fetty/authentication/templates/controllers/reset_passwords_controller.rb +45 -0
  8. data/lib/generators/fetty/authentication/templates/controllers/sessions_controller.rb +30 -0
  9. data/lib/generators/fetty/authentication/templates/controllers/users_controller.rb +78 -0
  10. data/lib/generators/fetty/authentication/templates/helpers/reset_passwords_helper.rb +2 -0
  11. data/lib/generators/fetty/authentication/templates/helpers/sessions_helper.rb +2 -0
  12. data/lib/generators/fetty/authentication/templates/helpers/users_helper.rb +2 -0
  13. data/lib/generators/fetty/authentication/templates/lib/sessions_authentication.rb +53 -0
  14. data/lib/generators/fetty/authentication/templates/lib/users_authentication.rb +110 -0
  15. data/lib/generators/fetty/authentication/templates/mailers/setup_mail.rb +11 -0
  16. data/lib/generators/fetty/authentication/templates/mailers/user_mailer.rb +14 -0
  17. data/lib/generators/fetty/authentication/templates/models/active_record/create_users.rb +17 -0
  18. data/lib/generators/fetty/authentication/templates/models/active_record/user.rb +15 -0
  19. data/lib/generators/fetty/authentication/templates/models/mongoid/user.rb +23 -0
  20. data/lib/generators/fetty/authentication/templates/spec/controllers/reset_passwords_controller_spec.rb +93 -0
  21. data/lib/generators/fetty/authentication/templates/spec/controllers/sessions_controller_spec.rb +61 -0
  22. data/lib/generators/fetty/authentication/templates/spec/controllers/users_controller_spec.rb +158 -0
  23. data/lib/generators/fetty/authentication/templates/spec/models/user_spec.rb +108 -0
  24. data/lib/generators/fetty/authentication/templates/spec/routing/reset_passwords_routing_spec.rb +21 -0
  25. data/lib/generators/fetty/authentication/templates/spec/routing/sessions_routing_spec.rb +17 -0
  26. data/lib/generators/fetty/authentication/templates/spec/routing/users_routing_spec.rb +37 -0
  27. data/lib/generators/fetty/authentication/templates/spec/support/user_factories.rb +6 -0
  28. data/lib/generators/fetty/authentication/templates/views/layouts/application.html.erb +33 -0
  29. data/lib/generators/fetty/authentication/templates/views/reset_passwords/edit.html.erb +19 -0
  30. data/lib/generators/fetty/authentication/templates/views/reset_passwords/new.html.erb +14 -0
  31. data/lib/generators/fetty/authentication/templates/views/sessions/new.html.erb +22 -0
  32. data/lib/generators/fetty/authentication/templates/views/user_mailer/user_activation.text.erb +4 -0
  33. data/lib/generators/fetty/authentication/templates/views/user_mailer/user_forgot_password.text.erb +7 -0
  34. data/lib/generators/fetty/authentication/templates/views/users/_table.html.erb +23 -0
  35. data/lib/generators/fetty/authentication/templates/views/users/edit.html.erb +21 -0
  36. data/lib/generators/fetty/authentication/templates/views/users/index.html.erb +7 -0
  37. data/lib/generators/fetty/authentication/templates/views/users/index.js.erb +1 -0
  38. data/lib/generators/fetty/authentication/templates/views/users/new.html.erb +23 -0
  39. data/lib/generators/fetty/authentication/templates/views/users/show.html.erb +19 -0
  40. data/lib/generators/fetty/messages/USAGE +4 -0
  41. data/lib/generators/fetty/messages/messages_generator.rb +136 -0
  42. data/lib/generators/fetty/messages/templates/assets/javascripts/jquery.tokeninput.js +718 -0
  43. data/lib/generators/fetty/messages/templates/assets/javascripts/messages.js +19 -0
  44. data/lib/generators/fetty/messages/templates/assets/stylesheets/messages.css +87 -0
  45. data/lib/generators/fetty/messages/templates/assets/stylesheets/token-input-facebook.css +122 -0
  46. data/lib/generators/fetty/messages/templates/controllers/messages_controller.rb +109 -0
  47. data/lib/generators/fetty/messages/templates/helpers/messages_helper.rb +2 -0
  48. data/lib/generators/fetty/messages/templates/lib/users_messages.rb +67 -0
  49. data/lib/generators/fetty/messages/templates/models/active_record/create_messages.rb +24 -0
  50. data/lib/generators/fetty/messages/templates/models/active_record/message.rb +67 -0
  51. data/lib/generators/fetty/messages/templates/models/mongoid/message.rb +81 -0
  52. data/lib/generators/fetty/messages/templates/spec/controllers/messages_controller_spec.rb +78 -0
  53. data/lib/generators/fetty/messages/templates/spec/models/message_spec.rb +53 -0
  54. data/lib/generators/fetty/messages/templates/spec/routing/messages_routing_spec.rb +61 -0
  55. data/lib/generators/fetty/messages/templates/spec/support/message_factories.rb +8 -0
  56. data/lib/generators/fetty/messages/templates/views/_head.html.erb +20 -0
  57. data/lib/generators/fetty/messages/templates/views/_messages.html.erb +56 -0
  58. data/lib/generators/fetty/messages/templates/views/_tabs_panel.html.erb +11 -0
  59. data/lib/generators/fetty/messages/templates/views/index.html.erb +10 -0
  60. data/lib/generators/fetty/messages/templates/views/index.js.erb +1 -0
  61. data/lib/generators/fetty/messages/templates/views/new.html.erb +26 -0
  62. data/lib/generators/fetty/messages/templates/views/show.html.erb +35 -0
  63. data/lib/generators/fetty/scaffold/USAGE +2 -52
  64. data/lib/generators/fetty/scaffold/scaffold_generator.rb +96 -329
  65. data/lib/generators/fetty/scaffold/templates/controllers/active_record/controller.rb +60 -0
  66. data/lib/generators/fetty/scaffold/templates/controllers/mongoid/controller.rb +60 -0
  67. data/lib/generators/fetty/scaffold/templates/helpers/helper.rb +2 -0
  68. data/lib/generators/fetty/scaffold/templates/models/active_record/migration.rb +16 -0
  69. data/lib/generators/fetty/scaffold/templates/models/active_record/model.rb +10 -0
  70. data/lib/generators/fetty/scaffold/templates/models/mongoid/model.rb +16 -0
  71. data/lib/generators/fetty/scaffold/templates/test/rspec/controller.rb +98 -0
  72. data/lib/generators/fetty/scaffold/templates/test/rspec/factories.rb +26 -0
  73. data/lib/generators/fetty/scaffold/templates/test/rspec/helper.rb +15 -0
  74. data/lib/generators/fetty/scaffold/templates/test/rspec/model.rb +9 -0
  75. data/lib/generators/fetty/scaffold/templates/test/rspec/request.rb +11 -0
  76. data/lib/generators/fetty/scaffold/templates/test/rspec/routing.rb +41 -0
  77. data/lib/generators/fetty/scaffold/templates/test/test_unit/controller.rb +62 -0
  78. data/lib/generators/fetty/scaffold/templates/{fixtures.yml → test/test_unit/fixtures.yml} +2 -0
  79. data/lib/generators/fetty/scaffold/templates/test/test_unit/helper.rb +4 -0
  80. data/lib/generators/fetty/scaffold/templates/test/test_unit/model.rb +7 -0
  81. data/lib/generators/fetty/scaffold/templates/views/_form.html.erb +20 -0
  82. data/lib/generators/fetty/scaffold/templates/views/_table.html.erb +48 -0
  83. data/lib/generators/fetty/scaffold/templates/views/edit.html.erb +13 -0
  84. data/lib/generators/fetty/scaffold/templates/views/index.html.erb +15 -0
  85. data/lib/generators/fetty/scaffold/templates/views/{erb/index.js.erb → index.js.erb} +0 -0
  86. data/lib/generators/fetty/scaffold/templates/views/new.html.erb +9 -0
  87. data/lib/generators/fetty/scaffold/templates/views/show.html.erb +28 -0
  88. data/lib/generators/fetty/setup/USAGE +3 -20
  89. data/lib/generators/fetty/setup/setup_generator.rb +122 -61
  90. data/lib/generators/fetty/setup/templates/ability.rb +0 -0
  91. data/lib/generators/fetty/setup/templates/ckeditor.rb +54 -0
  92. data/lib/generators/fetty/setup/templates/ckeditor.tar.gz +0 -0
  93. data/lib/generators/fetty/setup/templates/escape_utils.rb +7 -0
  94. data/lib/generators/fetty/setup/templates/file_uploader.rb +15 -0
  95. data/lib/generators/fetty/setup/templates/image_uploader.rb +48 -0
  96. data/lib/generators/fetty/setup/templates/spec_helper.rb +44 -0
  97. data/lib/generators/fetty/views/USAGE +5 -0
  98. data/lib/generators/fetty/{layout/templates/stylesheet.css → views/templates/application.css} +184 -166
  99. data/lib/generators/fetty/views/templates/application.html.erb +23 -0
  100. data/lib/generators/fetty/{layout → views}/templates/application.js +0 -0
  101. data/lib/generators/fetty/views/templates/application_helper.rb +10 -0
  102. data/lib/generators/fetty/views/templates/down_arrow.gif +0 -0
  103. data/lib/generators/fetty/{layout → views}/templates/error_messages_helper.rb +0 -0
  104. data/lib/generators/fetty/{layout → views}/templates/layout_helper.rb +0 -0
  105. data/lib/generators/fetty/views/templates/up_arrow.gif +0 -0
  106. data/lib/generators/fetty/views/views_generator.rb +51 -0
  107. data/lib/generators/scaffold.rb +204 -0
  108. metadata +126 -111
  109. data/LICENSE +0 -20
  110. data/lib/generators/fetty/layout/USAGE +0 -26
  111. data/lib/generators/fetty/layout/layout_generator.rb +0 -44
  112. data/lib/generators/fetty/layout/templates/layout.html.erb +0 -32
  113. data/lib/generators/fetty/layout/templates/layout.html.haml +0 -34
  114. data/lib/generators/fetty/layout/templates/no-devise-links-layout.html.erb +0 -23
  115. data/lib/generators/fetty/layout/templates/no-devise-links-layout.html.haml +0 -23
  116. data/lib/generators/fetty/layout/templates/stylesheet.sass +0 -163
  117. data/lib/generators/fetty/scaffold/templates/actions/create.rb +0 -8
  118. data/lib/generators/fetty/scaffold/templates/actions/destroy.rb +0 -5
  119. data/lib/generators/fetty/scaffold/templates/actions/edit.rb +0 -3
  120. data/lib/generators/fetty/scaffold/templates/actions/index.rb +0 -10
  121. data/lib/generators/fetty/scaffold/templates/actions/new.rb +0 -3
  122. data/lib/generators/fetty/scaffold/templates/actions/show.rb +0 -3
  123. data/lib/generators/fetty/scaffold/templates/actions/update.rb +0 -8
  124. data/lib/generators/fetty/scaffold/templates/controller.rb +0 -7
  125. data/lib/generators/fetty/scaffold/templates/helper.rb +0 -2
  126. data/lib/generators/fetty/scaffold/templates/migration.rb +0 -16
  127. data/lib/generators/fetty/scaffold/templates/model.rb +0 -7
  128. data/lib/generators/fetty/scaffold/templates/tests/rspec/actions/create.rb +0 -11
  129. data/lib/generators/fetty/scaffold/templates/tests/rspec/actions/destroy.rb +0 -6
  130. data/lib/generators/fetty/scaffold/templates/tests/rspec/actions/edit.rb +0 -4
  131. data/lib/generators/fetty/scaffold/templates/tests/rspec/actions/index.rb +0 -4
  132. data/lib/generators/fetty/scaffold/templates/tests/rspec/actions/new.rb +0 -4
  133. data/lib/generators/fetty/scaffold/templates/tests/rspec/actions/show.rb +0 -4
  134. data/lib/generators/fetty/scaffold/templates/tests/rspec/actions/update.rb +0 -11
  135. data/lib/generators/fetty/scaffold/templates/tests/rspec/controller.rb +0 -8
  136. data/lib/generators/fetty/scaffold/templates/tests/rspec/model.rb +0 -7
  137. data/lib/generators/fetty/scaffold/templates/tests/shoulda/actions/create.rb +0 -13
  138. data/lib/generators/fetty/scaffold/templates/tests/shoulda/actions/destroy.rb +0 -8
  139. data/lib/generators/fetty/scaffold/templates/tests/shoulda/actions/edit.rb +0 -6
  140. data/lib/generators/fetty/scaffold/templates/tests/shoulda/actions/index.rb +0 -6
  141. data/lib/generators/fetty/scaffold/templates/tests/shoulda/actions/new.rb +0 -6
  142. data/lib/generators/fetty/scaffold/templates/tests/shoulda/actions/show.rb +0 -6
  143. data/lib/generators/fetty/scaffold/templates/tests/shoulda/actions/update.rb +0 -13
  144. data/lib/generators/fetty/scaffold/templates/tests/shoulda/controller.rb +0 -5
  145. data/lib/generators/fetty/scaffold/templates/tests/shoulda/model.rb +0 -7
  146. data/lib/generators/fetty/scaffold/templates/tests/testunit/actions/create.rb +0 -11
  147. data/lib/generators/fetty/scaffold/templates/tests/testunit/actions/destroy.rb +0 -6
  148. data/lib/generators/fetty/scaffold/templates/tests/testunit/actions/edit.rb +0 -4
  149. data/lib/generators/fetty/scaffold/templates/tests/testunit/actions/index.rb +0 -4
  150. data/lib/generators/fetty/scaffold/templates/tests/testunit/actions/new.rb +0 -4
  151. data/lib/generators/fetty/scaffold/templates/tests/testunit/actions/show.rb +0 -4
  152. data/lib/generators/fetty/scaffold/templates/tests/testunit/actions/update.rb +0 -11
  153. data/lib/generators/fetty/scaffold/templates/tests/testunit/controller.rb +0 -5
  154. data/lib/generators/fetty/scaffold/templates/tests/testunit/model.rb +0 -7
  155. data/lib/generators/fetty/scaffold/templates/views/erb/_form.html.erb +0 -22
  156. data/lib/generators/fetty/scaffold/templates/views/erb/_table.html.erb +0 -50
  157. data/lib/generators/fetty/scaffold/templates/views/erb/edit.html.erb +0 -12
  158. data/lib/generators/fetty/scaffold/templates/views/erb/index.html.erb +0 -13
  159. data/lib/generators/fetty/scaffold/templates/views/erb/new.html.erb +0 -9
  160. data/lib/generators/fetty/scaffold/templates/views/erb/show.html.erb +0 -26
  161. data/lib/generators/fetty/scaffold/templates/views/haml/_form.html.haml +0 -8
  162. data/lib/generators/fetty/scaffold/templates/views/haml/_table.html.haml +0 -33
  163. data/lib/generators/fetty/scaffold/templates/views/haml/edit.html.haml +0 -14
  164. data/lib/generators/fetty/scaffold/templates/views/haml/index.html.haml +0 -12
  165. data/lib/generators/fetty/scaffold/templates/views/haml/index.js.haml +0 -1
  166. data/lib/generators/fetty/scaffold/templates/views/haml/new.html.haml +0 -8
  167. data/lib/generators/fetty/scaffold/templates/views/haml/show.html.haml +0 -23
@@ -1,3 +1,5 @@
1
+ # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
+
1
3
  one:
2
4
  <%- for attribute in model_attributes -%>
3
5
  <%= attribute.name %>: <%= attribute.default %>
@@ -0,0 +1,4 @@
1
+ require 'test_helper'
2
+
3
+ class <%= helper_name %>Test < ActionView::TestCase
4
+ end
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class <%= model_name %>Test < ActiveSupport::TestCase
4
+ def test_should_be_valid
5
+ assert true
6
+ end
7
+ end
@@ -0,0 +1,20 @@
1
+ <%- if has_type? :editor -%>
2
+ <%% content_for(:head) do %>
3
+ <%%= javascript_include_tag :ckeditor %>
4
+ <%% end %>
5
+ <%- end -%>
6
+ <%%= simple_form_for <%= record_or_name_or_array %><%= ", :html => { :multipart => true }" if has_type? :image -%> do |f| %>
7
+ <%%= f.error_messages %>
8
+ <div class="inputs">
9
+ <%- for attribute in model_attributes -%>
10
+ <%- if special_select(:editor).include?(attribute.name) -%>
11
+ <%%= f.ckeditor :<%= attribute.name %>, :label => false, :input_html => { :height => 400, :toolbar=>'Full' } %>
12
+ <%- else -%>
13
+ <%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %> %>
14
+ <%- end -%>
15
+ <%- end -%>
16
+ </div>
17
+ <div class="actions">
18
+ <%%= f.button :submit %>
19
+ </div>
20
+ <%% end %>
@@ -0,0 +1,48 @@
1
+ <table class="pretty">
2
+ <tr>
3
+ <%- for attribute in model_attributes -%>
4
+ <th><%%= sortable "<%= attribute.name %>" %></th>
5
+ <%- end -%>
6
+ <%- if action? :show -%>
7
+ <th></th>
8
+ <%- end -%>
9
+ <%- if action? :edit -%>
10
+ <th></th>
11
+ <%- end -%>
12
+ <%- if action? :destroy -%>
13
+ <th></th>
14
+ <%- end -%>
15
+ </tr>
16
+ <%% for <%= instance_name %> in <%= instances_name('@') %> %>
17
+ <tr>
18
+ <%- for attribute in model_attributes -%>
19
+ <%- if special_select(:image).include?(attribute.name) -%>
20
+ <td><%%= image_tag <%= instance_name %>.<%= attribute.name %>_url(:small) if <%= instance_name %>.<%= attribute.name %>? %></td>
21
+ <%- elsif special_select(:file).include?(attribute.name) -%>
22
+ <td><%%= link_to File.basename(<%= instance_name %>.<%= attribute.name %>.to_s), <%= instance_name %>.<%= attribute.name %>_url if <%= instance_name %>.<%= attribute.name %>? %></td>
23
+ <%- elsif special_select(:editor).include?(attribute.name) -%>
24
+ <td><%%= raw <%= instance_name %>.<%= attribute.name %> %></td>
25
+ <%- else -%>
26
+ <td><%%= <%= instance_name %>.<%= attribute.name %> %></td>
27
+ <%- end -%>
28
+ <%- end -%>
29
+ <%- if action? :show -%>
30
+ <td>
31
+ <%= generate_action_links(:show, :read, instance_name, "Show") %>
32
+ </td>
33
+ <%- end -%>
34
+ <%- if action? :edit -%>
35
+ <td>
36
+ <%= generate_action_links(:edit, :update, instance_name, "Edit") %>
37
+ </td>
38
+ <%- end -%>
39
+ <%- if action? :destroy -%>
40
+ <td>
41
+ <%= generate_action_links(:destroy, :destroy, instance_name, "Destroy") %>
42
+ </td>
43
+ <%- end -%>
44
+ </tr>
45
+ <%% end %>
46
+ </table>
47
+
48
+ <p><%%= paginate <%= instances_name('@') %> %></p>
@@ -0,0 +1,13 @@
1
+ <%% title "Edit <%= simple_name %>" %>
2
+
3
+ <%%= render 'form' %>
4
+ <%- if actions? :show, :index -%>
5
+ <p>
6
+ <%- if action? :show -%>
7
+ <%= generate_action_links(:show, :read, instance_name('@'), "Show") %> |
8
+ <%- end -%>
9
+ <%- if action? :index -%>
10
+ <%= generate_action_links(:index, :index, class_name, "View All") %>
11
+ <%- end -%>
12
+ </p>
13
+ <%- end -%>
@@ -0,0 +1,15 @@
1
+ <%% title "<%= plural_name.titleize %>" %>
2
+
3
+ <%%= form_tag <%= generate_route_link(:action => :index, :suffix => 'url') %>, { :id => "index_search", :method => :get } do %>
4
+ <%%= text_field_tag :search, params[:search], { :title => "Search by <%= model_attributes[0].name %>" } %>
5
+ <%%= hidden_field_tag :sort, params[:sort] %>
6
+ <%%= hidden_field_tag :direction, params[:direction] %>
7
+ <%% end %>
8
+
9
+ <div id="index_table"><%%= render 'table' %></div>
10
+
11
+ <%- if action? :new -%>
12
+ <p>
13
+ <%= generate_action_links(:new, :create, class_name, "New #{simple_name}") %>
14
+ </p>
15
+ <%- end -%>
@@ -0,0 +1,9 @@
1
+ <%% title "New <%= simple_name %>" %>
2
+
3
+ <%%= render 'form' %>
4
+
5
+ <%- if action? :index -%>
6
+ <p>
7
+ <%= generate_action_links(:index, :index, class_name, "Back to List") %>
8
+ </p>
9
+ <%- end -%>
@@ -0,0 +1,28 @@
1
+ <%% title "<%= simple_name.titleize %>" %>
2
+
3
+ <%- for attribute in model_attributes -%>
4
+ <p>
5
+ <strong><%= attribute.human_name.titleize %>:</strong>
6
+ <%- if special_select(:image).include?(attribute.name) -%>
7
+ <%%= image_tag <%= instance_name('@') %>.<%= attribute.name %>_url(:small) if <%= instance_name('@') %>.<%= attribute.name %>? %>
8
+ <%- elsif special_select(:file).include?(attribute.name) -%>
9
+ <%%= link_to File.basename(<%= instance_name('@') %>.<%= attribute.name %>.to_s), <%= instance_name('@') %>.<%= attribute.name %>_url if <%= instance_name('@') %>.<%= attribute.name %>? %>
10
+ <%- elsif special_select(:editor).include?(attribute.name) -%>
11
+ <%%= raw <%= instance_name('@') %>.<%= attribute.name %> %>
12
+ <%- else -%>
13
+ <%%= <%= instance_name('@') %>.<%= attribute.name %> %>
14
+ <%- end -%>
15
+ </p>
16
+ <%- end -%>
17
+
18
+ <p>
19
+ <%- if action? :edit -%>
20
+ <%= generate_action_links(:edit, :update, instance_name('@'), "Edit") %> |
21
+ <%- end -%>
22
+ <%- if action? :destroy -%>
23
+ <%= generate_action_links(:destroy, :destroy, instance_name('@'), "Destroy") %> |
24
+ <%- end -%>
25
+ <%- if action? :index -%>
26
+ <%= generate_action_links(:index, :index, class_name, "View All") %>
27
+ <%- end -%>
28
+ </p>
@@ -1,22 +1,5 @@
1
1
  Description:
2
- The fetty:setup generator creates a bunch of task to update your gemfile
3
- with necessary gem need for you to build your rails app.
4
- the basic installation required you to have :
5
- - meta_search
6
- - simple_form
7
- - will_paginate
8
- - jquery-rails
9
- and the optional gems for Authentication & Autorization using :
10
- - Devise
11
- - CanCan
2
+ The fetty:setup generator will add / install the necessary gems
3
+ to your Gemfile and automatically configure the gems.
4
+
12
5
 
13
- Examples:
14
- rails generate fetty:setup
15
-
16
- this default command will add gems to your Gemfile and install
17
- some necessary files. both required and optional gems.
18
- if you like to install minimum for layout and scaffolding using
19
- fetty-generators, or you already have diffrent gems for authentication
20
- or authorization you could skip the optional setup :
21
-
22
- rails generate fetty:setup --skip-optional
@@ -2,77 +2,138 @@ require 'generators/fetty'
2
2
 
3
3
  module Fetty
4
4
  module Generators
5
- class SetupGenerator < Base
6
-
7
- class_option :required, :desc => 'Only install required gems [meta_where, meta_search, will_paginate, simple_form, jquery-rails]', :type => :boolean, :default => true
8
- class_option :optional, :desc => 'Only install optional gems such as [devise, cancan, paperclip, tiny_mce]', :type => :boolean, :default => true
5
+ class SetupGenerator < Base #:nodoc:
6
+ # required
7
+ class_option :cancan, :desc => 'Install cancan for authorization', :type => :boolean, :default => true
8
+ class_option :jquery_rails, :desc => 'Install jquery-rails for javascript framework', :type => :boolean, :default => true
9
+ class_option :simple_form, :desc => 'Install simple_form for generate form', :type => :boolean, :default => true
10
+ class_option :carrierwave, :desc => 'Install carrierwave for handling file attachment', :type => :boolean, :default => true
11
+ class_option :kaminari, :desc => 'Install kaminari for pagination', :type => :boolean, :default => true
12
+ class_option :ckeditor, :desc => 'Install ckeditor for WYSIWYG editor', :type => :boolean, :default => true
13
+ class_option :test, :desc => 'Setup all test framework rspec / cucumber, capybara, guard, etc.', :type => :boolean, :default => true
9
14
 
10
- def add_install_gems
11
-
12
- #required
13
- if options.required?
14
- add_gem("meta_where")
15
- add_gem("meta_search")
16
- add_gem("will_paginate")
17
-
18
- add_gem("simple_form")
19
- generate("simple_form:install")
20
-
21
- add_gem("jquery-rails")
22
- generate("jquery:install")
23
- end
24
-
25
- # optional
26
- if options.optional?
27
- install_devise
28
- install_cancan
29
- install_paperclip
30
- install_tiny_mce
31
- end
15
+ # optional
16
+ class_option :mongoid, :desc => 'Install mongoid for replacing your ORM', :type => :boolean, :default => false
17
+ class_option :only, :desc => 'Install gems only these mentioned.', :type => :array, :default => []
18
+
19
+ def install_gems_dependencies
20
+ asking "Would you like to setup mongoid gem?" do
21
+ setup_mongoid
22
+ end if options['mongoid']
23
+ @selected_gems = options.only.empty? ? options.reject { |k,v| k == "only" || k == "mongoid" || v == false }.keys : options.only
24
+ @selected_gems.each do |gems|
25
+ asking "Would you like to setup #{gems} gem?" do
26
+ send("setup_#{gems}")
27
+ end
28
+ end
29
+ remove_file 'public/index.html' if file_exists?('public/index.html')
30
+ remove_file 'public/images/rails.png' if file_exists?('public/images/rails.png')
31
+ rescue Exception => e
32
+ print_notes(e.message,"error",:red)
32
33
  end
33
-
34
+
34
35
  private
35
36
 
36
- def install_devise
37
- opt = ask("Would you like to install Devise for authentication? [yes]")
38
- if opt == "yes" || opt.blank?
39
- add_gem("devise")
40
- generate("devise:install")
41
- model_name = ask("Would you like the user model to be called? [user]")
42
- model_name = "user" if model_name.blank?
43
- generate("devise", model_name)
44
- opt = ask("Would you like to set global authentications in application_controller.rb? [yes]")
45
- if opt == "yes" || opt.blank?
46
- inject_into_file 'app/controllers/application_controller.rb', :after => "class ApplicationController < ActionController::Base" do
47
- "\n before_filter :authenticate_user!"
48
- end
49
- end
50
- end
37
+ def setup_mongoid
38
+ add_gem("bson_ext")
39
+ add_gem("mongoid")
40
+ generate("mongoid:config")
41
+ rescue Exception => e
42
+ raise e
43
+ end
44
+
45
+ def setup_cancan
46
+ add_gem("cancan")
47
+ copy_file 'ability.rb', 'app/models/ability.rb'
48
+ inject_into_class 'app/controllers/application_controller.rb', ApplicationController do
49
+ " rescue_from CanCan::AccessDenied do |exception| flash[:alert] = exception.message; redirect_to root_url end;\n"
50
+ end
51
+ rescue Exception => e
52
+ raise e
53
+ end
54
+
55
+ def setup_jquery_rails
56
+ add_gem("jquery-rails")
57
+ generate("jquery:install")
58
+ rescue Exception => e
59
+ raise e
60
+ end
61
+
62
+ def setup_simple_form
63
+ add_gem("simple_form")
64
+ generate("simple_form:install")
65
+ rescue Exception => e
66
+ raise e
67
+ end
68
+
69
+ def setup_carrierwave
70
+ add_gem("mini_magick")
71
+ add_gem("carrierwave")
72
+ copy_file 'image_uploader.rb', 'app/uploaders/image_uploader.rb'
73
+ copy_file 'file_uploader.rb', 'app/uploaders/file_uploader.rb'
74
+ print_notes("carrierwave will use mini_magick by default!")
75
+ rescue Exception => e
76
+ raise e
51
77
  end
52
78
 
53
- def install_cancan
54
- opt = ask("Would you like to install CanCan for authorization? [yes]")
55
- if opt == "yes" || opt.blank?
56
- add_gem("cancan","~> 1.5.0")
57
- copy_file 'ability.rb', 'app/models/ability.rb'
58
- inject_into_file 'app/controllers/application_controller.rb', :after => "class ApplicationController < ActionController::Base" do
59
- "\n rescue_from CanCan::AccessDenied do |exception| flash[:alert] = exception.message; redirect_to root_url end;"
60
- end
61
- end
79
+ def setup_kaminari
80
+ add_gem("kaminari")
81
+ rescue Exception => e
82
+ raise e
62
83
  end
63
84
 
64
- def install_paperclip
65
- opt = ask("Would you like to install Paperclip for handling your attachment? [yes]")
66
- if opt == "yes" || opt.blank?
67
- add_gem("paperclip")
68
- end
85
+ def setup_ckeditor
86
+ # remove the existing install (if any)
87
+ destroy("public/javascripts/ckeditor")
88
+ ver = ask("==> What version of CKEditor javascript files do you need? [default 3.5.4]")
89
+ if ver == "3.5.4" || ver.blank?
90
+ add_gem("ckeditor","3.5.4")
91
+ template "ckeditor.rb", "config/initializers/ckeditor.rb"
92
+ extract("setup/templates/ckeditor.tar.gz","public/javascripts","ckeditor")
93
+ else
94
+ add_gem("ckeditor",ver)
95
+ generate("ckeditor:base --version=#{ver}")
96
+ end
97
+ rescue Exception => e
98
+ raise e
69
99
  end
70
100
 
71
- def install_tiny_mce
72
- opt = ask("Would you like to install Tiny-MCE Editor? [yes]")
73
- if opt == "yes" || opt.blank?
74
- add_gem("tiny_mce")
75
- end
101
+ def setup_test
102
+ gemfile = File.expand_path(destination_path("Gemfile"), __FILE__)
103
+
104
+ group_gems = "\ngroup :development, :test do"
105
+ group_gems << "\n gem 'rspec-rails'"
106
+ group_gems << "\n gem 'capybara'"
107
+ group_gems << "\n gem 'factory_girl_rails'"
108
+ group_gems << "\n gem 'faker'"
109
+ group_gems << "\n gem 'database_cleaner'"
110
+ group_gems << "\n gem 'escape_utils'"
111
+ group_gems << "\n gem 'guard-rspec'"
112
+ group_gems << "\n if RUBY_PLATFORM =~ /darwin/i"
113
+ group_gems << "\n gem 'rb-fsevent', :require => false"
114
+ group_gems << "\n gem 'growl'"
115
+ group_gems << "\n end"
116
+ group_gems << "\nend\n"
117
+
118
+ File.open(gemfile, 'a') { |f| f.write(group_gems) }
119
+ refresh_bundle
120
+
121
+ copy_file 'escape_utils.rb', 'config/initializers/escape_utils.rb'
122
+ generate("rspec:install")
123
+ remove_file 'spec/spec_helper.rb'
124
+ template 'spec_helper.rb', 'spec/spec_helper.rb'
125
+ `guard init rspec`
126
+
127
+ asking "Would you like to install Cucumber?" do
128
+ add_gem("cucumber-rails", :group => [:development, :test])
129
+ add_gem("guard-cucumber", :group => [:development, :test])
130
+ generate("cucumber:install", "--rspec", "--capybara")
131
+ `guard init cucumber`
132
+ end
133
+
134
+ print_notes("Please make sure you already install growl with growlnotify!!")
135
+ rescue Exception => e
136
+ raise e
76
137
  end
77
138
 
78
139
  end
File without changes
@@ -0,0 +1,54 @@
1
+ # Use this hook to configure ckeditor
2
+ if Object.const_defined?("Ckeditor")
3
+ Ckeditor.setup do |config|
4
+ # The file_post_name allows you to set the value name used to post the file.
5
+ # This is not related to the file name. The default value is 'data'.
6
+ # For maximum compatibility it is recommended that the default value is used.
7
+ #config.swf_file_post_name = "data"
8
+
9
+ # A text description that is displayed to the user in the File Browser dialog.
10
+ #config.swf_file_types_description = "Files"
11
+
12
+ # The file_types setting accepts a semi-colon separated list of file extensions
13
+ # that are allowed to be selected by the user. Use '*.*' to allow all file types.
14
+ #config.swf_file_types = "*.doc;*.wpd;*.pdf;*.swf;*.xls"
15
+
16
+ # The file_size_limit setting defines the maximum allowed size of a file to be uploaded.
17
+ # This setting accepts a value and unit. Valid units are B, KB, MB and GB.
18
+ # If the unit is omitted default is KB. A value of 0 (zero) is interpreted as unlimited.
19
+ # Note: This setting only applies to the user's browser. It does not affect any settings or limits on the web server.
20
+ #config.swf_file_size_limit = "10 MB"
21
+
22
+ # Defines the number of files allowed to be uploaded by SWFUpload.
23
+ # This setting also sets the upper bound of the file_queue_limit setting.
24
+ # Once the user has uploaded or queued the maximum number of files she will
25
+ # no longer be able to queue additional files. The value of 0 (zero) is interpreted as unlimited.
26
+ # Only successful uploads (uploads the trigger the uploadSuccess event) are counted toward the upload limit.
27
+ # The setStats function can be used to modify the number of successful uploads.
28
+ # Note: This value is not tracked across pages and is reset when a page is refreshed.
29
+ # File quotas should be managed by the web server.
30
+ #config.swf_file_upload_limit = 5
31
+
32
+ # The same as for downloads files, only to upload images
33
+ #config.swf_image_file_types_description = "Images"
34
+ #config.swf_image_file_types = "*.jpg;*.jpeg;*.png;*.gif"
35
+ #config.swf_image_file_size_limit = "5 MB"
36
+ #config.swf_image_file_upload_limit = 10
37
+
38
+ # Path for view all uploaded files
39
+ #config.file_manager_uri = "/ckeditor/attachments"
40
+
41
+ # Path for upload files process
42
+ #config.file_manager_upload_uri = "/ckeditor/attachments"
43
+
44
+ # Path for view all uploaded images
45
+ #config.file_manager_image_uri = "/ckeditor/pictures"
46
+
47
+ # Path for upload images process
48
+ #config.file_manager_image_upload_uri = "/ckeditor/pictures"
49
+
50
+ # Model's names witch processing in ckeditor_controller
51
+ #config.file_manager_image_model = "Ckeditor::Picture"
52
+ #config.file_manager_file_model = "Ckeditor::AttachmentFile"
53
+ end
54
+ end