crashbreak 1.0.12 → 1.0.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/lib/crashbreak/config/configurator.rb +2 -1
- data/lib/crashbreak/predefined_settings.rb +31 -10
- data/lib/crashbreak/version.rb +1 -1
- data/lib/restorers/database_restorer.rb +1 -9
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7d7adc44cb4ad259ba9627c926170b36c080cea
|
4
|
+
data.tar.gz: f51a90e5561978dd29a6836cad108b3507aa16c5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d1d37ea7d5404919d3728bd5ced392772882dd3f17bbf898b44d49313f55eae38a2a1c7d09a9258cea39c2ce8ef2295fcc3316c7d8ba81a4b8c8e9da35490fb1
|
7
|
+
data.tar.gz: bac31d0b6f414665d9c6cbfff6c9d51fb95cdf6b4ca3c4cc2b76b784bc2ebe8161a75809087ca411d59057a3f7edf955000c7e93d81e5ad99779d05d1facd78e
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
ruby-2.
|
1
|
+
ruby-2.2.2
|
@@ -1,36 +1,57 @@
|
|
1
1
|
module Crashbreak
|
2
2
|
class PredefinedSettings
|
3
|
+
DEFAULT_DUMP_LOCATION = "#{Rails.root}/tmp/db.dump"
|
4
|
+
|
3
5
|
def postgresql(db_name)
|
4
|
-
|
6
|
+
setup_restorer_for_postgresql
|
5
7
|
|
6
8
|
config.dumper_options.reverse_merge!(
|
7
|
-
dump_location:
|
8
|
-
dump_command: "pg_dump -Fc #{db_name} > #{
|
9
|
+
dump_location: DEFAULT_DUMP_LOCATION,
|
10
|
+
dump_command: "pg_dump -Fc #{db_name} > #{DEFAULT_DUMP_LOCATION}"
|
9
11
|
)
|
10
12
|
end
|
11
13
|
|
12
14
|
def heroku_postgresql(db_name, app_name)
|
13
|
-
|
15
|
+
setup_restorer_for_postgresql
|
14
16
|
|
15
17
|
config.dumper_options.reverse_merge!(
|
16
|
-
dump_location:
|
18
|
+
dump_location: DEFAULT_DUMP_LOCATION,
|
17
19
|
dump_command: "/app/vendor/heroku-toolbelt/bin/heroku pg:backups capture #{db_name} -a #{app_name} &&" +
|
18
|
-
"curl -o #{
|
20
|
+
"curl -o #{DEFAULT_DUMP_LOCATION} `/app/vendor/heroku-toolbelt/bin/heroku pg:backups public-url --app #{app_name}`"
|
19
21
|
)
|
20
22
|
end
|
21
23
|
|
22
|
-
|
24
|
+
def mongodb(db_name)
|
25
|
+
setup_restorer_for_mongo(db_name)
|
23
26
|
|
24
|
-
|
25
|
-
|
27
|
+
config.dumper_options.reverse_merge!(
|
28
|
+
dump_location: DEFAULT_DUMP_LOCATION,
|
29
|
+
dump_command: "mongodump --db #{db_name} --out #{Rails.root}/tmp/db_dump && tar -cvf #{DEFAULT_DUMP_LOCATION} #{Rails.root}/tmp/db_dump"
|
30
|
+
)
|
26
31
|
end
|
27
32
|
|
28
|
-
|
33
|
+
private
|
34
|
+
|
35
|
+
def setup_restorer_for_postgresql
|
29
36
|
config.restorer_options.reverse_merge!(
|
30
37
|
drop_test_database_command: 'dropdb crashbreak-test',
|
31
38
|
create_test_database_command: 'createdb -T template0 crashbreak-test',
|
32
39
|
restore_command: "pg_restore -O #{Rails.root}/tmp/db.dump -d crashbreak-test",
|
40
|
+
setup_database_connection: -> { ActiveRecord::Base.establish_connection(YAML.load(File.read('config/database.yml'))[:crashbreak_test]) }
|
33
41
|
)
|
34
42
|
end
|
43
|
+
|
44
|
+
def setup_restorer_for_mongo(db_name)
|
45
|
+
config.restorer_options.reverse_merge!(
|
46
|
+
drop_test_database_command: 'mongo crashbreak-test --eval "db.dropDatabase()"',
|
47
|
+
create_test_database_command: '',
|
48
|
+
restore_command: "tar -xf #{Rails.root}/tmp/db.dump -C #{Rails.root}/tmp/db_dump && mongorestore --db crashbreak-test #{Rails.root}/tmp/db_dump/#{db_name}",
|
49
|
+
setup_database_connection: -> { Mongoid.load!("#{Rails.root}/config/mongoid.yml", :crashbreak_test) }
|
50
|
+
)
|
51
|
+
end
|
52
|
+
|
53
|
+
def config
|
54
|
+
Crashbreak.configurator
|
55
|
+
end
|
35
56
|
end
|
36
57
|
end
|
data/lib/crashbreak/version.rb
CHANGED
@@ -32,15 +32,7 @@ module Crashbreak
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def setup_connection_to_restored_database
|
35
|
-
|
36
|
-
Crashbreak.configure.restorer_options[:setup_database_connection].call
|
37
|
-
else
|
38
|
-
ActiveRecord::Base.establish_connection(database_config.merge(database: 'crashbreak-test')) if database_config
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def database_config
|
43
|
-
@database_config ||= YAML.load(File.read('config/database.yml')).try(:[], 'test')
|
35
|
+
Crashbreak.configure.restorer_options[:setup_database_connection].call
|
44
36
|
end
|
45
37
|
|
46
38
|
def restore_command
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crashbreak
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michal Janeczek
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -299,7 +299,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
299
299
|
version: '0'
|
300
300
|
requirements: []
|
301
301
|
rubyforge_project:
|
302
|
-
rubygems_version: 2.
|
302
|
+
rubygems_version: 2.4.8
|
303
303
|
signing_key:
|
304
304
|
specification_version: 4
|
305
305
|
summary: Take a break from crashes!
|
@@ -328,3 +328,4 @@ test_files:
|
|
328
328
|
- spec/support/rspec_config.rb
|
329
329
|
- spec/support/test_error.rb
|
330
330
|
- spec/support/test_error_formatter.rb
|
331
|
+
has_rdoc:
|