effective_developer 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/effective_developer/version.rb +1 -1
- data/lib/generators/effective/ability_generator.rb +1 -2
- data/lib/generators/effective/controller_generator.rb +9 -0
- data/lib/generators/effective/datatable_generator.rb +4 -0
- data/lib/generators/effective/form_generator.rb +3 -3
- data/lib/scaffolds/controllers/controller.rb +12 -11
- data/lib/scaffolds/forms/tabpanel/_form.html.haml +2 -2
- data/lib/scaffolds/views/index.html.haml +4 -0
- data/lib/tasks/validate.rake +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f41039ceac09c55fe7ae821452bc2d570bb2279c
|
4
|
+
data.tar.gz: 4078bf19bfc90c29a6e67253ed1cbb3d54cef519
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e776f703a4753b14d2b507be9c1beb72e7024879241fbfd2016dd0879efce73355f18a779a7fd8b9b782d3eb9ab675f8bcd243eb9e4ef6d6bc71b0c1077e3bc5
|
7
|
+
data.tar.gz: 46fcc829aa004135e7412f919e385335ae5e33a6102551674d3a7034a3ec32fd034ae4944b188e6f191cdd6ec6b6dc1f55ce701f38794f8d1d8de153b4f8e8ca
|
@@ -21,8 +21,7 @@ module Effective
|
|
21
21
|
|
22
22
|
def create_ability
|
23
23
|
unless File.exists?('app/models/ability.rb')
|
24
|
-
say_status
|
25
|
-
return
|
24
|
+
say_status(:skipped, :ability, :yellow) and return
|
26
25
|
end
|
27
26
|
|
28
27
|
Effective::CodeWriter.new('app/models/ability.rb') do |w|
|
@@ -30,6 +30,15 @@ module Effective
|
|
30
30
|
say_status :invoke, :controller, :white
|
31
31
|
end
|
32
32
|
|
33
|
+
# Find if effective_resources is in the app's Gemfile
|
34
|
+
def enable_effective_resources
|
35
|
+
self.class.send(:attr_reader, :use_effective_resources)
|
36
|
+
|
37
|
+
Effective::CodeWriter.new('Gemfile') do |w|
|
38
|
+
@use_effective_resources = w.find { |line| line.include?('effective_resources') }.present?
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
33
42
|
def create_controller
|
34
43
|
template 'controllers/controller.rb', resource.controller_file
|
35
44
|
end
|
@@ -40,7 +40,7 @@ module Effective
|
|
40
40
|
|
41
41
|
class_eval { attr_accessor :nested_resource }
|
42
42
|
|
43
|
-
resource.nested_resources.each do |
|
43
|
+
resource.nested_resources.each do |nested_resource|
|
44
44
|
@nested_resource = nested_resource
|
45
45
|
template 'forms/tabpanel/_tab_nested_resource.html.haml', resource.view_file("form_#{nested_resource.plural_name}", partial: true)
|
46
46
|
template 'forms/fields/_nested_resource_fields.html.haml', File.join('app/views', resource.namespace.to_s, (resource.namespace.present? ? '' : resource.class_path), nested_resource.name.to_s.underscore.pluralize, '_fields.html.haml')
|
@@ -61,10 +61,10 @@ module Effective
|
|
61
61
|
b = binding
|
62
62
|
|
63
63
|
partial = case attribute
|
64
|
-
when ActiveRecord::Reflection::BelongsToReflection
|
64
|
+
when (ActiveRecord::Reflection::BelongsToReflection rescue false)
|
65
65
|
b.local_variable_set(:reference, attribute)
|
66
66
|
'belongs_to'
|
67
|
-
when ActiveRecord::Reflection::HasManyReflection
|
67
|
+
when (ActiveRecord::Reflection::HasManyReflection rescue false)
|
68
68
|
b.local_variable_set(:nested_resource, attribute)
|
69
69
|
'nested_resource'
|
70
70
|
when Effective::Resource
|
@@ -1,11 +1,11 @@
|
|
1
1
|
class <%= resource.namespaced_class_name.pluralize %>Controller < <%= [resource.namespace.try(:classify).presence, ApplicationController].compact.join('::') %>
|
2
2
|
before_action :authenticate_user! # Devise enforce user is present
|
3
3
|
|
4
|
-
<% if
|
4
|
+
<% if use_effective_resources -%>
|
5
5
|
include Effective::CrudController
|
6
6
|
|
7
7
|
<% end -%>
|
8
|
-
<% if actions.delete('index') && !
|
8
|
+
<% if actions.delete('index') && !use_effective_resources -%>
|
9
9
|
def index
|
10
10
|
@page_title = '<%= resource.plural_name.titleize %>'
|
11
11
|
authorize! :index, <%= resource.class_name %>
|
@@ -14,7 +14,7 @@ class <%= resource.namespaced_class_name.pluralize %>Controller < <%= [resource.
|
|
14
14
|
end
|
15
15
|
|
16
16
|
<% end -%>
|
17
|
-
<% if actions.delete('new') && !
|
17
|
+
<% if actions.delete('new') && !use_effective_resources -%>
|
18
18
|
def new
|
19
19
|
@<%= resource.name %> = <%= resource.class_name %>.new
|
20
20
|
|
@@ -23,7 +23,7 @@ class <%= resource.namespaced_class_name.pluralize %>Controller < <%= [resource.
|
|
23
23
|
end
|
24
24
|
|
25
25
|
<% end -%>
|
26
|
-
<% if actions.delete('create') && !
|
26
|
+
<% if actions.delete('create') && !use_effective_resources -%>
|
27
27
|
def create
|
28
28
|
@<%= resource.name %> = <%= resource.class_name %>.new(<%= resource.name %>_params)
|
29
29
|
|
@@ -40,7 +40,7 @@ class <%= resource.namespaced_class_name.pluralize %>Controller < <%= [resource.
|
|
40
40
|
end
|
41
41
|
|
42
42
|
<% end -%>
|
43
|
-
<% if actions.delete('show') && !
|
43
|
+
<% if actions.delete('show') && !use_effective_resources -%>
|
44
44
|
def show
|
45
45
|
@<%= resource.name %> = <%= resource.class_name %>.find(params[:id])
|
46
46
|
|
@@ -49,7 +49,7 @@ class <%= resource.namespaced_class_name.pluralize %>Controller < <%= [resource.
|
|
49
49
|
end
|
50
50
|
|
51
51
|
<% end -%>
|
52
|
-
<% if actions.delete('edit') && !
|
52
|
+
<% if actions.delete('edit') && !use_effective_resources -%>
|
53
53
|
def edit
|
54
54
|
@<%= resource.name %> = <%= resource.class_name %>.find(params[:id])
|
55
55
|
|
@@ -58,7 +58,7 @@ class <%= resource.namespaced_class_name.pluralize %>Controller < <%= [resource.
|
|
58
58
|
end
|
59
59
|
|
60
60
|
<% end -%>
|
61
|
-
<% if actions.delete('update') && !
|
61
|
+
<% if actions.delete('update') && !use_effective_resources -%>
|
62
62
|
def update
|
63
63
|
@<%= resource.name %> = <%= resource.class_name %>.find(params[:id])
|
64
64
|
|
@@ -75,7 +75,7 @@ class <%= resource.namespaced_class_name.pluralize %>Controller < <%= [resource.
|
|
75
75
|
end
|
76
76
|
|
77
77
|
<% end -%>
|
78
|
-
<% if actions.delete('destroy') && !
|
78
|
+
<% if actions.delete('destroy') && !use_effective_resources -%>
|
79
79
|
def destroy
|
80
80
|
@<%= resource.name %> = <%= resource.class_name %>.find(params[:id])
|
81
81
|
authorize! :destroy, @<%= resource.name %>
|
@@ -121,13 +121,14 @@ class <%= resource.namespaced_class_name.pluralize %>Controller < <%= [resource.
|
|
121
121
|
<% attributes.each_slice(8).with_index do |slice, index| -%>
|
122
122
|
<%= slice.map { |att| permitted_param_for(att.name) }.join(', ') %><%= ',' if (((index+1) * 8) < attributes.length || resource.nested_resources.present?) %>
|
123
123
|
<% end -%>
|
124
|
-
<% resource.nested_resources.each_with_index do |
|
125
|
-
|
124
|
+
<% resource.nested_resources.each_with_index do |nested_resource, index| -%>
|
125
|
+
<% nested = Effective::Resource.new(nested_resource) -%>
|
126
|
+
<%= nested.name %>_attributes: [:id, :_destroy, <%= (nested.belong_tos_attributes + nested.attributes).map { |att| ':' + att.name.to_s }.join(', ') %>]<%= ',' if index < resource.nested_resources.length-1 %>
|
126
127
|
<% end -%>
|
127
128
|
)
|
128
129
|
end
|
129
130
|
|
130
|
-
<% if !
|
131
|
+
<% if !use_effective_resources -%>
|
131
132
|
def redirect_path
|
132
133
|
case params[:commit].to_s
|
133
134
|
when 'Save'
|
@@ -5,7 +5,7 @@
|
|
5
5
|
%a{'data-toggle': 'tab', role: 'tab', 'aria-controls': '<%= resource.name %>-tab', href: '#<%= resource.name %>-tab'}
|
6
6
|
<%= resource.human_name.titleize %>
|
7
7
|
|
8
|
-
<% resource.nested_resources.each do |
|
8
|
+
<% resource.nested_resources.each do |nested_resource| -%>
|
9
9
|
%li{role: 'presentation'}
|
10
10
|
%a{'data-toggle': 'tab', role: 'tab', 'aria-controls': '<%= nested_resource.plural_name %>-tab', href: '#<%= nested_resource.plural_name %>-tab'}
|
11
11
|
<%= nested_resource.plural_name.titleize %>
|
@@ -15,7 +15,7 @@
|
|
15
15
|
#<%= resource.name %>-tab.tab-pane.active{role: 'tabpanel'}
|
16
16
|
= render 'form_<%= resource.name %>', f: f
|
17
17
|
|
18
|
-
<% resource.nested_resources.each do |
|
18
|
+
<% resource.nested_resources.each do |nested_resource| -%>
|
19
19
|
#<%= nested_resource.plural_name %>-tab.tab-pane{role: 'tabpanel'}
|
20
20
|
= render 'form_<%= nested_resource.plural_name %>', f: f
|
21
21
|
<% end -%>
|
@@ -5,8 +5,12 @@
|
|
5
5
|
%p.text-right= link_to 'New <%= resource.human_name %>', <%= resource.new_path %>, class: 'btn btn-primary'
|
6
6
|
|
7
7
|
<% end -%>
|
8
|
+
<% if defined?(EffectiveDatatables) -%>
|
8
9
|
- if @datatable.present?
|
9
10
|
= render_datatable_scopes(@datatable)
|
10
11
|
= render_datatable(@datatable)
|
11
12
|
- else
|
12
13
|
%p There are no <%= resource.plural_name %>.
|
14
|
+
<% else %>
|
15
|
+
= render @<%= resource.plural_name %>
|
16
|
+
<% end %>
|
data/lib/tasks/validate.rake
CHANGED
@@ -6,7 +6,7 @@ task :validate, [:model] => :environment do |t, args|
|
|
6
6
|
args.with_defaults(:model => 'all')
|
7
7
|
|
8
8
|
Rails.application.eager_load!
|
9
|
-
klasses = ActiveRecord::Base.descendants.sort { |a, b| a.name <=> b.name }
|
9
|
+
klasses = ActiveRecord::Base.descendants.reject { |klass| klass.abstract_class? }.sort { |a, b| a.name <=> b.name }
|
10
10
|
|
11
11
|
if args.model != 'all'
|
12
12
|
klasses.delete_if { |klass| klass.name.downcase != args.model.singularize.downcase }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_developer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|