boxafe 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Gemfile +2 -0
- data/VERSION +1 -1
- data/lib/boxafe/cli.rb +7 -1
- data/lib/boxafe/config.rb +1 -1
- data/lib/boxafe/encfs.rb +4 -3
- data/lib/boxafe/notifier/growl.rb +27 -0
- data/lib/boxafe/notifier/notification_center.rb +27 -0
- data/lib/boxafe/notifier.rb +43 -0
- data/lib/boxafe.rb +1 -1
- metadata +32 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODMyZGQyNWI3ZDQyMTI2MzNkMjlhNGM4MTc3YzliMzhkZTlhNTM0Mg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZTkyMWRmY2M4NjU1MTAyNDQwMWU4YjEyNWZhYzAzNzgwYmUzNTZkOA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Y2UzNjNmMTg3NzY4MGNlN2I1MjZiNmU2MzNmNTZlMDNiNjdhYzVjNzNhMjdi
|
10
|
+
ZmI2YWFhZjQ3MjY3MGI1Nzg1Y2ZiYzRmOGI0ZjBmYTBmOTY5NjNmZThmZTRj
|
11
|
+
YjhkOGVjMjg4ZDIzZWIxODU0NTAwOWFiNGVhMmRlNzgwY2IxZGM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZjI2NWNhNmYzMjNjOGVkYWQ2ZWY5OTJkYjQ1ZjEwMWE3ZTNmMDAzNzgxNDVm
|
14
|
+
MTE3NzlmMzIxMWE2ODA3OGZkNjNlMWNmMWE4YjFiNjdkOTRlMTQ1NjcyNzZh
|
15
|
+
MDBjZDBmYzI3NDRhZTRhMTY0MzNhYmUzNWRjZjQ1ODk5YzZjOWU=
|
data/Gemfile
CHANGED
@@ -9,6 +9,8 @@ gem 'which_works', '~> 1.0.0'
|
|
9
9
|
gem 'dotenv', '~> 0.8.0'
|
10
10
|
gem 'mutaconf', '~> 0.2.0'
|
11
11
|
gem 'launchdr', '3'
|
12
|
+
gem 'growl', '~> 1.0.3'
|
13
|
+
gem 'terminal-notifier-guard', '~> 1.5.3'
|
12
14
|
#gem 'whenever', '~> 0.8.2'
|
13
15
|
#gem 'whenever', :git => 'git@github.com:AlphaHydrae/whenever.git', :branch => 'block-config'
|
14
16
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.4
|
data/lib/boxafe/cli.rb
CHANGED
@@ -34,16 +34,20 @@ class Boxafe::CLI
|
|
34
34
|
# FIXME: crashes with unknown box names
|
35
35
|
boxes = args.empty? ? config.boxes : args.collect{ |arg| config.boxes.find{ |box| box.name == arg } }
|
36
36
|
|
37
|
+
notifier = Boxafe::Notifier.notifier config.options
|
38
|
+
|
37
39
|
puts
|
38
40
|
boxes.each do |box|
|
39
41
|
|
40
42
|
print "Mounting #{box.name}... "
|
41
43
|
case box.mount_status
|
42
44
|
when :mounted
|
45
|
+
notifier.notify "#{box.name} is already mounted" if notifier
|
43
46
|
puts Paint['already mounted', :green]
|
44
47
|
next
|
45
48
|
when :invalid
|
46
|
-
|
49
|
+
notifier.notify "#{box.name} has an invalid mount point (not a directory)", type: :failure if notifier
|
50
|
+
puts Paint['invalid mount point (not a directory)', :red]
|
47
51
|
next
|
48
52
|
end
|
49
53
|
|
@@ -52,8 +56,10 @@ class Boxafe::CLI
|
|
52
56
|
|
53
57
|
puts case box.mount_status
|
54
58
|
when :mounted
|
59
|
+
notifier.notify "#{box.name} is mounted", type: :success if notifier
|
55
60
|
Paint['mounted', :green]
|
56
61
|
else
|
62
|
+
notifier.notify "#{box.name} could not be mounted", type: :failure if notifier
|
57
63
|
Paint['could not be mounted', :red]
|
58
64
|
end
|
59
65
|
end
|
data/lib/boxafe/config.rb
CHANGED
data/lib/boxafe/encfs.rb
CHANGED
@@ -8,13 +8,14 @@ class Boxafe::Encfs
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def command
|
11
|
-
|
11
|
+
# TODO: use shellwords for binary, test escaping
|
12
|
+
[ encfs_config, @options[:encfs], Shellwords.escape(@options[:root]), Shellwords.escape(@options[:mount]), extpass, '--', volname ].compact.join ' '
|
12
13
|
end
|
13
14
|
|
14
15
|
private
|
15
16
|
|
16
17
|
def volname
|
17
|
-
%/-ovolname
|
18
|
+
%/-ovolname=#{Shellwords.escape @options[:volume]}/
|
18
19
|
end
|
19
20
|
|
20
21
|
def extpass
|
@@ -26,6 +27,6 @@ class Boxafe::Encfs
|
|
26
27
|
end
|
27
28
|
|
28
29
|
def encfs_config
|
29
|
-
@options[:encfs_config] ? %/ENCFS6_CONFIG
|
30
|
+
@options[:encfs_config] ? %/ENCFS6_CONFIG=#{Shellwords.escape File.expand_path(@options[:encfs_config])}/ : nil
|
30
31
|
end
|
31
32
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'growl'
|
3
|
+
|
4
|
+
class Boxafe::Notifier::Growl < Boxafe::Notifier
|
5
|
+
METHODS = {
|
6
|
+
info: :notify_info,
|
7
|
+
success: :notify_ok,
|
8
|
+
failure: :notify_error
|
9
|
+
}
|
10
|
+
|
11
|
+
def self.available?
|
12
|
+
::Growl.installed?
|
13
|
+
end
|
14
|
+
|
15
|
+
def notify msg, options = {}
|
16
|
+
method = METHODS[options.delete(:type)] || :notify_info
|
17
|
+
::Growl.send method, msg, growl_options(options)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def growl_options options = {}
|
23
|
+
@options.dup.tap do |h|
|
24
|
+
h[:title] = options[:title] if options[:title]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'terminal-notifier-guard'
|
3
|
+
|
4
|
+
class Boxafe::Notifier::NotificationCenter < Boxafe::Notifier
|
5
|
+
METHODS = {
|
6
|
+
info: :notify,
|
7
|
+
success: :success,
|
8
|
+
failure: :failed
|
9
|
+
}
|
10
|
+
|
11
|
+
def self.available?
|
12
|
+
TerminalNotifier::Guard.available?
|
13
|
+
end
|
14
|
+
|
15
|
+
def notify msg, options = {}
|
16
|
+
method = METHODS[options.delete(:type)] || :notify
|
17
|
+
TerminalNotifier::Guard.send method, msg, terminal_notifier_options(options)
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def terminal_notifier_options options = {}
|
23
|
+
@options.dup.tap do |h|
|
24
|
+
h[:title] = options[:title] if options[:title]
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
class Boxafe::Notifier
|
4
|
+
IMPLEMENTATIONS = %w(growl notification_center)
|
5
|
+
|
6
|
+
def self.notifier options = {}
|
7
|
+
if options[:notify] == true
|
8
|
+
platform_notifier options
|
9
|
+
elsif IMPLEMENTATIONS.include?(name = options[:notify].to_s)
|
10
|
+
notifier_instance name, options
|
11
|
+
elsif options.key?(:notify) and options[:notify] != false
|
12
|
+
raise Boxafe::Error, "Unknown notification type #{options[:notify].inspect}"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.notifier_instance name, options = {}
|
17
|
+
impl = Boxafe::Notifier.const_get(name.gsub(/(?:\A|_)(.)/){ $1.upcase })
|
18
|
+
impl.available? ? impl.new(options) : nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.platform_notifier options = {}
|
22
|
+
|
23
|
+
candidates = case RbConfig::CONFIG['host_os']
|
24
|
+
when /darwin/i
|
25
|
+
%w(notification_center growl)
|
26
|
+
else
|
27
|
+
[]
|
28
|
+
end
|
29
|
+
|
30
|
+
candidates.each do |name|
|
31
|
+
notifier = notifier_instance name, options
|
32
|
+
return notifier if notifier
|
33
|
+
end
|
34
|
+
|
35
|
+
nil
|
36
|
+
end
|
37
|
+
|
38
|
+
def initialize options = {}
|
39
|
+
@options = { title: 'Boxafe' }.merge options
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
Dir[File.join File.dirname(__FILE__), File.basename(__FILE__, '.*'), '*.rb'].each{ |lib| require lib }
|
data/lib/boxafe.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: boxafe
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AlphaHydrae
|
@@ -94,6 +94,34 @@ dependencies:
|
|
94
94
|
- - '='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '3'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: growl
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 1.0.3
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 1.0.3
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: terminal-notifier-guard
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 1.5.3
|
118
|
+
type: :runtime
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ~>
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 1.5.3
|
97
125
|
- !ruby/object:Gem::Dependency
|
98
126
|
name: bundler
|
99
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -225,6 +253,9 @@ files:
|
|
225
253
|
- lib/boxafe/cli.rb
|
226
254
|
- lib/boxafe/config.rb
|
227
255
|
- lib/boxafe/encfs.rb
|
256
|
+
- lib/boxafe/notifier.rb
|
257
|
+
- lib/boxafe/notifier/growl.rb
|
258
|
+
- lib/boxafe/notifier/notification_center.rb
|
228
259
|
- lib/boxafe/program.rb
|
229
260
|
- lib/boxafe/scheduler.rb
|
230
261
|
- lib/boxafe/scheduler/cron.rb
|