active_leonardo 0.0.2

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 (38) hide show
  1. data/CHANGELOG +2 -0
  2. data/LICENSE +20 -0
  3. data/README.rdoc +157 -0
  4. data/active_template.rb +88 -0
  5. data/lib/generators/active_leonardo.rb +334 -0
  6. data/lib/generators/erb/leosca/leosca_generator.rb +122 -0
  7. data/lib/generators/leolay/USAGE +21 -0
  8. data/lib/generators/leolay/install_generator.rb +16 -0
  9. data/lib/generators/leolay/leolay_generator.rb +368 -0
  10. data/lib/generators/leolay/templates/app/admin/users.rb +63 -0
  11. data/lib/generators/leolay/templates/app/assets/javascripts/custom.js +10 -0
  12. data/lib/generators/leolay/templates/app/helpers/layout_helper.rb +27 -0
  13. data/lib/generators/leolay/templates/app/views/admin/users/_form.html.erb +21 -0
  14. data/lib/generators/leolay/templates/config.rb +11 -0
  15. data/lib/generators/leolay/templates/config/locales/en.yml +271 -0
  16. data/lib/generators/leolay/templates/config/locales/it.yml +298 -0
  17. data/lib/generators/leolay/templates/lib/development_mail_interceptor.rb +6 -0
  18. data/lib/generators/leolay/templates/lib/upd_activeadmin.rb +65 -0
  19. data/lib/generators/leolay/templates/lib/upd_array.rb +25 -0
  20. data/lib/generators/leolay/templates/styles/active/images/logo.png +0 -0
  21. data/lib/generators/leolay/templates/styles/active/images/style/Thumbs.db +0 -0
  22. data/lib/generators/leolay/templates/styles/active/images/style/ico_v.png +0 -0
  23. data/lib/generators/leolay/templates/styles/active/images/style/ico_x.png +0 -0
  24. data/lib/generators/leolay/templates/styles/active/stylesheets/app/_enviroment.css.scss +25 -0
  25. data/lib/generators/leolay/templates/styles/active/stylesheets/app/custom_active_admin.css.scss +23 -0
  26. data/lib/generators/leolay/templates/styles/active/stylesheets/app/stylesheet.css.scss +51 -0
  27. data/lib/generators/leolay/templates/styles/active/views/layout/_message.html.erb +3 -0
  28. data/lib/generators/leolay/templates/styles/active/views/layout/_session.html.erb +10 -0
  29. data/lib/generators/leolay/templates/styles/active/views/layout/application.html.erb +45 -0
  30. data/lib/generators/leosca/USAGE +23 -0
  31. data/lib/generators/leosca/install_generator.rb +16 -0
  32. data/lib/generators/rails/leosca/USAGE +40 -0
  33. data/lib/generators/rails/leosca/leosca_generator.rb +56 -0
  34. data/lib/generators/rails/leosca/templates/leosca.css +56 -0
  35. data/lib/generators/rails/leosca_controller/USAGE +23 -0
  36. data/lib/generators/rails/leosca_controller/leosca_controller_generator.rb +197 -0
  37. data/lib/generators/rails/leosca_controller/templates/controller.rb +3 -0
  38. metadata +117 -0
