effective_developer 0.2.10 → 0.2.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4c950de342d073c07427aa516389a9271a7c4c44
4
- data.tar.gz: d95f82b1f7219b99bf542576b96f17a9d507118b
3
+ metadata.gz: 869a0360b0421b9efd42f297cb23a6869b8eaa76
4
+ data.tar.gz: 98d76ce74f926a3600702680a558c0f9204a2559
5
5
  SHA512:
6
- metadata.gz: f0e19413a78e4902b85702ad599b69c40c4f47904e587061f9087ab6f96f1ecd95d7c25415760746205cf61cda317491e9885e3d42da4582934f472e21894c01
7
- data.tar.gz: a5cfae5b14be51933f1d03b7c5890a855aadd506d4b8e8e2798c53296d6d19d6bbd4b01e3b0ae9a1a1eb0912b00aab9bdb3eba2403848066f160de74332b464c
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:import:scaffold
165
+ rake csv:scaffold
166
166
  ```
167
167
 
168
168
  or
169
169
 
170
170
  ```ruby
171
- rake csv:import:scaffold[users]
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
- yield
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)
@@ -1,3 +1,3 @@
1
1
  module EffectiveDeveloper
2
- VERSION = '0.2.10'.freeze
2
+ VERSION = '0.2.11'.freeze
3
3
  end
@@ -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.index_path, :blue
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.index_path, :green
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.index_path, :blue
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.index_path}"
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.index_path}"
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
- Rails::Generators.invoke('effective:menu', [name])
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
- Rails::Generators.invoke('effective:menu', [name])
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')
@@ -38,7 +38,11 @@ module Effective
38
38
  private
39
39
 
40
40
  def available_actions
41
- %w(index new show edit)
41
+ if defined?(EffectiveResources) # We don't need any views!
42
+ []
43
+ else
44
+ %w(index new show edit)
45
+ end
42
46
  end
43
47
 
44
48
  end
@@ -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.index_path %>
137
+ <%= resource.index_path_helper %>
138
138
  when 'Save and Add New'
139
- <%= resource.new_path %>
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
- <% if defined?(EffectiveResources) -%>
9
+ <% if defined?(EffectiveResources) -%>
10
10
  = simple_form_submit(f)
11
- <% else -%>
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
- <% end -%>
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.new_path %>, class: 'btn btn-primary'
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:import:scaffold
14
- # rake csv:import:scaffold[users]
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
- # rake csv:scaffold
52
- # rake csv:scaffold[users]
53
- desc 'Scaffold an Effective::CSVImporter for each /lib/csv_importers/data/*.csv file'
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
- task :scaffold, [:file_name] => :environment do |t, args|
56
- args.with_defaults(file_name: 'all')
56
+ task :scaffold, [:file_name] => :environment do |t, args|
57
+ args.with_defaults(file_name: 'all')
57
58
 
58
- require 'csv'
59
+ require 'csv'
59
60
 
60
- generator = ERB.new(File.read(File.dirname(__FILE__) + '/../scaffolds/importers/csv_importer.rb'))
61
- letters = ('A'..'AT').to_a
61
+ generator = ERB.new(File.read(File.dirname(__FILE__) + '/../scaffolds/importers/csv_importer.rb'))
62
+ letters = ('A'..'AT').to_a
62
63
 
63
- Dir['lib/csv_importers/data/*.csv'].each do |file|
64
- csv_file = file.split('/').last.gsub('.csv', '')
64
+ Dir['lib/csv_importers/data/*.csv'].each do |file|
65
+ csv_file = file.split('/').last.gsub('.csv', '')
65
66
 
66
- next if (Array(args.file_name) != ['all'] && Array(args.file_name).include?(csv_file) == false)
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
- klass = csv_file.classify.pluralize
69
- columns = CSV.open(file, 'r') { |csv| csv.first }
70
+ klass = csv_file.classify.pluralize
71
+ columns = CSV.open(file, 'r') { |csv| csv.first }
70
72
 
71
- File.open("#{Rails.root}/lib/csv_importers/#{csv_file}_importer.rb", 'w') do |file|
72
- file.write generator.result(binding)
73
- end
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.10
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-20 00:00:00.000000000 Z
11
+ date: 2017-12-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails