brillo 1.2.2 → 1.3.0

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
  SHA1:
3
- metadata.gz: dca2fe9bf5bd40152028f30723ec28bf20b277b6
4
- data.tar.gz: b3fd67ef708fdeac5f980889fe40d8f46b618bb0
3
+ metadata.gz: ed51adc58208694cd352025dbd773637176c70f8
4
+ data.tar.gz: 0556c7bad489affaccba0e9341af4863240d4b28
5
5
  SHA512:
6
- metadata.gz: 9288c13a235a8e14569e19a5e9e4949675c164a60c926c7b5da381870893d781f2d7c4c9c477ca7d3d96d1632fae224cc6dc20004955f66bec234683ba663d49
7
- data.tar.gz: a5b3663b86b43f5a74843e8d7018cb1ba293b1913b21e7cd41502e46c6b8316e52c0be0b44379b32a73b225d878d5d6508eb607bf2ce7cee0b4f8d5482a5eebd
6
+ metadata.gz: 45accea61c2b9cd61dee2a4b4d95e82a353ed6e2c3ed146dc9445462f7afc33bb327c003895aa4b4f6300df3a19d7d6e503691f0c092259e48f6a31d3889c985
7
+ data.tar.gz: fa0b361deb1ff96feeede5a1068bcd475182f93ecec877c07e68b81ebdd07e82c7b39519e89f30616804fcec19d0f3ba7fc8fe43d0da76c89a185f8fb709dbd9
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.3.0
4
+ Remove Caring specific scrubber code
5
+
6
+ Fix Postgres load failing because of existing connection
7
+
3
8
  ## 1.2.2
4
9
  Fixed initializer. `Brillo.configure` pre-initialization will now work.
5
10
 
@@ -1,6 +1,8 @@
1
1
  module Brillo
2
2
  module Adapter
3
3
  class Base
4
+ include Logger
5
+
4
6
  attr_reader :config
5
7
  def initialize(db_config)
6
8
  @config = db_config
@@ -26,6 +28,13 @@ module Brillo
26
28
  def load_command
27
29
  raise NotImplementedError
28
30
  end
31
+
32
+ def recreate_db
33
+ ["db:drop", "db:create"].each do |t|
34
+ logger.info "Running\n\trake #{t}"
35
+ Rake::Task[t].invoke
36
+ end
37
+ end
29
38
  end
30
39
  end
31
40
  end
@@ -16,6 +16,21 @@ module Brillo
16
16
  FROM #{table_name};
17
17
  SQL
18
18
  end
19
+
20
+ def recreate_db
21
+ logger.info "Dropping all connections to #{config[:database]}"
22
+ ActiveRecord::Base.connection.execute(
23
+ <<-SQL
24
+ -- Disconnect all others from the database we are about to drop.
25
+ -- Without this, the drop will fail and so the load will abort.
26
+ SELECT pg_terminate_backend(pg_stat_activity.pid)
27
+ FROM pg_stat_activity
28
+ WHERE pg_stat_activity.datname = '#{config[:database]}'
29
+ AND pid <> pg_backend_pid();
30
+ SQL
31
+ )
32
+ super
33
+ end
19
34
  end
20
35
  end
21
36
  end
data/lib/brillo/loader.rb CHANGED
@@ -18,10 +18,7 @@ module Brillo
18
18
  end
19
19
 
20
20
  def recreate_db
21
- ["db:drop", "db:create"].each do |t|
22
- logger.info "Running\n\trake #{t}"
23
- Rake::Task[t].invoke
24
- end
21
+ config.adapter.recreate_db
25
22
  end
26
23
 
27
24
  def import_sql
@@ -10,9 +10,10 @@ module Brillo
10
10
  # Define some procs as scrubbing strategies for Polo
11
11
  SCRUBBERS = {
12
12
  default_time: ->(t) { t.nil? ? Time.now.to_s(:sql) : t },
13
- email: ->(e) { e.match(/@caring.com/) ? e : Digest::MD5.hexdigest(e) + "@example.com".freeze },
13
+ email: ->(e) { Digest::MD5.hexdigest(e) + "@example.com".freeze },
14
14
  jumble: ->(j) { j.downcase.chars.shuffle!(random: JUMBLE_PRNG.clone).join },
15
- phone: ->(n) { n = n.split(' ').first; n && n.length > 9 ? n[0..-5] + n[-1] + n[-2] + n[-3] + n[-4] : n}, # strips extensions
15
+ # strips extensions
16
+ phone: ->(n) { n = n.split(' ').first; n && n.length > 9 ? n[0..-5] + n[-1] + n[-2] + n[-3] + n[-4] : n},
16
17
  name: ->(n) { n.downcase.split(' ').map do |word|
17
18
  word.chars.shuffle!(random: JUMBLE_PRNG.clone).join
18
19
  end.each(&:capitalize!).join(' ')
@@ -1,3 +1,3 @@
1
1
  module Brillo
2
- VERSION = "1.2.2"
2
+ VERSION = "1.3.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brillo
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Bessey
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-17 00:00:00.000000000 Z
11
+ date: 2017-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake