dirwatch 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/dirwatch +7 -2
- data/lib/dirwatch/options.rb +14 -13
- data/lib/dirwatch/settings.rb +9 -0
- data/lib/dirwatch/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26c78f4771dcc01e082ad1e36fada76f29679793
|
4
|
+
data.tar.gz: d7d1361e238f98a0f9bd818e29a4bf3398eb238c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a53182c9099d75540eef49b5837a4f3485339824ab754ea6b2d78ab601e38dbf74f1f9e7e0f1962fe8be27a980a9a7f4ebef66e093b87f976b53df1848d81b2e
|
7
|
+
data.tar.gz: 238321416eb30f0cffa9c03e8e8ce5fb80fcc61d3b3f6b6b6f857c523c2a9b00fd768059425c095d43ee3ef9f955dd2d70a74179af2a89f1f67d8973e489bef8
|
data/bin/dirwatch
CHANGED
@@ -2,8 +2,13 @@
|
|
2
2
|
|
3
3
|
#require 'dirwatch'
|
4
4
|
require_relative '../lib/dirwatch'
|
5
|
-
|
6
|
-
watcher.
|
5
|
+
begin
|
6
|
+
watcher = Dirwatch::Watcher.from_args ARGV
|
7
|
+
watcher.start
|
8
|
+
rescue Dirwatch::Settings::FileNotFoundError => e
|
9
|
+
puts "Could not find the file #{e.filename}"
|
10
|
+
exit 1
|
11
|
+
end
|
7
12
|
|
8
13
|
begin
|
9
14
|
sleep
|
data/lib/dirwatch/options.rb
CHANGED
@@ -10,20 +10,22 @@ module Dirwatch
|
|
10
10
|
parser = OptionParser.new do |opts|
|
11
11
|
opts.banner = "Usage: #{$0} [options] [directory]"
|
12
12
|
|
13
|
-
opts.on
|
14
|
-
options.
|
13
|
+
opts.on '-v', '--[no-]verbose', 'Print additional information' do |verbose|
|
14
|
+
options.verbose = verbose
|
15
15
|
end
|
16
16
|
|
17
|
-
opts.on
|
18
|
-
options.
|
17
|
+
opts.on '-d', '--[no-]daemonize', 'Run the programm as a daemon' do |daemonize|
|
18
|
+
options.daemonize = daemonize
|
19
19
|
end
|
20
20
|
|
21
|
-
opts.
|
22
|
-
|
21
|
+
opts.on_tail '-h', '--help', 'Show this help' do
|
22
|
+
puts opts
|
23
|
+
exit
|
23
24
|
end
|
24
25
|
|
25
|
-
opts.
|
26
|
-
|
26
|
+
opts.on_tail '--version', 'Show the version' do
|
27
|
+
require 'dirwatch/version'
|
28
|
+
puts "dirwatch #{Dirwatch::VERSION}"
|
27
29
|
exit
|
28
30
|
end
|
29
31
|
end
|
@@ -41,14 +43,13 @@ module Dirwatch
|
|
41
43
|
new options.to_h
|
42
44
|
end
|
43
45
|
|
44
|
-
attr_reader :directory, :
|
46
|
+
attr_reader :directory, :daemonize
|
45
47
|
|
46
|
-
def initialize directory
|
48
|
+
def initialize directory:, daemonize: false, verbose: false
|
47
49
|
raise 'The directory is required' unless directory
|
48
50
|
@directory = directory
|
49
|
-
@
|
50
|
-
@
|
51
|
-
@daemonize = !!daemonize
|
51
|
+
@daemonize = daemonize
|
52
|
+
@verbose = verbose
|
52
53
|
end
|
53
54
|
end
|
54
55
|
end
|
data/lib/dirwatch/settings.rb
CHANGED
@@ -2,11 +2,20 @@ require_relative 'settings/watch_setting'
|
|
2
2
|
|
3
3
|
module Dirwatch
|
4
4
|
class Settings
|
5
|
+
class FileNotFoundError < IOError
|
6
|
+
attr_reader :filename
|
7
|
+
def initialize filename, msg = nil
|
8
|
+
super msg || "Could not find the configuration file #{filename}"
|
9
|
+
@filename = filename
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
5
13
|
def self.from_options options
|
6
14
|
Settings.from_file(File.join(options.directory, 'dirwatch.yml'), options)
|
7
15
|
end
|
8
16
|
|
9
17
|
def self.from_file filename, options
|
18
|
+
raise FileNotFoundError, filename unless File.exists? filename
|
10
19
|
settings = new
|
11
20
|
config = symbolize YAML.load_file(filename)
|
12
21
|
watch_data = {}
|
data/lib/dirwatch/version.rb
CHANGED