effective_developer 0.2.10 → 0.2.11
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.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/app/models/effective/csv_importer.rb +13 -1
- data/lib/effective_developer/version.rb +1 -1
- data/lib/generators/effective/menu_generator.rb +5 -5
- data/lib/generators/effective/scaffold_controller_generator.rb +3 -3
- data/lib/generators/effective/scaffold_generator.rb +3 -3
- data/lib/generators/effective/views_generator.rb +5 -1
- data/lib/scaffolds/controllers/controller.rb +2 -2
- data/lib/scaffolds/forms/default/_form.html.haml +3 -3
- data/lib/scaffolds/views/index.html.haml +1 -1
- data/lib/tasks/effective_csv_importer.rake +20 -18
- 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: 869a0360b0421b9efd42f297cb23a6869b8eaa76
|
4
|
+
data.tar.gz: 98d76ce74f926a3600702680a558c0f9204a2559
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18ae8153ee5d8abfed4df8d8b39cc61b9c2e57d57a6943b7e7d72839564164505da644c07ecc6f8b386005dfd37cfff46cfe11c0e9916e2eac31bac380a09779
|
7
|
+
data.tar.gz: e1404d7301a08146a85fdefc08c1238b9794156ee40749ed0bcd9f661632f5d8cb0e12ca780cba848811e3d17b82a6eeb071cd5a277e84648fbef67f71e7c55a
|
data/README.md
CHANGED
@@ -162,13 +162,13 @@ rake csv:import:foos
|
|
162
162
|
Scaffolds an `Effective::CSVImporter` file for each .csv file in `/lib/csv_importers/data/*.csv`
|
163
163
|
|
164
164
|
```ruby
|
165
|
-
rake csv:
|
165
|
+
rake csv:scaffold
|
166
166
|
```
|
167
167
|
|
168
168
|
or
|
169
169
|
|
170
170
|
```ruby
|
171
|
-
rake csv:
|
171
|
+
rake csv:scaffold[users]
|
172
172
|
```
|
173
173
|
|
174
174
|
## rename_class
|
@@ -148,7 +148,19 @@ module Effective
|
|
148
148
|
@current_row = row
|
149
149
|
|
150
150
|
begin
|
151
|
-
|
151
|
+
exception = false
|
152
|
+
|
153
|
+
ActiveRecord::Base.transaction do
|
154
|
+
begin
|
155
|
+
yield
|
156
|
+
rescue => e
|
157
|
+
exception = e
|
158
|
+
raise ActiveRecord::Rollback
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
raise exception if exception
|
163
|
+
|
152
164
|
print colorize('.', :green)
|
153
165
|
rescue => e
|
154
166
|
error(e.message)
|
@@ -20,7 +20,7 @@ module Effective
|
|
20
20
|
begin
|
21
21
|
Effective::CodeWriter.new((['app/views'] + resource.namespaces + ['_navbar.html.haml']).join('/')) do |w|
|
22
22
|
if w.find { |line, _| line == menu_content.last.strip }
|
23
|
-
say_status :identical, resource.
|
23
|
+
say_status :identical, resource.action_path(:index), :blue
|
24
24
|
else
|
25
25
|
index = w.last { |line, _| line.start_with?('- if can?') }
|
26
26
|
|
@@ -29,7 +29,7 @@ module Effective
|
|
29
29
|
end
|
30
30
|
|
31
31
|
w.insert_raw(menu_content, index+1, w.depth_at(index))
|
32
|
-
say_status :menu, resource.
|
32
|
+
say_status :menu, resource.action_path(:index), :green
|
33
33
|
end
|
34
34
|
end
|
35
35
|
rescue Errno::ENOENT
|
@@ -42,7 +42,7 @@ module Effective
|
|
42
42
|
begin
|
43
43
|
Effective::CodeWriter.new('lib/tasks/generate/effective_menus.rake') do |w|
|
44
44
|
if w.find { |line, _| line == effective_menus_content }
|
45
|
-
say_status :identical, resource.
|
45
|
+
say_status :identical, resource.action_path(:index), :blue
|
46
46
|
else
|
47
47
|
index = w.first { |line, _| line.start_with?('item') }
|
48
48
|
|
@@ -65,12 +65,12 @@ module Effective
|
|
65
65
|
[
|
66
66
|
"\n",
|
67
67
|
"- if can? :manage, #{resource.class_name}",
|
68
|
-
" %li= link_to '#{resource.plural_name.titleize}', #{resource.
|
68
|
+
" %li= link_to '#{resource.plural_name.titleize}', #{resource.action_path(:index)}"
|
69
69
|
]
|
70
70
|
end
|
71
71
|
|
72
72
|
def effective_menus_content
|
73
|
-
"item '#{resource.plural_name.titleize}', :#{resource.
|
73
|
+
"item '#{resource.plural_name.titleize}', :#{resource.action_path(:index)}"
|
74
74
|
end
|
75
75
|
|
76
76
|
end
|
@@ -30,9 +30,9 @@ module Effective
|
|
30
30
|
Rails::Generators.invoke('effective:ability', [name] + invoked_actions)
|
31
31
|
end
|
32
32
|
|
33
|
-
def invoke_menu
|
34
|
-
|
35
|
-
end
|
33
|
+
# def invoke_menu
|
34
|
+
# Rails::Generators.invoke('effective:menu', [name])
|
35
|
+
# end
|
36
36
|
|
37
37
|
def invoke_datatable
|
38
38
|
unless invoked_actions.include?('index')
|
@@ -41,9 +41,9 @@ module Effective
|
|
41
41
|
Rails::Generators.invoke('effective:ability', [name] + invoked_actions)
|
42
42
|
end
|
43
43
|
|
44
|
-
def invoke_menu
|
45
|
-
|
46
|
-
end
|
44
|
+
# def invoke_menu
|
45
|
+
# Rails::Generators.invoke('effective:menu', [name])
|
46
|
+
# end
|
47
47
|
|
48
48
|
def invoke_datatable
|
49
49
|
unless invoked_actions.include?('index')
|
@@ -134,9 +134,9 @@ class <%= resource.namespaced_class_name.pluralize %>Controller < <%= [resource.
|
|
134
134
|
when 'Save'
|
135
135
|
<%= resource.edit_path_helper %>
|
136
136
|
when 'Save and Continue'
|
137
|
-
<%= resource.
|
137
|
+
<%= resource.index_path_helper %>
|
138
138
|
when 'Save and Add New'
|
139
|
-
<%= resource.
|
139
|
+
<%= resource.new_path_helper %>
|
140
140
|
else
|
141
141
|
raise 'Unexpected redirect path'
|
142
142
|
end
|
@@ -6,11 +6,11 @@
|
|
6
6
|
<%= render_field(attribute, depth: 1) %>
|
7
7
|
<% end -%>
|
8
8
|
|
9
|
-
|
9
|
+
<% if defined?(EffectiveResources) -%>
|
10
10
|
= simple_form_submit(f)
|
11
|
-
|
11
|
+
<% else -%>
|
12
12
|
.form-actions
|
13
13
|
= f.button :submit, 'Save', data: { disable_with: 'Saving...' }
|
14
14
|
= f.button :submit, 'Save and Continue', data: { disable_with: 'Saving...' }
|
15
15
|
= f.button :submit, 'Save and Add New', data: { disable_with: 'Saving...' }
|
16
|
-
|
16
|
+
<% end -%>
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
<% if actions.include?('new') -%>
|
4
4
|
- if can?(:new, <%= resource.class_name %>)
|
5
|
-
%p.text-right= link_to 'New <%= resource.human_name %>', <%= resource.
|
5
|
+
%p.text-right= link_to 'New <%= resource.human_name %>', <%= resource.action_path(:new) %>, class: 'btn btn-primary'
|
6
6
|
|
7
7
|
<% end -%>
|
8
8
|
<% if defined?(EffectiveDatatables) -%>
|
@@ -10,8 +10,8 @@
|
|
10
10
|
|
11
11
|
# rake csv:import:posts (one task created per model)
|
12
12
|
# rake csv:import:all
|
13
|
-
# rake csv:
|
14
|
-
# rake csv:
|
13
|
+
# rake csv:scaffold
|
14
|
+
# rake csv:scaffold[users]
|
15
15
|
# rake csv:export
|
16
16
|
|
17
17
|
namespace :csv do
|
@@ -47,30 +47,32 @@ namespace :csv do
|
|
47
47
|
Rake::Task["csv:import:#{importer}"].invoke
|
48
48
|
end
|
49
49
|
end
|
50
|
+
end
|
50
51
|
|
51
|
-
|
52
|
-
|
53
|
-
|
52
|
+
# rake csv:scaffold
|
53
|
+
# rake csv:scaffold[users]
|
54
|
+
desc 'Scaffold an Effective::CSVImporter for each /lib/csv_importers/data/*.csv file, defaults to all'
|
54
55
|
|
55
|
-
|
56
|
-
|
56
|
+
task :scaffold, [:file_name] => :environment do |t, args|
|
57
|
+
args.with_defaults(file_name: 'all')
|
57
58
|
|
58
|
-
|
59
|
+
require 'csv'
|
59
60
|
|
60
|
-
|
61
|
-
|
61
|
+
generator = ERB.new(File.read(File.dirname(__FILE__) + '/../scaffolds/importers/csv_importer.rb'))
|
62
|
+
letters = ('A'..'AT').to_a
|
62
63
|
|
63
|
-
|
64
|
-
|
64
|
+
Dir['lib/csv_importers/data/*.csv'].each do |file|
|
65
|
+
csv_file = file.split('/').last.gsub('.csv', '')
|
65
66
|
|
66
|
-
|
67
|
+
next if (Array(args.file_name) != ['all'] && Array(args.file_name).include?(csv_file) == false)
|
68
|
+
next if args.file_name == 'all' && File.exists?("#{Rails.root}/lib/csv_importers/#{csv_file}_importer.rb")
|
67
69
|
|
68
|
-
|
69
|
-
|
70
|
+
klass = csv_file.classify.pluralize
|
71
|
+
columns = CSV.open(file, 'r') { |csv| csv.first }
|
70
72
|
|
71
|
-
|
72
|
-
|
73
|
-
|
73
|
+
File.open("#{Rails.root}/lib/csv_importers/#{csv_file}_importer.rb", 'w') do |file|
|
74
|
+
file.write generator.result(binding)
|
75
|
+
puts "created lib/csv_importers/#{csv_file}_importer.rb"
|
74
76
|
end
|
75
77
|
end
|
76
78
|
end
|
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.11
|
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-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|