crashbreak 0.9.10 → 0.9.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
  SHA1:
3
- metadata.gz: 049fadb7ad06d34a0cee543f5c51cb12f88b91eb
4
- data.tar.gz: b5b854e144727e47300921c6f88a7bd5947cfe31
3
+ metadata.gz: 94c401ee078a3f6f4d71f1309855ea77fc89e6ef
4
+ data.tar.gz: dcf09e8fc27a7934ad862119bfd4b7012f618263
5
5
  SHA512:
6
- metadata.gz: bf6074ee2b2b7db7ff8d29efa35a1329f77109ddfb2e8a9c985a56bef54753b24c081260624d2eed240a3a8f17ce92d242de252ade5047ae5e2c53c3cf98e63d
7
- data.tar.gz: dd5dd8039dac2068fee5e20dd31ec4504668e8f8e99f63ea30f7c50cf52a56ad3cdbf64ea6e136b564d50ea6bb9f8850e336c8f663c785ce27e7cc6f345d048c
6
+ metadata.gz: 1b4156728a4159720d0433e9087d202647390acfe07be068dab05660f4d040bb7eb0ffc82b4220016a4849b6289c98b006821b0d207a5f05889cdbc57b14c2bc
7
+ data.tar.gz: 72abcbadd27dfe83c3bab1dcd3ececf42819ed20f67e2ddb0fa077a42727ba112edb6b0cd4b8dd4b5ae6e6ba29efbe596bf79034dec99acb33552d73971cca81
@@ -4,6 +4,10 @@ module Crashbreak
4
4
  @client ||= Aws::S3::Client.new
5
5
  end
6
6
 
7
+ def aws_resource_bucket
8
+ @aws_resource_bucket ||= Aws::S3::Resource.new.bucket(bucket_name)
9
+ end
10
+
7
11
  def bucket_name
8
12
  Crashbreak.configure.dumper_options[:aws_bucket_name]
9
13
  end
@@ -1,3 +1,3 @@
1
1
  module Crashbreak
2
- VERSION = '0.9.10'
2
+ VERSION = '0.9.11'
3
3
  end
@@ -1,12 +1,18 @@
1
+ require 'digest/md5'
2
+
1
3
  module Crashbreak
2
- class DatabaseDumper
4
+ class DatabaseDumper < BasicFormatter
3
5
  include Crashbreak::AWS
4
6
 
5
7
  def dump
6
- dump_database
7
8
  prepare_aws
8
- aws_file_name = upload_dump
9
- remove_locally_dump
9
+
10
+ if dump_not_exist_yet?
11
+ dump_database
12
+ upload_dump
13
+ remove_locally_dump
14
+ end
15
+
10
16
  { file_name: aws_file_name }
11
17
  end
12
18
 
@@ -17,17 +23,19 @@ module Crashbreak
17
23
  end
18
24
 
19
25
  def upload_dump
20
- generate_aws_file_name.tap do |aws_file_name|
21
- client.put_object(bucket: bucket_name, key: aws_file_name, body: File.read(dump_location))
22
- end
26
+ client.put_object(bucket: bucket_name, key: aws_file_name, body: File.read(dump_location))
23
27
  end
24
28
 
25
29
  def remove_locally_dump
26
30
  File.delete(dump_location)
27
31
  end
28
32
 
29
- def generate_aws_file_name
30
- "Crashbreak - database dump #{DateTime.now.utc}"
33
+ def aws_file_name
34
+ "Crashbreak - database dump #{Digest::MD5.hexdigest(ENV['RACK_ENV'] + exception.class.to_s + exception.backtrace[0])}"
35
+ end
36
+
37
+ def dump_not_exist_yet?
38
+ !aws_resource_bucket.object(aws_file_name).exists?
31
39
  end
32
40
 
33
41
  def dump_location
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: 0.9.10
4
+ version: 0.9.11
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-04-14 00:00:00.000000000 Z
11
+ date: 2015-04-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler