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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8b538205831d72c8a994667c146f67a6d1094c84
4
- data.tar.gz: 966fcbef2b0eb0af08a79a50ec3153a8f016bb25
3
+ metadata.gz: c7d7adc44cb4ad259ba9627c926170b36c080cea
4
+ data.tar.gz: f51a90e5561978dd29a6836cad108b3507aa16c5
5
5
  SHA512:
6
- metadata.gz: 42129c23eac395857a2e73c4ecfaf66f61bef6086613d2d952bcd09d2d87ccd68d46795cad4c325b621b12979c71dbc759a2bccd02831b4c2f325a9b7b2bbd36
7
- data.tar.gz: a89052ae1ff139eb7de551561fc2b6087b65db802f6bf350b5f6fdb83af7f67deb6ac54eb930b601b037f85e6280dbe7f239f8ce832fd5034713e82b86f03427
6
+ metadata.gz: d1d37ea7d5404919d3728bd5ced392772882dd3f17bbf898b44d49313f55eae38a2a1c7d09a9258cea39c2ce8ef2295fcc3316c7d8ba81a4b8c8e9da35490fb1
7
+ data.tar.gz: bac31d0b6f414665d9c6cbfff6c9d51fb95cdf6b4ca3c4cc2b76b784bc2ebe8161a75809087ca411d59057a3f7edf955000c7e93d81e5ad99779d05d1facd78e
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- ruby-2.1.2
1
+ ruby-2.2.2
@@ -19,7 +19,8 @@ module Crashbreak
19
19
  end
20
20
 
21
21
  def ignored_environments
22
- @ignored_environments ||= ['development', 'test']
22
+ @ignored_environments ||= ['development']
23
+ @ignored_environments + ['test']
23
24
  end
24
25
 
25
26
  def error_serializers
@@ -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
- restorer_for_postgresql
6
+ setup_restorer_for_postgresql
5
7
 
6
8
  config.dumper_options.reverse_merge!(
7
- dump_location: "#{Rails.root}/tmp/db.dump",
8
- dump_command: "pg_dump -Fc #{db_name} > #{Rails.root}/tmp/db.dump"
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
- restorer_for_postgresql
15
+ setup_restorer_for_postgresql
14
16
 
15
17
  config.dumper_options.reverse_merge!(
16
- dump_location: "#{Rails.root}/tmp/db.dump",
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 #{Rails.root}/tmp/db.dump `/app/vendor/heroku-toolbelt/bin/heroku pg:backups public-url --app #{app_name}`"
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
- private
24
+ def mongodb(db_name)
25
+ setup_restorer_for_mongo(db_name)
23
26
 
24
- def config
25
- Crashbreak.configurator
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
- def restorer_for_postgresql
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
@@ -1,3 +1,3 @@
1
1
  module Crashbreak
2
- VERSION = '1.0.12'
2
+ VERSION = '1.0.13'
3
3
  end
@@ -32,15 +32,7 @@ module Crashbreak
32
32
  end
33
33
 
34
34
  def setup_connection_to_restored_database
35
- if Crashbreak.configure.restorer_options[:setup_database_connection].present?
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.12
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-07-15 00:00:00.000000000 Z
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.2.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: