backup_demon 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- backup_demon (0.0.2)
4
+ backup_demon (0.0.3)
5
5
  thor (~> 0.18)
6
6
 
7
7
  GEM
@@ -54,6 +54,12 @@ module BackupDemon
54
54
  end
55
55
  end
56
56
 
57
+ desc "reload", "reload the configuration"
58
+ def reload
59
+ load_config
60
+ end
61
+
62
+
57
63
  protected
58
64
  def load_config
59
65
  opts = {}
@@ -1,3 +1,5 @@
1
+ require 'date'
2
+
1
3
  module BackupDemon
2
4
  class Daemon
3
5
  def initialize(directories, device_path, mount_point = "/mnt/backuphdd")
@@ -12,12 +14,26 @@ module BackupDemon
12
14
 
13
15
  if @drive.exists? && @drive.different?
14
16
  procline 'Found Drive'
17
+
18
+ Notifier.alert("Starting Backup") do
19
+ "Starting Backup on #{Date.today}"
20
+ end
21
+
15
22
  if @drive.mount(@mount_point)
16
23
  @directories.each do |source|
17
24
  procline "Backing up #{source}"
18
25
  Sync.start(source, @drive.mount_point)
19
26
  end
20
- end
27
+ @drive.ummount
28
+
29
+ Notifier.alert("Backup Complete") do
30
+ "Backup Complete on #{Date.today}"
31
+ end
32
+ else
33
+ Notifier.alert("Backup Error") do
34
+ "Unable to mount the backup disk."
35
+ end
36
+ end
21
37
  end
22
38
 
23
39
  Kernel.sleep(interval)
@@ -0,0 +1,22 @@
1
+ module BackupDemon
2
+ class Notifier
3
+ def initialize(recepients)
4
+ @recepients = [recepients].flatten
5
+ end
6
+
7
+ def mail(subject, &block)
8
+ if block_given?
9
+ msg = yield
10
+
11
+ @recepients.each do |recepient|
12
+ `echo #{msg} | mail -s "#{subject}" #{recepient}`
13
+ end
14
+ end
15
+ end
16
+
17
+ def self.alert(subject, &block)
18
+ notifier = new(BackupDemon.config.recepients)
19
+ notifier.mail(subject, block)
20
+ end
21
+ end
22
+ end
@@ -1,3 +1,3 @@
1
1
  module BackupDemon
2
- Version = VERSION = '0.0.2'
2
+ Version = VERSION = '0.0.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: backup_demon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -49,6 +49,7 @@ files:
49
49
  - lib/backup_demon/core_ext/hash.rb
50
50
  - lib/backup_demon/daemon.rb
51
51
  - lib/backup_demon/device.rb
52
+ - lib/backup_demon/notifier.rb
52
53
  - lib/backup_demon/sync.rb
53
54
  - lib/backup_demon/version.rb
54
55
  homepage: https://github.com/ryanfaerman/backup_demon
@@ -65,7 +66,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
65
66
  version: '0'
66
67
  segments:
67
68
  - 0
68
- hash: -2489128216511426742
69
+ hash: -989672854755456934
69
70
  required_rubygems_version: !ruby/object:Gem::Requirement
70
71
  none: false
71
72
  requirements:
@@ -74,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
75
  version: '0'
75
76
  segments:
76
77
  - 0
77
- hash: -2489128216511426742
78
+ hash: -989672854755456934
78
79
  requirements: []
79
80
  rubyforge_project:
80
81
  rubygems_version: 1.8.24