backup 3.0.25 → 3.0.26

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -15,7 +15,7 @@ end
15
15
  # Define gems to be used in the 'test' environment
16
16
  group :test do
17
17
  gem 'rspec'
18
- gem 'mocha'
18
+ gem 'mocha', '0.12.7'
19
19
  gem 'timecop'
20
20
  gem 'fuubar'
21
21
 
data/Guardfile CHANGED
@@ -10,7 +10,6 @@
10
10
  # Be sure to run `bundle install` against every Ruby version, as well as `gem install thor POpen4`
11
11
 
12
12
  guard "rspec",
13
- :version => 2,
14
13
  :rvm => ["1.9.3", "1.9.2", "1.8.7"],
15
14
  :cli => "--color --format Fuubar",
16
15
  :notification => false,
data/README.md CHANGED
@@ -117,6 +117,7 @@ Below you find a list of components that Backup currently supports. If you'd lik
117
117
  - Presently
118
118
  - Prowl
119
119
  - Hipchat
120
+ - Pushover
120
121
 
121
122
  [Notifiers Wiki Page](https://github.com/meskyanichi/backup/wiki/Notifiers)
122
123
 
@@ -130,7 +131,7 @@ Below you find a list of components that Backup currently supports. If you'd lik
130
131
  A sample Backup configuration file
131
132
  ----------------------------------
132
133
 
133
- This is a Backup configuration file. Check it out and read the explanation below.
134
+ This is a Backup configuration file. Check it out and read the explanation below.
134
135
  Backup has a [great wiki](https://github.com/meskyanichi/backup/wiki) which explains each component of Backup in detail.
135
136
 
136
137
  ``` rb
@@ -429,12 +430,16 @@ View the [issue log](https://github.com/meskyanichi/backup/issues) and post them
429
430
  <td><a href="https://github.com/szymonpk" target="_blank">Szymon ( szymonpk )</a></td>
430
431
  <td>Pbzip2 compressor</td>
431
432
  </tr>
433
+ <tr>
434
+ <td><a href="https://github.com/SteveNewson" target="_blank">Steve Newson ( SteveNewson )</a></td>
435
+ <td>Pushover Notifier</td>
436
+ </tr>
432
437
  </table>
433
438
 
434
439
 
435
440
  ### Want to contribute?
436
441
 
437
- - Fork/Clone the **develop** branch
442
+ - Fork the project
438
443
  - Write RSpec tests, and test against:
439
444
  - Ruby 1.9.3
440
445
  - Ruby 1.9.2
data/backup.gemspec CHANGED
@@ -26,7 +26,7 @@ Gem::Specification.new do |gem|
26
26
 
27
27
  ##
28
28
  # Gem dependencies
29
- gem.add_dependency 'thor', ['~> 0.15.4']
29
+ gem.add_dependency 'thor', ['>= 0.15.4', '< 2']
30
30
  gem.add_dependency 'open4', ['~> 1.3.0']
31
31
 
32
32
  end
data/lib/backup.rb CHANGED
@@ -106,6 +106,7 @@ module Backup
106
106
  autoload :Campfire, File.join(NOTIFIER_PATH, 'campfire')
107
107
  autoload :Prowl, File.join(NOTIFIER_PATH, 'prowl')
108
108
  autoload :Hipchat, File.join(NOTIFIER_PATH, 'hipchat')
109
+ autoload :Pushover, File.join(NOTIFIER_PATH, 'pushover')
109
110
  end
110
111
 
111
112
  ##
data/lib/backup/config.rb CHANGED
@@ -116,7 +116,7 @@ module Backup
116
116
  { 'RSync' => ['Push', 'Pull', 'Local'] }
117
117
  ],
118
118
  # Notifiers
119
- ['Mail', 'Twitter', 'Campfire', 'Prowl', 'Hipchat']
119
+ ['Mail', 'Twitter', 'Campfire', 'Prowl', 'Hipchat', 'Pushover']
120
120
  ]
121
121
  )
122
122
  end
@@ -0,0 +1,88 @@
1
+ # encoding: utf-8
2
+ require 'net/https'
3
+
4
+ module Backup
5
+ module Notifier
6
+ class Pushover < Base
7
+
8
+ ##
9
+ # The API User Token
10
+ attr_accessor :user
11
+
12
+ ##
13
+ # The API Application Token
14
+ attr_accessor :token
15
+
16
+ ##
17
+ # The user's device identifier to sent he message directly to that device rather than all of the user's devices
18
+ attr_accessor :device
19
+
20
+ ##
21
+ # The message title
22
+ attr_accessor :title
23
+
24
+ ##
25
+ # The priority of the notification
26
+ attr_accessor :priority
27
+
28
+ def initialize(model, &block)
29
+ super(model)
30
+
31
+ instance_eval(&block) if block_given?
32
+ end
33
+
34
+ private
35
+
36
+ ##
37
+ # Notify the user of the backup operation results.
38
+ # `status` indicates one of the following:
39
+ #
40
+ # `:success`
41
+ # : The backup completed successfully.
42
+ # : Notification will be sent if `on_success` was set to `true`
43
+ #
44
+ # `:warning`
45
+ # : The backup completed successfully, but warnings were logged
46
+ # : Notification will be sent, including a copy of the current
47
+ # : backup log, if `on_warning` was set to `true`
48
+ #
49
+ # `:failure`
50
+ # : The backup operation failed.
51
+ # : Notification will be sent, including the Exception which caused
52
+ # : the failure, the Exception's backtrace, a copy of the current
53
+ # : backup log and other information if `on_failure` was set to `true`
54
+ #
55
+ def notify!(status)
56
+ name = case status
57
+ when :success then 'Success'
58
+ when :failure then 'Failure'
59
+ when :warning then 'Warning'
60
+ end
61
+ message = "[Backup::%s] #{@model.label} (#{@model.trigger})" % name
62
+
63
+ send_message(message)
64
+ end
65
+
66
+ # Push a message via the Pushover API
67
+ def send_message(message)
68
+ url = URI.parse("https://api.pushover.net/1/messages.json")
69
+
70
+ request = Net::HTTP::Post.new(url.path)
71
+ request.set_form_data(parameters.merge ({:message => message}))
72
+ response = Net::HTTP.new(url.host, url.port)
73
+
74
+ response.use_ssl = true
75
+ response.verify_mode = OpenSSL::SSL::VERIFY_PEER
76
+
77
+ response.start {|http| http.request(request) }
78
+ end
79
+
80
+ # List available parameters
81
+ def parameters
82
+ @values = {}
83
+ [:token, :user, :message, :title, :priority, :device].each { |k| @values.merge! k => self.instance_variable_get("@#{k}") }
84
+ @values
85
+ end
86
+ end
87
+ end
88
+ end
@@ -13,7 +13,7 @@ module Backup
13
13
  # Defines the minor version
14
14
  # PATCH:
15
15
  # Defines the patch version
16
- MAJOR, MINOR, PATCH = 3, 0, 25
16
+ MAJOR, MINOR, PATCH = 3, 0, 26
17
17
 
18
18
  ##
19
19
  # Returns the major version ( big release based off of multiple minor releases )
@@ -219,7 +219,7 @@ describe 'Backup::CLI::Utility' do
219
219
  [--syncers=SYNCERS] # (cloud_files, rsync_local, rsync_pull, rsync_push, s3)
220
220
  [--encryptors=ENCRYPTORS] # (gpg, openssl)
221
221
  [--compressors=COMPRESSORS] # (bzip2, custom, gzip, lzma, pbzip2)
222
- [--notifiers=NOTIFIERS] # (campfire, hipchat, mail, prowl, twitter)
222
+ [--notifiers=NOTIFIERS] # (campfire, hipchat, mail, prowl, pushover, twitter)
223
223
  [--archives]
224
224
  [--splitter] # use `--no-splitter` to disable
225
225
  # Default: true
@@ -0,0 +1,123 @@
1
+ # encoding: utf-8
2
+
3
+ require File.expand_path('../../spec_helper.rb', __FILE__)
4
+
5
+ describe Backup::Notifier::Pushover do
6
+ let(:model) { Backup::Model.new(:test_trigger, 'test label') }
7
+ let(:notifier) do
8
+ Backup::Notifier::Pushover.new(model) do |notifier|
9
+ notifier.user = 'user_token'
10
+ notifier.token = 'app_token'
11
+ notifier.title = 'title'
12
+ end
13
+ end
14
+
15
+ it 'should be a subclass of Notifier::Base' do
16
+ Backup::Notifier::Pushover.
17
+ superclass.should == Backup::Notifier::Base
18
+ end
19
+
20
+ describe '#initialize' do
21
+ after { Backup::Notifier::Pushover.clear_defaults! }
22
+
23
+ it 'should load pre-configured defaults through Base' do
24
+ Backup::Notifier::Pushover.any_instance.expects(:load_defaults!)
25
+ notifier
26
+ end
27
+
28
+ it 'should pass the model reference to Base' do
29
+ notifier.instance_variable_get(:@model).should == model
30
+ end
31
+
32
+ context 'when no pre-configured defaults have been set' do
33
+ it 'should use the values given' do
34
+ notifier.user.should == 'user_token'
35
+ notifier.token.should == 'app_token'
36
+ notifier.device.should be_nil
37
+ notifier.priority.should be_nil
38
+
39
+ notifier.on_success.should == true
40
+ notifier.on_warning.should == true
41
+ notifier.on_failure.should == true
42
+ end
43
+
44
+ it 'should use default values if none are given' do
45
+ notifier = Backup::Notifier::Pushover.new(model)
46
+ notifier.token.should be_nil
47
+ notifier.user.should be_nil
48
+ notifier.device.should be_nil
49
+ notifier.priority.should be_nil
50
+
51
+ notifier.on_success.should == true
52
+ notifier.on_warning.should == true
53
+ notifier.on_failure.should == true
54
+ end
55
+ end # context 'when no pre-configured defaults have been set'
56
+
57
+ context 'when pre-configured defaults have been set' do
58
+ before do
59
+ Backup::Notifier::Pushover.defaults do |n|
60
+ n.token = 'the_token'
61
+ n.user = 'the_user'
62
+ n.on_failure = false
63
+ end
64
+ end
65
+
66
+ it 'should use pre-configured defaults' do
67
+ notifier = Backup::Notifier::Pushover.new(model)
68
+
69
+ notifier.token.should == 'the_token'
70
+ notifier.user.should == 'the_user'
71
+
72
+ notifier.on_success.should == true
73
+ notifier.on_warning.should == true
74
+ notifier.on_failure.should == false
75
+ end
76
+
77
+ it 'should override pre-configured defaults' do
78
+ notifier = Backup::Notifier::Pushover.new(model) do |n|
79
+ n.token = 'new_token'
80
+ n.user = 'new_user'
81
+ n.on_success = false
82
+ n.on_failure = true
83
+ end
84
+
85
+ notifier.token.should == 'new_token'
86
+ notifier.user.should == 'new_user'
87
+
88
+ notifier.on_success.should == false
89
+ notifier.on_warning.should == true
90
+ notifier.on_failure.should == true
91
+ end
92
+ end # context 'when pre-configured defaults have been set'
93
+ end # describe '#initialize'
94
+
95
+ describe '#notify!' do
96
+ context 'when status is :success' do
97
+ it 'should send Success message' do
98
+ notifier.expects(:send_message).with(
99
+ '[Backup::Success] test label (test_trigger)'
100
+ )
101
+ notifier.send(:notify!, :success)
102
+ end
103
+ end
104
+
105
+ context 'when status is :warning' do
106
+ it 'should send Warning message' do
107
+ notifier.expects(:send_message).with(
108
+ '[Backup::Warning] test label (test_trigger)'
109
+ )
110
+ notifier.send(:notify!, :warning)
111
+ end
112
+ end
113
+
114
+ context 'when status is :failure' do
115
+ it 'should send Failure message' do
116
+ notifier.expects(:send_message).with(
117
+ '[Backup::Failure] test label (test_trigger)'
118
+ )
119
+ notifier.send(:notify!, :failure)
120
+ end
121
+ end
122
+ end # describe '#notify!'
123
+ end
@@ -0,0 +1,11 @@
1
+ ##
2
+ # Pushover [Notifier]
3
+ #
4
+ notify_by Pushover do |push|
5
+ push.on_success = true
6
+ push.on_warning = true
7
+ push.on_failure = true
8
+
9
+ push.user = "USER_TOKEN"
10
+ push.token = "APP_TOKEN"
11
+ end
metadata CHANGED
@@ -1,55 +1,64 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: backup
3
- version: !ruby/object:Gem::Version
4
- version: 3.0.25
5
- prerelease:
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 3
7
+ - 0
8
+ - 26
9
+ version: 3.0.26
6
10
  platform: ruby
7
- authors:
11
+ authors:
8
12
  - Michael van Rooijen
9
13
  autorequire:
10
14
  bindir: bin
11
15
  cert_chain: []
12
- date: 2012-08-01 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
16
+
17
+ date: 2012-11-17 00:00:00 +01:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: thor
16
- requirement: !ruby/object:Gem::Requirement
17
- none: false
18
- requirements:
19
- - - ~>
20
- - !ruby/object:Gem::Version
21
- version: 0.15.4
22
- type: :runtime
23
22
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ~>
28
- - !ruby/object:Gem::Version
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ requirements:
25
+ - - ">="
26
+ - !ruby/object:Gem::Version
27
+ segments:
28
+ - 0
29
+ - 15
30
+ - 4
29
31
  version: 0.15.4
30
- - !ruby/object:Gem::Dependency
31
- name: open4
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ~>
36
- - !ruby/object:Gem::Version
37
- version: 1.3.0
32
+ - - <
33
+ - !ruby/object:Gem::Version
34
+ segments:
35
+ - 2
36
+ version: "2"
38
37
  type: :runtime
38
+ version_requirements: *id001
39
+ - !ruby/object:Gem::Dependency
40
+ name: open4
39
41
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
42
+ requirement: &id002 !ruby/object:Gem::Requirement
43
+ requirements:
43
44
  - - ~>
44
- - !ruby/object:Gem::Version
45
+ - !ruby/object:Gem::Version
46
+ segments:
47
+ - 1
48
+ - 3
49
+ - 0
45
50
  version: 1.3.0
51
+ type: :runtime
52
+ version_requirements: *id002
46
53
  description:
47
54
  email: meskyanichi@gmail.com
48
- executables:
55
+ executables:
49
56
  - backup
50
57
  extensions: []
58
+
51
59
  extra_rdoc_files: []
52
- files:
60
+
61
+ files:
53
62
  - .gitignore
54
63
  - .travis.yml
55
64
  - Gemfile
@@ -92,6 +101,7 @@ files:
92
101
  - lib/backup/notifier/hipchat.rb
93
102
  - lib/backup/notifier/mail.rb
94
103
  - lib/backup/notifier/prowl.rb
104
+ - lib/backup/notifier/pushover.rb
95
105
  - lib/backup/notifier/twitter.rb
96
106
  - lib/backup/package.rb
97
107
  - lib/backup/packager.rb
@@ -162,6 +172,7 @@ files:
162
172
  - spec/notifier/hipchat_spec.rb
163
173
  - spec/notifier/mail_spec.rb
164
174
  - spec/notifier/prowl_spec.rb
175
+ - spec/notifier/pushover_spec.rb
165
176
  - spec/notifier/twitter_spec.rb
166
177
  - spec/package_spec.rb
167
178
  - spec/packager_spec.rb
@@ -207,6 +218,7 @@ files:
207
218
  - templates/cli/utility/notifier/hipchat
208
219
  - templates/cli/utility/notifier/mail
209
220
  - templates/cli/utility/notifier/prowl
221
+ - templates/cli/utility/notifier/pushover
210
222
  - templates/cli/utility/notifier/twitter
211
223
  - templates/cli/utility/splitter
212
224
  - templates/cli/utility/storage/cloud_files
@@ -231,33 +243,35 @@ files:
231
243
  - templates/storage/dropbox/authorization_url.erb
232
244
  - templates/storage/dropbox/authorized.erb
233
245
  - templates/storage/dropbox/cache_file_written.erb
246
+ has_rdoc: true
234
247
  homepage: http://rubygems.org/gems/backup
235
248
  licenses: []
249
+
236
250
  post_install_message:
237
251
  rdoc_options: []
238
- require_paths:
252
+
253
+ require_paths:
239
254
  - lib
240
- required_ruby_version: !ruby/object:Gem::Requirement
241
- none: false
242
- requirements:
243
- - - ! '>='
244
- - !ruby/object:Gem::Version
245
- version: '0'
246
- required_rubygems_version: !ruby/object:Gem::Requirement
247
- none: false
248
- requirements:
249
- - - ! '>='
250
- - !ruby/object:Gem::Version
251
- version: '0'
255
+ required_ruby_version: !ruby/object:Gem::Requirement
256
+ requirements:
257
+ - - ">="
258
+ - !ruby/object:Gem::Version
259
+ segments:
260
+ - 0
261
+ version: "0"
262
+ required_rubygems_version: !ruby/object:Gem::Requirement
263
+ requirements:
264
+ - - ">="
265
+ - !ruby/object:Gem::Version
266
+ segments:
267
+ - 0
268
+ version: "0"
252
269
  requirements: []
270
+
253
271
  rubyforge_project:
254
- rubygems_version: 1.8.24
272
+ rubygems_version: 1.3.6
255
273
  signing_key:
256
274
  specification_version: 3
257
- summary: Backup is a RubyGem, written for UNIX-like operating systems, that allows
258
- you to easily perform backup operations on both your remote and local environments.
259
- It provides you with an elegant DSL in Ruby for modeling your backups. Backup has
260
- built-in support for various databases, storage protocols/services, syncers, compressors,
261
- encryptors and notifiers which you can mix and match. It was built with modularity,
262
- extensibility and simplicity in mind.
275
+ summary: Backup is a RubyGem, written for UNIX-like operating systems, that allows you to easily perform backup operations on both your remote and local environments. It provides you with an elegant DSL in Ruby for modeling your backups. Backup has built-in support for various databases, storage protocols/services, syncers, compressors, encryptors and notifiers which you can mix and match. It was built with modularity, extensibility and simplicity in mind.
263
276
  test_files: []
277
+