@@ -0,0 +1,122 @@
1
+ require 'rails/generators/erb/scaffold/scaffold_generator'
2
+ require File.join(File.dirname(__FILE__), '../../active_leonardo')
3
+
4
+ module Erb
5
+ module Generators
6
+ class LeoscaGenerator < ::Erb::Generators::ScaffoldGenerator
7
+ include ::ActiveLeonardo::Base
8
+ include ::ActiveLeonardo::Leosca
9
+ #include ::ActiveLeonardo::Nested
10
+ #puts 'erb:leosca'
11
+
12
+ source_root File.expand_path('../templates', __FILE__)
13
+ class_option :authorization, :type => :boolean, :default => true, :description => "Add code to manage authorization with cancan"
14
+ #class_option :remote, :type => :boolean, :default => true, :description => "Enable ajax. You can also do later set remote to true into index view."
15
+ #class_option :formtastic, :type => :boolean, :default => true, :description => "Create forms to manage with formtastic gem"
16
+ #class_option :under, :type => :string, :default => "", :banner => "brand/category", :desc => "To nest a resource under another(s)"
17
+ #class_option :leospace, :type => :string, :default => "", :banner => ":admin", :desc => "To nest a resource under namespace(s)"
18
+ class_option :auth_class, :type => :boolean, :default => 'user', :desc => "Set the authentication class name"
19
+
20
+ #override
21
+ #def copy_view_files
22
+ # available_views.each do |view|
23
+ # filenames = filenames_all_formats(view, source_paths)
24
+ # filenames.each do |filename|
25
+ # #Looking for custom filename into subfolder
26
+ # filename_source = "#{"formtastic/" if formtastic?}#{filename}"
27
+ # search_into_subfolder = nil
28
+ # source_paths.each do |path|
29
+ # if File.exists?(File.join(path,filename_source))
30
+ # search_into_subfolder = true
31
+ # break
32
+ # end
33
+ # end
34
+ # filename_source = filename unless search_into_subfolder
35
+ #
36
+ # template filename_source, File.join("app/views", base_namespaces, controller_file_path, filename)
37
+ # end
38
+ # end
39
+ #end
40
+
41
+ #def update_layout_html
42
+ # file = "app/views/layouts/_#{CONFIG[:default_style]}.html.erb"
43
+ # if nested?
44
+ # inject_into_file file, :before => " <!-- Insert above here other #{last_parent} elements -->" do
45
+ # <<-FILE.gsub(/^ /, '')
46
+ # #{"<% if can?(:read, #{class_name}) && controller.controller_path == '#{controller_name}' -%>" if authorization?}
47
+ # <li class="active"><%= t('models.#{plural_table_name}') %></li>
48
+ # <!-- Insert above here other #{singular_table_name} elements -->
49
+ # #{"<% end -%>" if authorization?}
50
+ # FILE
51
+ # end if File.exists?(file)
52
+ # else
53
+ # inject_into_file file, :before => " <!-- Insert above other elements -->" do
54
+ # <<-FILE.gsub(/^ /, '')
55
+ # #{"<% if can?(:read, #{class_name}) -%>" if authorization?}
56
+ # <li class="<%= controller.controller_path == '#{formatted_namespace_path}#{controller_name}' ? 'active' : '' %>"><a href="<%= #{list_resources_path} %>"><%= t('models.#{plural_table_name}') %></a></li>
57
+ # <!-- Insert above here other #{singular_table_name} elements -->
58
+ # #{"<% end -%>" if authorization?}
59
+ # FILE
60
+ # end if File.exists?(file)
61
+ # end
62
+ #end
63
+
64
+ #def update_parent_views
65
+ # return unless nested?
66
+ # file = "app/views/#{plural_last_parent}/_row_index.html.erb"
67
+ # inject_into_file file, :before => "<!-- Manage section, do not remove this tag -->" do
68
+ # <<-FILE.gsub(/^ /, '')
69
+ # <td><%= link_to t('models.#{plural_table_name}'), #{list_resources_path_back} %><%= link_to "", #{last_parent}_with_#{plural_table_name}_path(#{last_parent}), :id => "a_#{singular_table_name[0..5]}_\#{#{last_parent}.id}", :class =>"toggle_#{plural_table_name} desc", :remote => true %></td>
70
+ #
71
+ # FILE
72
+ # end if File.exists?(file)
73
+ # available_nested_views.each do |view|
74
+ # filenames = filenames_all_formats(view, source_paths)
75
+ # filenames.each do |filename|
76
+ # #Looking for custom filename into subfolder
77
+ # filename_source = "#{"formtastic/" if formtastic?}#{filename}"
78
+ # search_into_subfolder = nil
79
+ # source_paths.each do |path|
80
+ # if File.exists?(File.join(path,filename_source))
81
+ # search_into_subfolder = true
82
+ # break
83
+ # end
84
+ # end
85
+ # filename_source = filename unless search_into_subfolder
86
+ #
87
+ # template filename_source, File.join("app/views", base_namespaces, plural_last_parent, filename.sub('nested', plural_table_name))
88
+ # end
89
+ # end
90
+ #end
91
+
92
+ protected
93
+
94
+ #Override
95
+ #def available_views
96
+ # %w(index edit edit_multiple copy show new _form _form_multiple _fields destroy _show _list _row_index select)
97
+ #end
98
+ #
99
+ #def available_nested_views
100
+ # %w(_nested with_nested)
101
+ #end
102
+ #
103
+ #def filenames_all_formats(name, paths=[], formats=[:html, :js, nil])
104
+ # filenames = []
105
+ # paths.each do |path|
106
+ # formats.each do |format|
107
+ # filename = filename_with_extensions(format, name)
108
+ # if File.exists?(File.join(path, filename))
109
+ # filenames << filename
110
+ # end
111
+ # end
112
+ # break if filenames.any?
113
+ # end
114
+ # filenames
115
+ #end
116
+ #def filename_with_extensions(format, name, parser=:erb)
117
+ # [name, format, parser].compact.join(".")
118
+ #end
119
+
120
+ end
121
+ end
122
+ end
@@ -0,0 +1,21 @@
1
+ Description:
2
+ A layout and customized scaffold generator for Rails 3.1
3
+
4
+ Rails version supported:
5
+ 3.1
6
+
7
+ Available layout:
8
+ cloudy [default]
9
+
10
+ Example:
11
+ rails generate leolay
12
+ rails generate leolay --main_color=#c8c8c8
13
+ rails generate leolay layout1 --main_color=rgb(200,150,200) --second-color=yellow
14
+ rails generate leolay layout2 --skip-pagination --skip-authentication --skip-authorization
15
+
16
+ Will be:
17
+ Created an application layout with a nice and dynamic stylesheet based on sass
18
+ Customized views (only erb atm) and controller ajax ready and filters based on attributes, i18n messages ecc.
19
+ Customized application.rb to exclude javascript and stylesheet for every resource you will create
20
+ Customized application controller to manage i18n and others stuff like authentication, authorization ecc [optionals]
21
+ Created customized partials for pagination with kaminari [optional]
@@ -0,0 +1,16 @@
1
+ module Leolay
2
+ module Generators
3
+ class InstallGenerator < Rails::Generators::Base
4
+
5
+ source_root File.expand_path('../../', __FILE__)
6
+
7
+ def copy_all_to_local
8
+ #directory "leolay", "lib/generators/leolay"
9
+ copy_file "leolay/leolay_generator.rb", "lib/generators/leolay/leolay_generator.rb"
10
+ copy_file "leolay/USAGE", "lib/generators/leolay/USAGE"
11
+ directory "leolay/templates", "lib/generators/leolay/templates"
12
+ end
13
+ end
14
+ end
15
+ end
16
+
@@ -0,0 +1,368 @@
1
+ class LeolayGenerator < Rails::Generators::Base
2
+ source_root File.expand_path('../templates', __FILE__)
3
+ argument :style, :type => :string, :default => "active"
4
+ #class_option :pagination, :type => :boolean, :default => true, :desc => "Include pagination files"
5
+ class_option :main_color, :type => :string, :default => nil, :desc => "Force a main color for the stylesheet"
6
+ class_option :second_color, :type => :string, :default => nil, :desc => "Force a secondary color for the stylesheet"
7
+ class_option :authentication, :type => :boolean, :default => true, :desc => "Add code to manage authentication with devise"
8
+ class_option :authorization, :type => :boolean, :default => true, :desc => "Add code to manage authorization with cancan"
9
+ class_option :activeadmin, :type => :boolean, :default => true, :desc => "Add code to manage activeadmin gem"
10
+ class_option :auth_class, :type => :boolean, :default => 'User', :desc => "Set the authentication class name"
11
+ #class_option :formtastic, :type => :boolean, :default => true, :desc => "Copy formtastic files into leosca custom folder (inside project)"
12
+ #class_option :jquery_ui, :type => :boolean, :default => true, :desc => "To use jQuery ui improvement"
13
+ #class_option :rspec, :type => :boolean, :default => true, :desc => "Include custom rspec generator and custom templates"
14
+ #class_option :activeadmin, :type => :boolean, :default => true, :desc => "Include active admin management"
15
+ #class_option :old_views, :type => :boolean, :default => false, :desc => "Include old management"
16
+
17
+ #def generate_layout
18
+ # template "config.rb", "config/initializers/config.rb"
19
+ #
20
+ # template "styles/#{style_name}/stylesheets/app/stylesheet.sass", "app/assets/stylesheets/#{style_name}.sass"
21
+ # copy_file "styles/#{style_name}/stylesheets/app/states.sass", "app/assets/stylesheets/states.sass"
22
+ #
23
+ # copy_file "app/helpers/layout_helper.rb", "app/helpers/layout_helper.rb"
24
+ #
25
+ # copy_file "styles/#{style_name}/views/layout/application.html.erb", "app/views/layouts/application.html.erb", :force => true
26
+ # template "styles/#{style_name}/views/layout/_layout.html.erb", "app/views/layouts/_#{style_name}.html.erb"
27
+ # copy_file "styles/#{style_name}/views/layout/_message.html.erb", "app/views/application/_message.html.erb"
28
+ # copy_file "styles/#{style_name}/views/layout/_session.html.erb", "app/views/application/_session.html.erb" if options.authentication?
29
+ #
30
+ # locale_path = "config/locales"
31
+ # source_paths.each do |source_path|
32
+ # files = Dir["#{source_path}/#{locale_path}/??.yml"]
33
+ # files.each do |f|
34
+ # copy_file f, "#{locale_path}/#{File.basename(f)}"
35
+ # end
36
+ # break if files.any?
37
+ # end
38
+ #
39
+ # copy_file "lib/utility.rb", "lib/extras/utility.rb"
40
+ #
41
+ # if options.pagination?
42
+ # source_paths.each do |source_path|
43
+ # files = Dir["#{source_path}/#{locale_path}/kaminari.??.yml"]
44
+ # files.each do |f|
45
+ # copy_file f, "#{locale_path}/#{File.basename(f)}"
46
+ # end
47
+ # break if files.any?
48
+ # end
49
+ #
50
+ # directory "styles/#{style_name}/views/kaminari", "app/views/kaminari"
51
+ #
52
+ # directory "styles/#{style_name}/images/kaminari", "app/assets/images/styles/#{style_name}/kaminari"
53
+ # end
54
+ #
55
+ # directory "styles/#{style_name}/images/style", "app/assets/images/styles/#{style_name}"
56
+ #
57
+ # directory "styles/#{style_name}/images/jquery-ui", "app/assets/images/styles/#{style_name}/jquery-ui" if options.jquery_ui?
58
+ #
59
+ # if options.authentication?
60
+ # source_paths.each do |source_path|
61
+ # files = Dir["#{source_path}/#{locale_path}/devise.??.yml"]
62
+ # files.each do |f|
63
+ # copy_file f, "#{locale_path}/#{File.basename(f)}"
64
+ # end
65
+ # break if files.any?
66
+ # end
67
+ # directory "app/views/devise", "app/views/devise"
68
+ # end
69
+ #end
70
+ def generate_layout
71
+ template "styles/#{style_name}/stylesheets/app/stylesheet.css.scss", "app/assets/stylesheets/#{style_name}.css.scss"
72
+ template "styles/#{style_name}/stylesheets/app/custom_active_admin.css.scss", "app/assets/stylesheets/custom_active_admin.css.scss"
73
+ template "styles/#{style_name}/stylesheets/app/_enviroment.css.scss", "app/assets/stylesheets/_enviroment.css.scss"
74
+
75
+ copy_file "app/helpers/layout_helper.rb", "app/helpers/layout_helper.rb"
76
+ directory "styles/#{style_name}/images/style", "app/assets/images/styles/#{style_name}"
77
+
78
+ copy_file "styles/#{style_name}/views/layout/application.html.erb", "app/views/layouts/application.html.erb", :force => true
79
+ copy_file "styles/#{style_name}/views/layout/_message.html.erb", "app/views/application/_message.html.erb"
80
+ copy_file "styles/#{style_name}/views/layout/_session.html.erb", "app/views/application/_session.html.erb" if options.authentication?
81
+
82
+ template "config.rb", "config/initializers/config.rb"
83
+ locale_path = "config/locales"
84
+ source_paths.each do |source_path|
85
+ files = Dir["#{source_path}/#{locale_path}/??.yml"]
86
+ files.each do |f|
87
+ copy_file f, "#{locale_path}/#{File.basename(f)}"
88
+ end
89
+ break if files.any?
90
+ end
91
+ end
92
+
93
+ def setup_application
94
+ application do
95
+ <<-FILE.gsub(/^ /, '')
96
+ config.generators do |g|
97
+ g.stylesheets false
98
+ g.javascripts false
99
+ g.leosca_controller :leosca_controller
100
+ end
101
+
102
+ config.autoload_paths += %W(\#{config.root}/lib/extras)
103
+ FILE
104
+ end
105
+
106
+ file = "app/controllers/application_controller.rb"
107
+ if File.exists?(file)
108
+ inject_into_class file, ApplicationController do
109
+ <<-FILE.gsub(/^ /, '')
110
+ rescue_from CanCan::AccessDenied do |exception|
111
+ redirect_to root_url, :alert => exception.message
112
+ end
113
+ FILE
114
+ end if options.authorization?
115
+
116
+ inject_into_class file, ApplicationController do
117
+ <<-FILE.gsub(/^ /, '')
118
+ before_filter :localizate
119
+
120
+ def localizate
121
+ if params[:lang]
122
+ session[:lang] = params[:lang]
123
+ else
124
+ session[:lang] ||= I18n.default_locale
125
+ end
126
+ I18n.locale = session[:lang]
127
+ end
128
+ require "upd_activeadmin"
129
+ FILE
130
+ end
131
+ end
132
+
133
+ #file = "app/helpers/application_helper.rb"
134
+ #if File.exists?(file)
135
+ # inject_into_file file, :after => "module ApplicationHelper" do
136
+ # <<-FILE.gsub(/^ /, '')
137
+ #
138
+ # def sortable(column, title = nil, remote = nil, path = nil, *params)
139
+ # column = column.to_s
140
+ # title ||= column.titleize
141
+ # css_class = (column == sort_column) ? "sorted \#{sort_direction}" : nil
142
+ # direction = (column == sort_column && sort_direction == "asc") ? "desc" : "asc"
143
+ # params << "{:sort => column, :direction => direction}"
144
+ # path = path ? eval("#\{path}(\#{params.join(',')})") : {:sort => column, :direction => direction}
145
+ # link_to(title, path, :remote => true, :disable_with => t(:loading), :class => css_class)
146
+ # end
147
+ # FILE
148
+ # end
149
+ #end
150
+ end
151
+
152
+ def setup_authentication
153
+ file = "app/models/#{options.auth_class}.rb"
154
+ #puts "File #{file} #{File.exists?(file) ? "" : "does not"} exists!"
155
+ return unless options.authentication? and File.exists?(file)
156
+
157
+ inject_into_class file, User do
158
+ <<-FILE.gsub(/^ /, '')
159
+ ROLES = %w[admin manager user guest]
160
+ scope :with_role, lambda { |role| {:conditions => "roles_mask & \#{2**ROLES.index(role.to_s)} > 0 "} }
161
+
162
+ def roles=(roles)
163
+ self.roles_mask = (roles & ROLES).map { |r| 2**ROLES.index(r) }.sum
164
+ end
165
+ def roles
166
+ ROLES.reject { |r| ((roles_mask || 0) & 2**ROLES.index(r)).zero? }
167
+ end
168
+ def role_symbols
169
+ roles.map(&:to_sym)
170
+ end
171
+ def role?(role)
172
+ roles.include? role.to_s
173
+ end
174
+ def admin?
175
+ self.role? 'admin'
176
+ end
177
+ FILE
178
+ end
179
+
180
+ end
181
+
182
+ def setup_authorization
183
+ file = "app/models/ability.rb"
184
+ return unless File.exists?(file)
185
+ inject_into_file file, :before => " end\nend" do
186
+ <<-FILE.gsub(/^ /, '')
187
+ #{options[:auth_class].downcase} ||= #{options[:auth_class].classify}.new
188
+ can :manage, :all if #{options[:auth_class].downcase}.role? :admin
189
+
190
+ FILE
191
+ end
192
+ end
193
+
194
+ def create_users_for_development
195
+ return unless options.authentication?
196
+ file = "db/seeds.rb"
197
+ append_file file do
198
+ <<-FILE.gsub(/^ /, '')
199
+ user=User.new :email => 'admin@#{app_name}.com', :password => 'abcd1234', :password_confirmation => 'abcd1234'
200
+ #{"user.roles=['admin']" if options.authorization?}
201
+ user.save
202
+ user=User.new :email => 'manager@#{app_name}.com', :password => 'abcd1234', :password_confirmation => 'abcd1234'
203
+ #{"user.roles=['manager']" if options.authorization?}
204
+ user.save
205
+ user=User.new :email => 'user@#{app_name}.com', :password => 'abcd1234', :password_confirmation => 'abcd1234'
206
+ #{"user.roles=['user']" if options.authorization?}
207
+ user.save
208
+ FILE
209
+ end if File.exists?(file)
210
+ end
211
+
212
+ #def setup_formtastic
213
+ # return unless options.formtastic?
214
+ #
215
+ # path = "styles/#{style_name}/stylesheets/vendor/formtastic"
216
+ # dest_path = "vendor/assets/stylesheets/formtastic"
217
+ #
218
+ # path = dest_path unless File.exists?(path)
219
+ #
220
+ # file = "#{path}/formtastic.css"
221
+ # copy_file file, file unless File.exists?(file)
222
+ # file = "#{path}/formtastic_changes.css"
223
+ # copy_file file, file
224
+ #
225
+ # file = "config/initializers/formtastic.rb"
226
+ # inject_into_file file, :after => "# Formtastic::FormBuilder.i18n_lookups_by_default = false" do
227
+ # <<-FILE.gsub(/^ /, '')
228
+ #
229
+ # Formtastic::FormBuilder.i18n_lookups_by_default = true
230
+ # FILE
231
+ # end if File.exists?(file)
232
+ #
233
+ # path = "lib/templates/erb/"
234
+ # remove_file path if File.exists?(path)
235
+ #end
236
+
237
+ def setup_javascript
238
+ app_path = "app/assets/javascripts"
239
+
240
+ file = "#{app_path}/custom.js"
241
+ copy_file file, file
242
+
243
+ file = "#{app_path}/application.js"
244
+ append_file file do
245
+ <<-FILE.gsub(/^ /, '')
246
+
247
+ //= require custom
248
+ FILE
249
+ end
250
+
251
+ file = "#{app_path}/active_admin.js"
252
+ append_file file do
253
+ <<-FILE.gsub(/^ /, '')
254
+
255
+ //= require custom
256
+ FILE
257
+ end
258
+
259
+ end
260
+
261
+ #def setup_stylesheets
262
+ # app_path = "app/assets/stylesheets"
263
+ # vendor_path = "vendor/assets/stylesheets"
264
+ #
265
+ # file = "#{vendor_path}/vendor.css"
266
+ # copy_file file, file
267
+ #
268
+ # if options.jquery_ui?
269
+ # directory "styles/#{style_name}/stylesheets/vendor/jquery-ui", "vendor/assets/stylesheets/jquery-ui"
270
+ #
271
+ # file = "#{app_path}/application.css"
272
+ # inject_into_file file, :before => "*/" do
273
+ # <<-FILE.gsub(/^ /, '')
274
+ # *= require vendor
275
+ # FILE
276
+ # end
277
+ #
278
+ # file = "#{vendor_path}/vendor.css"
279
+ # inject_into_file file, :before => "*/" do
280
+ # <<-FILE.gsub(/^ /, '')
281
+ # *= require_tree ./jquery-ui
282
+ # FILE
283
+ # end
284
+ # end
285
+ #
286
+ # file = "#{vendor_path}/vendor.css"
287
+ # inject_into_file file, :before => "*/" do
288
+ # <<-FILE.gsub(/^ /, '')
289
+ # *= require_tree ./formtastic
290
+ # FILE
291
+ # end if options.formtastic?
292
+ #end
293
+
294
+ #def setup_rspec
295
+ # file = "spec/spec_helper.rb"
296
+ # return unless File.exists?(file) && options.rspec?
297
+ # inject_into_file file, :after => "require 'rspec/rails'" do
298
+ # <<-FILE.gsub(/^ /, '')
299
+ #
300
+ # require 'capybara/rspec'
301
+ # require 'helpers/application_helpers_spec'
302
+ #
303
+ # Capybara.default_wait_time = 10 #default=2
304
+ # FILE
305
+ # end
306
+ #
307
+ # gsub_file file, 'config.fixture_path = "#{::Rails.root}/spec/fixtures"', '#config.fixture_path = "#{::Rails.root}/spec/fixtures"'
308
+ # #inject_into_file file, "#", :before => 'config.fixture_path = "#{::Rails.root}/spec/fixtures"'
309
+ #
310
+ # gsub_file file, "config.use_transactional_fixtures = true" do
311
+ # <<-FILE.gsub(/^ /, '')
312
+ #config.use_transactional_fixtures = false
313
+ #
314
+ # config.before(:suite) do
315
+ # DatabaseCleaner.strategy = :truncation
316
+ # end
317
+ #
318
+ # config.before(:each) do
319
+ # DatabaseCleaner.start
320
+ # end
321
+ #
322
+ # config.after(:each) do
323
+ # DatabaseCleaner.clean
324
+ # end
325
+ #
326
+ # config.include ApplicationHelpers
327
+ # FILE
328
+ # end
329
+ #
330
+ # file = "spec/factories.rb"
331
+ # copy_file file, file
332
+ # file = "spec/support/devise.rb"
333
+ # copy_file file, file
334
+ # file = "spec/helpers/application_helpers_spec.rb"
335
+ # copy_file file, file
336
+ #
337
+ #end
338
+
339
+ def setup_extras
340
+ copy_file "lib/upd_array.rb", "lib/extras/upd_array.rb"
341
+ template "lib/upd_activeadmin.rb", "lib/extras/upd_activeadmin.rb"
342
+ end
343
+
344
+ def setup_activeadmin
345
+ file = "config/initializers/active_admin.rb"
346
+ return unless options.activeadmin? and File.exists?(file)
347
+ template "app/admin/users.rb", "app/admin/#{options[:auth_class].downcase.pluralize}.rb"
348
+ template "app/views/admin/users/_form.html.erb", "app/views/admin/#{options[:auth_class].downcase.pluralize}/_form.html.erb"
349
+
350
+ file = "app/assets/stylesheets/active_admin.css.scss"
351
+ append_file file do
352
+ <<-FILE.gsub(/^ /, '')
353
+
354
+ @import "custom_active_admin";
355
+ FILE
356
+ end if File.exists?(file)
357
+ end
358
+
359
+ private
360
+ def style_name
361
+ style.underscore
362
+ end
363
+
364
+ def app_name
365
+ File.basename(Dir.pwd)
366
+ end
367
+
368
+ end