effective_developer 0.6.8 → 0.6.9

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f51117606ee26c0266dfac742502712dc318a8b09148d722f928b3efd8dc404e
4
- data.tar.gz: 4fd2b3a0fd954b1c0f0d9716e6ee33c911365a3f71aa0141c7e60b5294c8a7bc
3
+ metadata.gz: c86580e62fc1a59098e658e5b98c05391113df75d13ab858cdc49ff045ff0cdd
4
+ data.tar.gz: 2a99640bbb2152e3ac88c4d7f360e1f9075016c218fc4b3054c0e5052b688430
5
5
  SHA512:
6
- metadata.gz: f5c5588277544f359c0e8481f9f273dc90f34f3831c8e2b3a8e3394a93657a0c863b1d699db00aa707fd7c716e29c47e9904319ac4405b1f82bac8ca89a4c759
7
- data.tar.gz: 6f55724df58ff196884dcd26ff7e2e274b800eae283bacf1b9ef5759f338edc8dfca73d0bc7b1fbf5ba90e6c3e1f9bbfabd434bc88bedb8dbcbe5a6f040a1975
6
+ metadata.gz: b0943fad39d092da9bd58075184fa2fafdb78e48d33c48857ad775af9b319986cb1bf273610a2ac7c9ad801dca50033f39f28374074605f627d12c35b63c1a5d
7
+ data.tar.gz: 65bf51e762c888b44fb5e3d2aeddc88e7eb66b5b8b67227d72a347e1da44c9f72cc474ed681d661ac61dbcdcab2c1c7b3551a1e6f965a525a41b06729e1464b7
@@ -38,6 +38,8 @@ module Effective
38
38
  private
39
39
 
40
40
  SIMPLE_FORM_FOR_REGEX = /simple_form_for( |\()(\[:[^,]+, ?[^,]+\])?(([^,]+),)?.+do \|(\w+)\|/
41
+ SIMPLE_FORM_FOR_REGEX2 = /simple_form_for\((\w+).+?\) do \|(\w+)\|/
42
+
41
43
  SIMPLE_FORM_INPUT_ATTRIBUTE = /\.input( |\():(\w+)/
42
44
  SIMPLE_FORM_INPUT_AS_ONE = /(as: :(\w+))/
43
45
  SIMPLE_FORM_INPUT_AS_TWO = /(:as => :(\w+))/
@@ -53,17 +55,38 @@ module Effective
53
55
  # Replace simple_form_for
54
56
  writer.all { |line| line.include?('simple_form_for') }.each do |line|
55
57
  content = writer.lines[line]
58
+
59
+ # Try first time
56
60
  matched = content.match(SIMPLE_FORM_FOR_REGEX)
57
- raise("unable to match simple_form_for from:\n#{content}") unless matched.present?
58
61
 
59
- original = matched[0]
60
- model = matched[2] || matched[4]
61
- letter = matched[5]
62
+ if matched.present?
63
+ original = matched[0]
64
+ model = matched[2] || matched[4]
65
+ letter = matched[5]
62
66
 
63
- raise("unable to determine simple_form_for subject from:\n#{content}") unless original && model && letter
67
+ if original && model && letter
68
+ content.sub!(original, "effective_form_with(model: #{model}) do |#{letter}|")
69
+ writer.replace(line, content)
70
+ next
71
+ end
72
+ end
64
73
 
65
- content.sub!(original, "effective_form_with(model: #{model}) do |#{letter}|")
66
- writer.replace(line, content)
74
+ # Try second time
75
+ matched = content.match(SIMPLE_FORM_FOR_REGEX2)
76
+
77
+ if matched.present?
78
+ original = matched[0]
79
+ model = matched[1]
80
+ letter = matched[2]
81
+
82
+ if original && model && letter
83
+ content.sub!(original, "effective_form_with(model: #{model}) do |#{letter}|")
84
+ writer.replace(line, content)
85
+ next
86
+ end
87
+ end
88
+
89
+ puts("unable to determine simple_form_for subject from:\n#{content}")
67
90
  end
68
91
 
69
92
  # Try to figure out klass again if its missing from filename
@@ -189,7 +212,8 @@ module Effective
189
212
  when 'text' then 'text_area'
190
213
  when 'url' then 'url_field'
191
214
  else
192
- raise("unknown input type #{input_type} (for attribute :#{attribute})")
215
+ puts("unknown input type #{input_type} (for attribute :#{attribute})")
216
+ 'text_field'
193
217
  end
194
218
  end
195
219
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveDeveloper
2
- VERSION = '0.6.8'.freeze
2
+ VERSION = '0.6.9'.freeze
3
3
  end
@@ -18,8 +18,8 @@ namespace :pg do
18
18
  args.with_defaults(defaults.compact.merge(env_keys.compact).merge(keywords))
19
19
 
20
20
  # Validate Config
21
- config = ActiveRecord::Base.configurations[Rails.env]
22
21
  configs = ActiveRecord::Base.configurations.configs_for(env_name: Rails.env)
22
+ config = configs.first
23
23
 
24
24
  if configs.length > 1 && args.database.blank?
25
25
  puts "Multiple database configs exist for #{Rails.env} environment."
@@ -102,8 +102,8 @@ namespace :pg do
102
102
  end
103
103
 
104
104
  # Validate Config
105
- config = ActiveRecord::Base.configurations[Rails.env]
106
105
  configs = ActiveRecord::Base.configurations.configs_for(env_name: Rails.env)
106
+ config = configs.first
107
107
 
108
108
  if configs.length > 1 && args.database.blank?
109
109
  puts "Multiple database configs exist for #{Rails.env} environment."
@@ -151,8 +151,8 @@ namespace :pg do
151
151
  { username: uri.user, password: uri.password, host: uri.host, port: (uri.port || 5432), database: uri.path.sub('/', '') }
152
152
  else
153
153
  # Validate Config
154
- config = ActiveRecord::Base.configurations[Rails.env]
155
154
  configs = ActiveRecord::Base.configurations.configs_for(env_name: Rails.env)
155
+ config = configs.first
156
156
 
157
157
  if configs.length > 1 && args.database.blank?
158
158
  puts "Multiple database configs exist for #{Rails.env} environment."
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.6.8
4
+ version: 0.6.9
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: 2021-09-21 00:00:00.000000000 Z
11
+ date: 2022-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails