effective_developer 0.6.8 → 0.6.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
  SHA256:
3
- metadata.gz: f51117606ee26c0266dfac742502712dc318a8b09148d722f928b3efd8dc404e
4
- data.tar.gz: 4fd2b3a0fd954b1c0f0d9716e6ee33c911365a3f71aa0141c7e60b5294c8a7bc
3
+ metadata.gz: 7c82e5a358ef279b2ccccaaf54c097ca549449b4d7c4c076eea41f88f5646f3e
4
+ data.tar.gz: c66fce38e2b60d3796964d51fd718911736c2be3f4f0e0413235b84095e25dd5
5
5
  SHA512:
6
- metadata.gz: f5c5588277544f359c0e8481f9f273dc90f34f3831c8e2b3a8e3394a93657a0c863b1d699db00aa707fd7c716e29c47e9904319ac4405b1f82bac8ca89a4c759
7
- data.tar.gz: 6f55724df58ff196884dcd26ff7e2e274b800eae283bacf1b9ef5759f338edc8dfca73d0bc7b1fbf5ba90e6c3e1f9bbfabd434bc88bedb8dbcbe5a6f040a1975
6
+ metadata.gz: d9fc0933cede1643a01fa8000c46d5beb1d8184e5eb74750adf6120cb4747789a65df62079f96b1a2946a78c177739a05880bfd925366e082b3493b2a2c6f1ec
7
+ data.tar.gz: f74388c2dd737bf879ff0a3b147c577b20eac0407a8d4b176942716a93cb75292c9ec2376211d176256e9aae0f50484d40adb4fac153f613283f24ed1b84991c
data/README.md CHANGED
@@ -238,6 +238,12 @@ rake pg:pull
238
238
  rake pg:pull[staging]
239
239
  ```
240
240
 
241
+ By default, any data in the `logs` table will be excluded. To include the logs data:
242
+
243
+ ```ruby
244
+ rake pg:pull logs=true
245
+ ```
246
+
241
247
  ## pg:load
242
248
 
243
249
  Drops and re-creates the local database then initializes database with the contents of latest.dump
@@ -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.11'.freeze
3
3
  end
@@ -8,18 +8,20 @@ namespace :pg do
8
8
  # bundle exec rake pg:pull
9
9
  # bundle exec rake pg:pull[staging]
10
10
  # bundle exec rake pg:pull[158.204.33.124]
11
+ # bundle exec rake pg:pull logs=true
11
12
  # bundle exec rake pg:pull filename=latest.dump database=example
13
+ # bundle exec rake pg:pull filename=latest.dump database=example logs=true
12
14
  # DATABASE=example bundle exec rake pg:load
13
15
  desc 'Creates a new backup on remote server and downloads it to latest.dump'
14
16
  task :pull, [:remote] => :environment do |t, args|
15
17
  defaults = { database: nil, filename: (ENV['DATABASE'] || 'latest') + '.dump' }
16
- env_keys = { database: ENV['DATABASE'], filename: ENV['FILENAME'] }
18
+ env_keys = { database: ENV['DATABASE'], filename: ENV['FILENAME'], logs: ENV['LOGS'] }
17
19
  keywords = ARGV.map { |a| a.split('=') if a.include?('=') }.compact.inject({}) { |h, (k, v)| h[k.to_sym] = v; h }
18
20
  args.with_defaults(defaults.compact.merge(env_keys.compact).merge(keywords))
19
21
 
20
22
  # Validate Config
21
- config = ActiveRecord::Base.configurations[Rails.env]
22
23
  configs = ActiveRecord::Base.configurations.configs_for(env_name: Rails.env)
24
+ config = configs.first
23
25
 
24
26
  if configs.length > 1 && args.database.blank?
25
27
  puts "Multiple database configs exist for #{Rails.env} environment."
@@ -62,7 +64,7 @@ namespace :pg do
62
64
  # SSH into hatchbox and call rake pg:save there to create latest.dump
63
65
  unless(result = `ssh -T #{args.user}@#{args.remote} << EOF
64
66
  cd ~/#{args.app}/current/
