effective_developer 0.4.3 → 0.4.4

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: 2ecc781b9a3506569610b1a024046d3a4654a162
4
- data.tar.gz: 76e8f79b2e3f86f8654b487b0ef0a0c7d9c4a2e3
3
+ metadata.gz: 50fcd5872915810b6bef79adf4c828cf21ccb7d3
4
+ data.tar.gz: 66f6ea7b6400d2c04b85d8d28cd395fa8e0eea89
5
5
  SHA512:
6
- metadata.gz: deb4c61a015920fb4bbd1d32e3f173995c6770309c83364c4134c45e2c16791959ee678f29ee6f3588924e86a5936dafc31a19ec944a45aa05662027f699493b
7
- data.tar.gz: 31249bfd2486d576955cb4f4df7a3b696568440b39d63a69df13e72da91930bba2c4c79c62e9252f93f685708b9fbaf22ca798eb81050bee4952b16001deaf7a
6
+ metadata.gz: 247c959af382160219fbbbabe7e97ba4046f571ad87c7dd91abf770aa082e5bb7c73612b9e50c7e6ce6a40bb8a412530febfe865c7251b715b7281c0117c87b9
7
+ data.tar.gz: e79c311358851e511701b64d3e2c5d1465dc772a9964fd9c0e2516a715b1f2e91800084182e0f181fc50c280934893ad31e35646d269f540b74c1b2b6bb7bd9c
data/README.md CHANGED
@@ -131,6 +131,14 @@ A command line script to delete any git branch that has already been merged into
131
131
  > gitsweep
