active_leonardo 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +44 -0
- data/LICENSE +19 -19
- data/README.md +173 -0
- data/active_template.rb +141 -137
- data/lib/generators/active_leonardo.rb +7 -1
- data/lib/generators/erb/leosca/leosca_generator.rb +122 -122
- data/lib/generators/leolay/USAGE +21 -21
- data/lib/generators/leolay/leolay_generator.rb +420 -400
- data/lib/generators/leolay/templates/app/admin/users.rb +87 -87
- data/lib/generators/leolay/templates/config/locales/it.yml +7 -0
- data/lib/generators/leolay/templates/spec/helpers/application_helpers.rb +13 -13
- data/lib/generators/leolay/templates/spec/support/devise.rb +4 -4
- data/lib/generators/leolay/templates/styles/active/stylesheets/app/custom_active_admin.css.scss +27 -27
- data/lib/generators/leosca/USAGE +23 -23
- data/lib/generators/rails/leosca/USAGE +39 -39
- data/lib/generators/rails/leosca/leosca_generator.rb +55 -55
- data/lib/generators/rails/leosca/templates/leosca.css +56 -56
- data/lib/generators/rails/leosca_controller/USAGE +23 -23
- data/lib/generators/rails/leosca_controller/leosca_controller_generator.rb +192 -188
- data/lib/generators/rails/leosca_controller/templates/controller.rb +3 -3
- data/lib/generators/rspec/leointegration/leointegration_generator.rb +35 -35
- data/lib/generators/rspec/leointegration/templates/admin/feature.rb +67 -67
- data/lib/generators/rspec/leointegration/templates/feature.rb +9 -9
- data/lib/generators/rspec/leosca/leosca_generator.rb +57 -57
- data/lib/generators/rspec/leosca/templates/admin/controller_spec.rb +181 -181
- data/lib/generators/rspec/leosca/templates/admin/edit_spec.rb +31 -31
- data/lib/generators/rspec/leosca/templates/admin/index_spec.rb +32 -32
- data/lib/generators/rspec/leosca/templates/admin/new_spec.rb +30 -30
- data/lib/generators/rspec/leosca/templates/admin/routing_spec.rb +39 -39
- data/lib/generators/rspec/leosca/templates/admin/show_spec.rb +28 -28
- data/lib/generators/rspec/leosca/templates/controller_spec.rb +168 -168
- data/lib/generators/rspec/leosca/templates/edit_spec.rb +31 -31
- data/lib/generators/rspec/leosca/templates/index_spec.rb +32 -32
- data/lib/generators/rspec/leosca/templates/new_spec.rb +30 -30
- data/lib/generators/rspec/leosca/templates/routing_spec.rb +39 -39
- data/lib/generators/rspec/leosca/templates/show_spec.rb +28 -28
- metadata +55 -124
- data/CHANGELOG +0 -28
- data/README.rdoc +0 -159
@@ -1,87 +1,87 @@
|
|
1
|
-
ActiveAdmin.register <%= options[:auth_class] %> do
|
2
|
-
<%- if options.authorization? -%>
|
3
|
-
menu :if => proc{ can?(:manage, <%= options[:auth_class] %>) }
|
4
|
-
<%- end -%>
|
5
|
-
config.sort_order = 'email_asc'
|
6
|
-
|
7
|
-
controller do
|
8
|
-
<%- if options.authorization? -%>
|
9
|
-
load_resource :except => :index
|
10
|
-
authorize_resource
|
11
|
-
<%- end -%>
|
12
|
-
def update
|
13
|
-
unless params[:<%= options[:auth_class].downcase %>]['password'] && params[:<%= options[:auth_class].downcase %>]['password'].size > 0
|
14
|
-
params[:<%= options[:auth_class].downcase %>].delete 'password'
|
15
|
-
params[:<%= options[:auth_class].downcase %>].delete 'password_confirmation'
|
16
|
-
end
|
17
|
-
super do
|
18
|
-
#do something
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
index do
|
24
|
-
selectable_column
|
25
|
-
id_column
|
26
|
-
column :email
|
27
|
-
#column :group, :sortable => :group_id
|
28
|
-
<%- if options.authorization? -%>
|
29
|
-
column :roles do |<%= options[:auth_class].downcase %>|
|
30
|
-
<%= options[:auth_class].downcase %>.roles.join ", "
|
31
|
-
end
|
32
|
-
<%- end -%>
|
33
|
-
column :current_sign_in_at
|
34
|
-
column :current_sign_in_ip
|
35
|
-
column :created_at
|
36
|
-
default_actions
|
37
|
-
end
|
38
|
-
|
39
|
-
filter :email
|
40
|
-
filter :created_at
|
41
|
-
|
42
|
-
form do |f|
|
43
|
-
<%- if options.authorization? -%>
|
44
|
-
input_roles = "<li>" <<
|
45
|
-
f.label(:roles) <<
|
46
|
-
<%= options[:auth_class] %>::ROLES.map{|role| check_box_tag("<%= options[:auth_class].downcase %>[roles][]", role, f.object.roles.include?(role)) << ' ' << role.humanize.html_safe }.join(" ") <<
|
47
|
-
hidden_field_tag("<%= options[:auth_class].downcase %>[roles][]") <<
|
48
|
-
"</li>"
|
49
|
-
<%- end -%>
|
50
|
-
f.inputs "Account" do
|
51
|
-
f.input :email
|
52
|
-
f.input :password
|
53
|
-
f.input(:password_confirmation) <%= "<< input_roles.html_safe" if options.authorization? %>
|
54
|
-
|
55
|
-
end
|
56
|
-
f.
|
57
|
-
end
|
58
|
-
|
59
|
-
show do
|
60
|
-
attributes_table do
|
61
|
-
row :email
|
62
|
-
#row :group
|
63
|
-
row :current_sign_in_at
|
64
|
-
row :last_sign_in_at
|
65
|
-
row :sign_in_count
|
66
|
-
row :current_sign_in_ip
|
67
|
-
<%- if options.authorization? -%>
|
68
|
-
row :roles do |<%= options[:auth_class].downcase %>|
|
69
|
-
<%= options[:auth_class].downcase %>.roles.join ", "
|
70
|
-
end
|
71
|
-
<%- end -%>
|
72
|
-
row :created_at
|
73
|
-
row :updated_at
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
csv do
|
78
|
-
column :email
|
79
|
-
#column("Name") { |<%= options[:auth_class].downcase %>| <%= options[:auth_class].downcase %>.name }
|
80
|
-
#column("Group") { |<%= options[:auth_class].downcase %>| <%= options[:auth_class].downcase %>.group.try(:name) }
|
81
|
-
<%- if options.authorization? -%>
|
82
|
-
column(I18n.t('attributes.<%= options[:auth_class].downcase %>.roles')) { |<%= options[:auth_class].downcase %>| <%= options[:auth_class].downcase %>.roles.join ", " }
|
83
|
-
<%- end -%>
|
84
|
-
column(I18n.t('attributes.created_at')) { |<%= options[:auth_class].downcase %>| <%= options[:auth_class].downcase %>.created_at.strftime("%d/%m/%Y") }
|
85
|
-
column(I18n.t('attributes.<%= options[:auth_class].downcase %>.last_sign_in_at')) { |<%= options[:auth_class].downcase %>| <%= options[:auth_class].downcase %>.last_sign_in_at.strftime("%d/%m/%Y") if <%= options[:auth_class].downcase %>.last_sign_in_at }
|
86
|
-
end
|
87
|
-
end
|
1
|
+
ActiveAdmin.register <%= options[:auth_class] %> do
|
2
|
+
<%- if options.authorization? -%>
|
3
|
+
menu :if => proc{ can?(:manage, <%= options[:auth_class] %>) }
|
4
|
+
<%- end -%>
|
5
|
+
config.sort_order = 'email_asc'
|
6
|
+
|
7
|
+
controller do
|
8
|
+
<%- if options.authorization? -%>
|
9
|
+
load_resource :except => :index
|
10
|
+
authorize_resource
|
11
|
+
<%- end -%>
|
12
|
+
def update
|
13
|
+
unless params[:<%= options[:auth_class].downcase %>]['password'] && params[:<%= options[:auth_class].downcase %>]['password'].size > 0
|
14
|
+
params[:<%= options[:auth_class].downcase %>].delete 'password'
|
15
|
+
params[:<%= options[:auth_class].downcase %>].delete 'password_confirmation'
|
16
|
+
end
|
17
|
+
super do
|
18
|
+
#do something
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
index do
|
24
|
+
selectable_column
|
25
|
+
id_column
|
26
|
+
column :email
|
27
|
+
#column :group, :sortable => :group_id
|
28
|
+
<%- if options.authorization? -%>
|
29
|
+
column :roles do |<%= options[:auth_class].downcase %>|
|
30
|
+
<%= options[:auth_class].downcase %>.roles.join ", "
|
31
|
+
end
|
32
|
+
<%- end -%>
|
33
|
+
column :current_sign_in_at
|
34
|
+
column :current_sign_in_ip
|
35
|
+
column :created_at
|
36
|
+
default_actions
|
37
|
+
end
|
38
|
+
|
39
|
+
filter :email
|
40
|
+
filter :created_at
|
41
|
+
|
42
|
+
form do |f|
|
43
|
+
<%- if options.authorization? -%>
|
44
|
+
input_roles = "<li>" <<
|
45
|
+
f.label(:roles) <<
|
46
|
+
<%= options[:auth_class] %>::ROLES.map{|role| check_box_tag("<%= options[:auth_class].downcase %>[roles][]", role, f.object.roles.include?(role)) << ' ' << role.humanize.html_safe }.join(" ") <<
|
47
|
+
hidden_field_tag("<%= options[:auth_class].downcase %>[roles][]") <<
|
48
|
+
"</li>"
|
49
|
+
<%- end -%>
|
50
|
+
f.inputs "Account" do
|
51
|
+
f.input :email
|
52
|
+
f.input :password
|
53
|
+
f.input(:password_confirmation) <%= "<< input_roles.html_safe" if options.authorization? %>
|
54
|
+
|
55
|
+
end
|
56
|
+
f.actions
|
57
|
+
end
|
58
|
+
|
59
|
+
show do
|
60
|
+
attributes_table do
|
61
|
+
row :email
|
62
|
+
#row :group
|
63
|
+
row :current_sign_in_at
|
64
|
+
row :last_sign_in_at
|
65
|
+
row :sign_in_count
|
66
|
+
row :current_sign_in_ip
|
67
|
+
<%- if options.authorization? -%>
|
68
|
+
row :roles do |<%= options[:auth_class].downcase %>|
|
69
|
+
<%= options[:auth_class].downcase %>.roles.join ", "
|
70
|
+
end
|
71
|
+
<%- end -%>
|
72
|
+
row :created_at
|
73
|
+
row :updated_at
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
csv do
|
78
|
+
column :email
|
79
|
+
#column("Name") { |<%= options[:auth_class].downcase %>| <%= options[:auth_class].downcase %>.name }
|
80
|
+
#column("Group") { |<%= options[:auth_class].downcase %>| <%= options[:auth_class].downcase %>.group.try(:name) }
|
81
|
+
<%- if options.authorization? -%>
|
82
|
+
column(I18n.t('attributes.<%= options[:auth_class].downcase %>.roles')) { |<%= options[:auth_class].downcase %>| <%= options[:auth_class].downcase %>.roles.join ", " }
|
83
|
+
<%- end -%>
|
84
|
+
column(I18n.t('attributes.created_at')) { |<%= options[:auth_class].downcase %>| <%= options[:auth_class].downcase %>.created_at.strftime("%d/%m/%Y") }
|
85
|
+
column(I18n.t('attributes.<%= options[:auth_class].downcase %>.last_sign_in_at')) { |<%= options[:auth_class].downcase %>| <%= options[:auth_class].downcase %>.last_sign_in_at.strftime("%d/%m/%Y") if <%= options[:auth_class].downcase %>.last_sign_in_at }
|
86
|
+
end
|
87
|
+
end
|
@@ -254,6 +254,13 @@ it:
|
|
254
254
|
canceled: "Eliminato"
|
255
255
|
completed: "Completato"
|
256
256
|
closed: "Chiuso"
|
257
|
+
views:
|
258
|
+
pagination:
|
259
|
+
next: "Succ."
|
260
|
+
previous: "Prec."
|
261
|
+
first: "Primo"
|
262
|
+
last: "Ultimo"
|
263
|
+
truncate: "..."
|
257
264
|
|
258
265
|
unknown_request: "Spiacente, richiesta sconosciuta, non è possibile eseguirla"
|
259
266
|
generic_error: "Un errore impedisce di svolgere questa operazione"
|
@@ -1,13 +1,13 @@
|
|
1
|
-
module ApplicationHelpers
|
2
|
-
def login_view_as(role=:user)
|
3
|
-
user = Factory(role)
|
4
|
-
fill_in 'user_email', :with => user.email
|
5
|
-
fill_in 'user_password', :with => user.password
|
6
|
-
click_button 'Login'
|
7
|
-
end
|
8
|
-
def login_controller_as(role=:user)
|
9
|
-
user = Factory(role)
|
10
|
-
#user.confirm! # or set a confirmed_at inside the factory. Only necessary if you are using the confirmable module
|
11
|
-
sign_in user
|
12
|
-
end
|
13
|
-
end
|
1
|
+
module ApplicationHelpers
|
2
|
+
def login_view_as(role=:user)
|
3
|
+
user = Factory(role)
|
4
|
+
fill_in 'user_email', :with => user.email
|
5
|
+
fill_in 'user_password', :with => user.password
|
6
|
+
click_button 'Login'
|
7
|
+
end
|
8
|
+
def login_controller_as(role=:user)
|
9
|
+
user = Factory(role)
|
10
|
+
#user.confirm! # or set a confirmed_at inside the factory. Only necessary if you are using the confirmable module
|
11
|
+
sign_in user
|
12
|
+
end
|
13
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
RSpec.configure do |config|
|
2
|
-
config.include Devise::TestHelpers, :type => :controller
|
3
|
-
config.include Devise::TestHelpers, :type => :view
|
4
|
-
end
|
1
|
+
RSpec.configure do |config|
|
2
|
+
config.include Devise::TestHelpers, :type => :controller
|
3
|
+
config.include Devise::TestHelpers, :type => :view
|
4
|
+
end
|
data/lib/generators/leolay/templates/styles/active/stylesheets/app/custom_active_admin.css.scss
CHANGED
@@ -1,28 +1,28 @@
|
|
1
|
-
body.active_admin {
|
2
|
-
@import "enviroment";
|
3
|
-
|
4
|
-
#active_admin_content {
|
5
|
-
padding: 10px 10px;
|
6
|
-
}
|
7
|
-
.price {
|
8
|
-
text-align: right;
|
9
|
-
}
|
10
|
-
table.index_table tr.odd.selected td {
|
11
|
-
background: none repeat scroll 0 0 #FFFFBD;
|
12
|
-
}
|
13
|
-
table.index_table tr.even.selected td {
|
14
|
-
background: none repeat scroll 0 0 #FFFFAC;
|
15
|
-
}
|
16
|
-
.table_tools_segmented_control li.selected {
|
17
|
-
a {
|
18
|
-
background-color: #E6E6E6;
|
19
|
-
cursor: pointer;
|
20
|
-
}
|
21
|
-
a:hover {
|
22
|
-
color: inherit;
|
23
|
-
}
|
24
|
-
}
|
25
|
-
#footer {
|
26
|
-
text-align: center;
|
27
|
-
}
|
1
|
+
body.active_admin {
|
2
|
+
@import "enviroment";
|
3
|
+
|
4
|
+
#active_admin_content {
|
5
|
+
padding: 10px 10px;
|
6
|
+
}
|
7
|
+
.price {
|
8
|
+
text-align: right;
|
9
|
+
}
|
10
|
+
table.index_table tr.odd.selected td {
|
11
|
+
background: none repeat scroll 0 0 #FFFFBD;
|
12
|
+
}
|
13
|
+
table.index_table tr.even.selected td {
|
14
|
+
background: none repeat scroll 0 0 #FFFFAC;
|
15
|
+
}
|
16
|
+
.table_tools_segmented_control li.selected {
|
17
|
+
a {
|
18
|
+
background-color: #E6E6E6;
|
19
|
+
cursor: pointer;
|
20
|
+
}
|
21
|
+
a:hover {
|
22
|
+
color: inherit;
|
23
|
+
}
|
24
|
+
}
|
25
|
+
#footer {
|
26
|
+
text-align: center;
|
27
|
+
}
|
28
28
|
}
|
data/lib/generators/leosca/USAGE
CHANGED
@@ -1,23 +1,23 @@
|
|
1
|
-
Description:
|
2
|
-
en: Copy all templates in the project directory lib \ generators to allow customization.
|
3
|
-
it: Copia tutti i template nella directory del progetto lib\generators per consentire la personalizzazione.
|
4
|
-
|
5
|
-
Example:
|
6
|
-
rails generate leosca:install
|
7
|
-
|
8
|
-
This will create:
|
9
|
-
lib/generators/erb/leosca/USAGE
|
10
|
-
lib/generators/erb/leosca/leosca_generator.rb
|
11
|
-
lib/generators/erb/leosca/templates/_form.html.erb
|
12
|
-
lib/generators/erb/leosca/templates/_list.erb
|
13
|
-
lib/generators/erb/leosca/templates/edit.html.erb
|
14
|
-
lib/generators/erb/leosca/templates/index.html.erb
|
15
|
-
lib/generators/erb/leosca/templates/index.js.erb
|
16
|
-
lib/generators/erb/leosca/templates/new.html.erb
|
17
|
-
lib/generators/erb/leosca/templates/show.html.erb
|
18
|
-
lib/generators/rails/leosca/USAGE
|
19
|
-
lib/generators/rails/leosca/leosca_generator.rb
|
20
|
-
lib/generators/rails/leosca/templates/leosca.css
|
21
|
-
lib/generators/rails/leosca_controller/USAGE
|
22
|
-
lib/generators/rails/leosca_controller/leosca_controller_generator.rb
|
23
|
-
lib/generators/rails/leosca_controller/templates/controller.rb
|
1
|
+
Description:
|
2
|
+
en: Copy all templates in the project directory lib \ generators to allow customization.
|
3
|
+
it: Copia tutti i template nella directory del progetto lib\generators per consentire la personalizzazione.
|
4
|
+
|
5
|
+
Example:
|
6
|
+
rails generate leosca:install
|
7
|
+
|
8
|
+
This will create:
|
9
|
+
lib/generators/erb/leosca/USAGE
|
10
|
+
lib/generators/erb/leosca/leosca_generator.rb
|
11
|
+
lib/generators/erb/leosca/templates/_form.html.erb
|
12
|
+
lib/generators/erb/leosca/templates/_list.erb
|
13
|
+
lib/generators/erb/leosca/templates/edit.html.erb
|
14
|
+
lib/generators/erb/leosca/templates/index.html.erb
|
15
|
+
lib/generators/erb/leosca/templates/index.js.erb
|
16
|
+
lib/generators/erb/leosca/templates/new.html.erb
|
17
|
+
lib/generators/erb/leosca/templates/show.html.erb
|
18
|
+
lib/generators/rails/leosca/USAGE
|
19
|
+
lib/generators/rails/leosca/leosca_generator.rb
|
20
|
+
lib/generators/rails/leosca/templates/leosca.css
|
21
|
+
lib/generators/rails/leosca_controller/USAGE
|
22
|
+
lib/generators/rails/leosca_controller/leosca_controller_generator.rb
|
23
|
+
lib/generators/rails/leosca_controller/templates/controller.rb
|
@@ -1,40 +1,40 @@
|
|
1
|
-
Description:
|
2
|
-
en: Customized version of rails's scaffold, to be used after leolay.
|
3
|
-
it: Versione personalizzata dello scaffold di rails, da usare dopo leolay.
|
4
|
-
|
5
|
-
Scaffolds an entire resource, from model and migration to controller and
|
6
|
-
views, along with a full test suite. The resource is ready to use as a
|
7
|
-
starting point for your RESTful, resource-oriented application.
|
8
|
-
|
9
|
-
Pass the name of the model (in singular form), either CamelCased or
|
10
|
-
under_scored, as the first argument, and an optional list of attribute
|
11
|
-
pairs.
|
12
|
-
|
13
|
-
Attribute pairs are field:type arguments specifying the
|
14
|
-
model's attributes. Timestamps are added by default, so you don't have to
|
15
|
-
specify them by hand as 'created_at:datetime updated_at:datetime'.
|
16
|
-
|
17
|
-
You don't have to think up every attribute up front, but it helps to
|
18
|
-
sketch out a few so you can start working with the resource immediately.
|
19
|
-
|
20
|
-
For example, 'scaffold post title:string body:text published:boolean'
|
21
|
-
gives you a model with those three attributes, a controller that handles
|
22
|
-
the create/show/update/destroy, forms to create and edit your posts, and
|
23
|
-
an index that lists them all, as well as a resources :posts
|
24
|
-
declaration in config/routes.rb.
|
25
|
-
|
26
|
-
If you want to remove all the generated files, run
|
27
|
-
'rails destroy scaffold ModelName'.
|
28
|
-
|
29
|
-
Use after leolay:
|
30
|
-
1. rails generate leolay
|
31
|
-
2. rails generate leosca
|
32
|
-
|
33
|
-
Usage example:
|
34
|
-
rails generate leosca product name:string description:text active:boolean items:integer price:decimal
|
35
|
-
|
36
|
-
Available options:
|
37
|
-
rails generate leosca product name:string --skip-seeds
|
38
|
-
rails generate leosca product name:string --seeds=60 => if you need more records
|
39
|
-
|
1
|
+
Description:
|
2
|
+
en: Customized version of rails's scaffold, to be used after leolay.
|
3
|
+
it: Versione personalizzata dello scaffold di rails, da usare dopo leolay.
|
4
|
+
|
5
|
+
Scaffolds an entire resource, from model and migration to controller and
|
6
|
+
views, along with a full test suite. The resource is ready to use as a
|
7
|
+
starting point for your RESTful, resource-oriented application.
|
8
|
+
|
9
|
+
Pass the name of the model (in singular form), either CamelCased or
|
10
|
+
under_scored, as the first argument, and an optional list of attribute
|
11
|
+
pairs.
|
12
|
+
|
13
|
+
Attribute pairs are field:type arguments specifying the
|
14
|
+
model's attributes. Timestamps are added by default, so you don't have to
|
15
|
+
specify them by hand as 'created_at:datetime updated_at:datetime'.
|
16
|
+
|
17
|
+
You don't have to think up every attribute up front, but it helps to
|
18
|
+
sketch out a few so you can start working with the resource immediately.
|
19
|
+
|
20
|
+
For example, 'scaffold post title:string body:text published:boolean'
|
21
|
+
gives you a model with those three attributes, a controller that handles
|
22
|
+
the create/show/update/destroy, forms to create and edit your posts, and
|
23
|
+
an index that lists them all, as well as a resources :posts
|
24
|
+
declaration in config/routes.rb.
|
25
|
+
|
26
|
+
If you want to remove all the generated files, run
|
27
|
+
'rails destroy scaffold ModelName'.
|
28
|
+
|
29
|
+
Use after leolay:
|
30
|
+
1. rails generate leolay
|
31
|
+
2. rails generate leosca
|
32
|
+
|
33
|
+
Usage example:
|
34
|
+
rails generate leosca product name:string description:text active:boolean items:integer price:decimal
|
35
|
+
|
36
|
+
Available options:
|
37
|
+
rails generate leosca product name:string --skip-seeds
|
38
|
+
rails generate leosca product name:string --seeds=60 => if you need more records
|
39
|
+
|
40
40
|
Of course, these options are in addition to those provided by the original scaffold
|
@@ -1,56 +1,56 @@
|
|
1
|
-
require 'rails/generators/rails/scaffold/scaffold_generator'
|
2
|
-
require File.join(File.dirname(__FILE__), '../../active_leonardo')
|
3
|
-
|
4
|
-
module Rails
|
5
|
-
module Generators
|
6
|
-
class LeoscaGenerator < ::Rails::Generators::ScaffoldGenerator
|
7
|
-
include ::ActiveLeonardo::Base
|
8
|
-
#include ::Leonardo::Nested
|
9
|
-
#puts 'rails:leosca'
|
10
|
-
|
11
|
-
#class_option :under, :type => :string, :default => "", :banner => "brand/category", :desc => "To nest a resource under another(s)"
|
12
|
-
#class_option :leospace, :type => :string, :default => "", :banner => ":admin", :desc => "To nest a resource under namespace(s)"
|
13
|
-
|
14
|
-
remove_hook_for :scaffold_controller
|
15
|
-
hook_for :leosca_controller, :required => true
|
16
|
-
|
17
|
-
#Override
|
18
|
-
#def add_resource_route
|
19
|
-
# return if options[:actions].present?
|
20
|
-
#
|
21
|
-
# route_config = ""
|
22
|
-
# iparent = 0
|
23
|
-
#
|
24
|
-
# if nested?
|
25
|
-
# plural_parent_resources.each do |m|
|
26
|
-
# iparent += 2
|
27
|
-
# indent = eval "/^\s{#{16 - iparent}}/"
|
28
|
-
# route_config << <<-FILE.gsub(indent, '')
|
29
|
-
# resources :#{m} do
|
30
|
-
# get :with_#{file_name.pluralize}
|
31
|
-
# post :select, :on => :collection
|
32
|
-
# post :edit_multiple, :on => :collection
|
33
|
-
# put :update_multiple, :on => :collection
|
34
|
-
# put :create_multiple, :on => :collection
|
35
|
-
# FILE
|
36
|
-
# end
|
37
|
-
# end
|
38
|
-
# route_config << base_namespaces.map{|m| "namespace :#{m} do " }.join(" ") if leospaced?
|
39
|
-
# route_config << regular_class_path.map{|m| "namespace :#{m} do " }.join(" ")
|
40
|
-
# indent = eval "/^\s{#{8 - iparent}}/"
|
41
|
-
# route_config << <<-FILE.gsub(indent, '')
|
42
|
-
#
|
43
|
-
# resources :#{file_name.pluralize} do
|
44
|
-
# post :select, :on => :collection
|
45
|
-
# post :edit_multiple, :on => :collection
|
46
|
-
# put :update_multiple, :on => :collection
|
47
|
-
# put :create_multiple, :on => :collection
|
48
|
-
# end
|
49
|
-
# FILE
|
50
|
-
# route_config << " end" * (regular_class_path.size + plural_parent_resources.size + base_namespaces.size)
|
51
|
-
# route route_config
|
52
|
-
#end
|
53
|
-
|
54
|
-
end
|
55
|
-
end
|
1
|
+
require 'rails/generators/rails/scaffold/scaffold_generator'
|
2
|
+
require File.join(File.dirname(__FILE__), '../../active_leonardo')
|
3
|
+
|
4
|
+
module Rails
|
5
|
+
module Generators
|
6
|
+
class LeoscaGenerator < ::Rails::Generators::ScaffoldGenerator
|
7
|
+
include ::ActiveLeonardo::Base
|
8
|
+
#include ::Leonardo::Nested
|
9
|
+
#puts 'rails:leosca'
|
10
|
+
|
11
|
+
#class_option :under, :type => :string, :default => "", :banner => "brand/category", :desc => "To nest a resource under another(s)"
|
12
|
+
#class_option :leospace, :type => :string, :default => "", :banner => ":admin", :desc => "To nest a resource under namespace(s)"
|
13
|
+
|
14
|
+
remove_hook_for :scaffold_controller
|
15
|
+
hook_for :leosca_controller, :required => true
|
16
|
+
|
17
|
+
#Override
|
18
|
+
#def add_resource_route
|
19
|
+
# return if options[:actions].present?
|
20
|
+
#
|
21
|
+
# route_config = ""
|
22
|
+
# iparent = 0
|
23
|
+
#
|
24
|
+
# if nested?
|
25
|
+
# plural_parent_resources.each do |m|
|
26
|
+
# iparent += 2
|
27
|
+
# indent = eval "/^\s{#{16 - iparent}}/"
|
28
|
+
# route_config << <<-FILE.gsub(indent, '')
|
29
|
+
# resources :#{m} do
|
30
|
+
# get :with_#{file_name.pluralize}
|
31
|
+
# post :select, :on => :collection
|
32
|
+
# post :edit_multiple, :on => :collection
|
33
|
+
# put :update_multiple, :on => :collection
|
34
|
+
# put :create_multiple, :on => :collection
|
35
|
+
# FILE
|
36
|
+
# end
|
37
|
+
# end
|
38
|
+
# route_config << base_namespaces.map{|m| "namespace :#{m} do " }.join(" ") if leospaced?
|
39
|
+
# route_config << regular_class_path.map{|m| "namespace :#{m} do " }.join(" ")
|
40
|
+
# indent = eval "/^\s{#{8 - iparent}}/"
|
41
|
+
# route_config << <<-FILE.gsub(indent, '')
|
42
|
+
#
|
43
|
+
# resources :#{file_name.pluralize} do
|
44
|
+
# post :select, :on => :collection
|
45
|
+
# post :edit_multiple, :on => :collection
|
46
|
+
# put :update_multiple, :on => :collection
|
47
|
+
# put :create_multiple, :on => :collection
|
48
|
+
# end
|
49
|
+
# FILE
|
50
|
+
# route_config << " end" * (regular_class_path.size + plural_parent_resources.size + base_namespaces.size)
|
51
|
+
# route route_config
|
52
|
+
#end
|
53
|
+
|
54
|
+
end
|
55
|
+
end
|
56
56
|
end
|