65
- bundle exec rake pg:save database=#{args.database} filename=#{args.filename}
67
+ bundle exec rake pg:save database=#{args.database} filename=#{args.filename} logs=#{args.logs}
66
68
  `).include?('Saving database completed') # The output of pg:save down below
67
69
  puts("Error calling ssh #{args.user}@#{args.remote} and running rake pg:save on hatchbox from ~/#{args.app}/current/")
68
70
  abort(result)
@@ -102,8 +104,8 @@ namespace :pg do
102
104
  end
103
105
 
104
106
  # Validate Config
105
- config = ActiveRecord::Base.configurations[Rails.env]
106
107
  configs = ActiveRecord::Base.configurations.configs_for(env_name: Rails.env)
108
+ config = configs.first
107
109
 
108
110
  if configs.length > 1 && args.database.blank?
109
111
  puts "Multiple database configs exist for #{Rails.env} environment."
@@ -140,7 +142,7 @@ namespace :pg do
140
142
  desc 'Saves the development database to a postgresql .dump file (latest.dump by default)'
141
143
  task :save, [:filename] => :environment do |t, args|
142
144
  defaults = { database: nil, filename: (ENV['DATABASE'] || 'latest') + '.dump' }
143
- env_keys = { database: ENV['DATABASE'], filename: ENV['FILENAME'] }
145
+ env_keys = { database: ENV['DATABASE'], filename: ENV['FILENAME'], logs: ENV['LOGS'] }
144
146
  keywords = ARGV.map { |a| a.split('=') if a.include?('=') }.compact.inject({}) { |h, (k, v)| h[k.to_sym] = v; h }
145
147
  args.with_defaults(defaults.compact.merge(env_keys.compact).merge(keywords))
146
148
 
@@ -151,8 +153,8 @@ namespace :pg do
151
153
  { username: uri.user, password: uri.password, host: uri.host, port: (uri.port || 5432), database: uri.path.sub('/', '') }
152
154
  else
153
155
  # Validate Config
154
- config = ActiveRecord::Base.configurations[Rails.env]
155
156
  configs = ActiveRecord::Base.configurations.configs_for(env_name: Rails.env)
157
+ config = configs.first
156
158
 
157
159
  if configs.length > 1 && args.database.blank?
158
160
  puts "Multiple database configs exist for #{Rails.env} environment."
@@ -179,7 +181,9 @@ namespace :pg do
179
181
 
180
182
  puts "=== Saving local '#{db[:database]}' database to #{args.filename}"
181
183
 
182
- if system("export PGPASSWORD=#{db[:password]}; pg_dump -Fc --no-acl --no-owner -h #{db[:host]} -p #{db[:port]} -U #{db[:username]} #{db[:database]} > #{args.filename}")
184
+ exclude_table_data = "--exclude-table-data=logs" unless (args.logs == 'true')
185
+
186
+ if system("export PGPASSWORD=#{db[:password]}; pg_dump -Fc --no-acl --no-owner #{exclude_table_data} -h #{db[:host]} -p #{db[:port]} -U #{db[:username]} #{db[:database]} > #{args.filename}")
183
187
  puts "Saving database completed"
184
188
  else
185
189
  abort "Error saving database"
@@ -189,11 +193,10 @@ namespace :pg do
189
193
  desc 'Clones the production (--remote heroku by default) database to staging (--remote staging by default)'
190
194
  task :clone, [:source_remote, :target_remote] => :environment do |t, args|
191
195
  args.with_defaults(:source_remote => 'heroku', :target_remote => 'staging')
192
- db = ActiveRecord::Base.configurations[Rails.env]
193
196
 
194
197
  puts "=== Cloning remote '#{args.source_remote}' to '#{args.target_remote}'"
195
198
 
196
- Bundler.with_clean_env do
199
+ Bundler.with_unbundled_env do
197
200
  unless system("heroku pg:backups:capture --remote #{args.source_remote}")
198
201
  abort "Error capturing heroku backup"
199
202
  end
@@ -240,7 +243,7 @@ namespace :pg do
240
243
  puts "=== Cloning local table '#{args.table}' to remote #{args.remote} database"
241
244
 
242
245
  # Dump my local database table
243
- db = ActiveRecord::Base.configurations[Rails.env]
246
+ db = ActiveRecord::Base.configurations.configs_for(env_name: Rails.env).first
244
247
  tmpfile = "tmp/#{args.table}.sql"
245
248
 
246
249
  unless system("pg_dump --data-only --table=#{args.table} -h localhost -U '#{db['username']}' '#{db['database']}' > #{tmpfile}")
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.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: 2021-09-21 00:00:00.000000000 Z
11
+ date: 2022-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails