filbert 0.1.0 → 0.1.1

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: ea1dd823ecbaa309c75980c3b0e5f94162a44b99
4
- data.tar.gz: 4061df6ab0cfc924d43d1e8c6eace95e2d91f908
3
+ metadata.gz: 107e006aeae846d31d72fec4789b8339a205c877
4
+ data.tar.gz: 99fb86b7a668faa414a48bc677799b89d3c62f39
5
5
  SHA512:
6
- metadata.gz: f7a885db781a241683b26db3902ec19a9b2ac29f081b52e21dfad88f51069280fd041e537d9448982faf82efbbae4dc0d31013c1ddd5707f0b9b38cefb1364d9
7
- data.tar.gz: 649f56be8b16eb9f5fd595833fe065647dc00b1453367a553b4d5b2a7b0f43fe58dbbfde8df574740c0d3207b582e3d39a294e6fa7aa5402be538409912c3341
6
+ metadata.gz: 07b733ef41d170e670dcd3496847fe986fc7f9f8b4db270c97b97ed861ada1a4c76f3edafa8b4c0e8ea66fce47d9e3b2fb7db79cfc35d22a7d420f8512eb2544
7
+ data.tar.gz: 8780c99d3e3e20788e19121ac85634e340c0a344ad8379b2ae50dddcc42447a4af73c2e08c9a674c57d5ecb7c5ee075e5c96c5362ccaab16119c4d7b5d849939
data/lib/filbert.rb CHANGED
@@ -3,4 +3,4 @@ require 'thor'
3
3
  require 'filbert/task'
4
4
 
5
5
  module Filbert
6
- end
6
+ end
@@ -22,4 +22,4 @@ module Filbert
22
22
  @config ||= YAML.load_file(@config_path)[@env]
23
23
  end
24
24
  end
25
- end
25
+ end
@@ -0,0 +1,35 @@
1
+ require 'rest_client'
2
+ require 'json'
3
+
4
+ class Log
5
+ def initialize(task_name, db_name, datastore)
6
+ @task_name = task_name
7
+ @db_name = db_name
8
+ @datastore = datastore
9
+ end
10
+
11
+ def success
12
+ RestClient.put(datastore, payload.to_json) unless datastore.nil?
13
+ rescue RestClient::Exception
14
+ #just dont explode the back up task
15
+ end
16
+
17
+ private
18
+
19
+ attr_reader :task_name, :db_name, :datastore
20
+
21
+ def rev
22
+ payload = RestClient.get(datastore)
23
+ JSON.parse(payload)['_rev']
24
+ end
25
+
26
+ def payload
27
+ {
28
+ "_rev" => rev,
29
+ "app"=> db_name,
30
+ "timestamp"=> Time.now.to_s,
31
+ "js_timestamp" => Time.now.to_i,
32
+ "task_name" => task_name
33
+ }
34
+ end
35
+ end
data/lib/filbert/task.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require 'filbert/db_config'
2
+ require 'filbert/log'
2
3
  require 'clean_files/cleaner'
3
4
 
4
5
  module Filbert
@@ -6,6 +7,7 @@ module Filbert
6
7
  include Thor::Actions
7
8
 
8
9
  method_option :app, type: :string, required: true
10
+ method_option :log, type: :string, required: false
9
11
  desc "backup", "capture and pull latest production snapshot and migrate local database"
10
12
  def backup
11
13
  say "Looking for the follower DB..."
@@ -18,11 +20,12 @@ module Filbert
18
20
  say "Downloading #{backup_url}"
19
21
  get backup_url, file_path
20
22
  say file_path
23
+ Log.new(:backup, db_name, options[:log]).success if File.exists?(file_path) && options[:log]
21
24
  invoke :cleanup, [], {}
22
25
  end
23
26
 
24
27
  method_option :pretend, type: :boolean, required: false, default: false, aliases: '-p'
25
- desc "cleanup", "remove backup files older than 12 hours"
28
+ desc "cleanup", "Remove old dumps intelligently keeping some of them"
26
29
  def cleanup
27
30
  pretend = options[:pretend]
28
31
  say "Would remove:" if pretend
@@ -111,4 +114,4 @@ module Filbert
111
114
  end
112
115
  end
113
116
  end
114
- end
117
+ end
@@ -1,3 +1,3 @@
1
1
  module Filbert
2
- VERSION = '0.1.0'
3
- end
2
+ VERSION = '0.1.1'
3
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filbert
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tadas Tamosauskas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-07 00:00:00.000000000 Z
11
+ date: 2013-07-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: heroku
@@ -70,6 +70,7 @@ files:
70
70
  - filbert.gemspec
71
71
  - lib/filbert.rb
72
72
  - lib/filbert/db_config.rb
73
+ - lib/filbert/log.rb
73
74
  - lib/filbert/task.rb
74
75
  - lib/filbert/version.rb
75
76
  homepage: https://github.com/alphasights/filbert
@@ -91,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
92
  version: '0'
92
93
  requirements: []
93
94
  rubyforge_project:
94
- rubygems_version: 2.0.0
95
+ rubygems_version: 2.0.2
95
96
  signing_key:
96
97
  specification_version: 4
97
98
  summary: Heroku followers' backups