132
132
  ```
133
133
 
134
+ ## killpuma
135
+
136
+ # kill -9 the first running puma process. Bails out of SystemStackError (stack level too deep).
137
+
138
+ ```console
139
+ > killpuma
140
+ ```
141
+
134
142
  # Rake scripts
135
143
 
136
144
  ## csv:export
@@ -29,6 +29,14 @@ module Effective
29
29
  end
30
30
  end
31
31
 
32
+ # Returns true if the insert happened, nil if no insert
33
+ def insert_into_first(content, &block)
34
+ index = first(&block)
35
+ return nil unless index
36
+
37
+ insert_raw(content, index, depth_at(index) + 1)
38
+ end
39
+
32
40
  # Returns true if the insert happened, nil if no insert
33
41
  def insert_after_first(content, depth: nil, content_depth: nil, &block)
34
42
  index = first(&block)
@@ -1,3 +1,3 @@
1
1
  module EffectiveDeveloper
2
- VERSION = '0.4.3'.freeze
2
+ VERSION = '0.4.4'.freeze
3
3
  end
@@ -25,29 +25,10 @@ module Effective
25
25
  end
26
26
 
27
27
  Effective::CodeWriter.new('app/models/ability.rb') do |w|
28
- if resource.namespaces.blank?
29
- if w.find { |line, depth| depth == 2 && line == ability }
30
- say_status :identical, ability, :blue
31
- else
32
- w.insert_after_last(ability) { |line, depth| depth == 2 && line.start_with?('can ') } ||
33
- w.insert_before_last(ability) { |line, depth| depth == 2 && line.start_with?('if') } ||
34
- w.insert_before_last(ability) { |line, depth| depth == 2 && line == 'end' }
35
-
36
- say_status :ability, ability
37
- end
38
- end
39
-
40
- resource.namespaces.each do |namespace|
41
- w.within("if user.is?(:#{namespace})") do
42
- if w.find { |line, depth| depth == 1 && line == ability }
43
- say_status :identical, ability, :blue
44
- else
45
- w.insert_after_last(ability) { |line, depth| depth == 1 && line.start_with?('can ') } ||
46
- w.insert_before_last(ability) { |line, depth| depth == 1 && line == 'end' }
47
-
48
- say_status "#{namespace}_ability", ability
49
- end
50
- end
28
+ if w.find { |line, depth| depth == 2 && line == ability }
29
+ say_status :identical, ability, :blue
30
+ else
31
+ w.insert_into_first(ability) { |line, depth| line.start_with?('def initialize') }
51
32
  end
52
33
  end
53
34
  end
@@ -73,7 +73,17 @@ module Effective
73
73
 
74
74
  b.local_variable_set(:attribute, name)
75
75
 
76
- if name.include?('price')
76
+ if datatype == 'string' && (resource.klass || NilClass).const_defined?(name.pluralize.upcase)
77
+ attribute_constant = "#{resource.klass.name}::#{name.pluralize.upcase}"
78
+ b.local_variable_set(:attribute_constant, attribute_constant)
79
+
80
+ 'select_constant'
81
+ elsif datatype == :string && (resource.klass || NilClass).const_defined?(name.singularize.upcase)
82
+ attribute_constant = "#{resource.klass.name}::#{name.singularize.upcase}"
83
+ b.local_variable_set(:attribute_constant, attribute_constant)
84
+
85
+ 'select_constant'
86
+ elsif name.include?('price')
77
87
  'price'
78
88
  elsif name.include?('_url')
79
89
  'url'
@@ -23,10 +23,10 @@ module Effective
23
23
 
24
24
  begin
25
25
  Effective::CodeWriter.new('app/views/layouts/_navbar.html.haml') do |w|
26
- if w.find { |line, _| line == menu_content.last.strip }
26
+ if w.find { |line, _| line == menu_content.second.strip }
27
27
  say_status :identical, menu_path, :blue
28
28
  else
29
- if (w.insert_after_first(menu_content) { |line, _| line.start_with?('= nav_link_to') })
29
+ if (w.insert_into_first(menu_content) { |line, _| line.include?('.navbar-nav') })
30
30
  say_status :menu, menu_path, :green
31
31
  else
32
32
  say_status(:skipped, :menu, :yellow)
@@ -45,17 +45,14 @@ module Effective
45
45
 
46
46
  begin
47
47
  Effective::CodeWriter.new('app/views/layouts/_navbar_admin.html.haml') do |w|
48
- if w.find { |line, _| line == admin_menu_content.last.strip }
48
+ if w.find { |line, _| line == menu_content.second.strip }
49
49
  say_status :identical, menu_path, :blue
50
50
  else
51
- index = w.last { |line, _| line.start_with?('- if can?') }
52
-
53
- if index.blank?
54
- say_status(:skipped, :menu, :yellow) and return
51
+ if (w.insert_into_first(menu_content) { |line, _| line.include?('.navbar-nav') })
52
+ say_status :menu, menu_path, :green
53
+ else
54
+ say_status(:skipped, :menu, :yellow)
55
55
  end
56
-
57
- w.insert_raw(admin_menu_content, index+1, w.depth_at(index))
58
- say_status(:menu, menu_path, :green)
59
56
  end
60
57
  end
61
58
  rescue Errno::ENOENT
@@ -67,14 +64,10 @@ module Effective
67
64
  private
68
65
 
69
66
  def menu_content
70
- ["= nav_link_to '#{resource.plural_name.titleize}', #{menu_path}"]
71
- end
72
-
73
- def admin_menu_content
74
67
  [
75
- "\n",
76
- "- if can? :manage, #{resource.class_name}",
77
- " = nav_link_to '#{resource.plural_name.titleize}', #{menu_path}"
68
+ "- if can? :index, #{resource.class_name}",
69
+ " = nav_link_to '#{resource.plural_name.titleize}', #{menu_path}",
70
+ "\n"
78
71
  ]
79
72
  end
80
73
 
@@ -17,7 +17,7 @@ module Effective
17
17
  class_option :attributes, type: :array, default: [], desc: 'Included form attributes, otherwise read from model'
18
18
 
19
19
  def assign_attributes
20
- @attributes = invoked_attributes.presence || resource_attributes
20
+ @attributes = (invoked_attributes.presence || resource_attributes).except(:archived)
21
21
  self.class.send(:attr_reader, :attributes)
22
22
  end
23
23
 
@@ -22,9 +22,13 @@ class <%= resource.namespaced_class_name.pluralize %>Datatable < Effective::Data
22
22
  <% end -%>
23
23
 
24
24
  <% end -%>
25
- <% attributes.except(:created_at, :updated_at, :id).each do |name, _| -%>
25
+ <% attributes.except(:created_at, :updated_at, :id, :archived).each do |name, _| -%>
26
26
  col :<%= name %>
27
27
  <% end -%>
28
+ <% if attributes.key?(:archived) -%>
29
+
30
+ col :archived, search: { value: false }
31
+ <% end -%>
28
32
 
29
33
  actions_col
30
34
  end
@@ -1 +1 @@
1
- = f.select :<%= reference.foreign_key.presence || (reference.name.to_s + '_id') %>, <%= reference.name.to_s.classify %>.sorted.all
1
+ = f.select :<%= reference.foreign_key.presence || (reference.name.to_s + '_id') %>, <%= (reference.options[:class_name] || reference.name).to_s.classify %>.sorted.all
@@ -0,0 +1,2 @@
1
+ = f.select :<%= attribute %>, <%= attribute_constant %>
2
+
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.4.3
4
+ version: 0.4.4
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: 2018-10-31 00:00:00.000000000 Z
11
+ date: 2019-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -84,6 +84,7 @@ files:
84
84
  - lib/scaffolds/forms/fields/_field_phone.html.haml
85
85
  - lib/scaffolds/forms/fields/_field_price.html.haml
86
86
  - lib/scaffolds/forms/fields/_field_select.html.haml
87
+ - lib/scaffolds/forms/fields/_field_select_constant.html.haml
87
88
  - lib/scaffolds/forms/fields/_field_string.html.haml
88
89
  - lib/scaffolds/forms/fields/_field_text.html.haml
89
90
  - lib/scaffolds/forms/fields/_nested_resource_fields.html.haml