dirwatch 0.0.0 → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28e52feff4b1a4dc37784ad8068a61045bba844f
4
- data.tar.gz: 54355f3b6eb1102921ecd050103fff6efddb3331
3
+ metadata.gz: 26c78f4771dcc01e082ad1e36fada76f29679793
4
+ data.tar.gz: d7d1361e238f98a0f9bd818e29a4bf3398eb238c
5
5
  SHA512:
6
- metadata.gz: a3f8a0c321dea9d1bf37ef79ca92cb8d23e3a2338a32ec571d08a9c762eb8c7b27b7426ca5314b08f1f70057bd96b3e24abb5741a8ccf4ddd66a673840de5083
7
- data.tar.gz: 78150645c779c24cef4af453487f6dfb3458b0a569340eb1cc167a8e365e4b7828c7b24f10c83cadbaf7d0c93172b939a05328db3b2db6c6a41d4dd15bc2c3f9
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
- watcher = Dirwatch::Watcher.from_args ARGV
6
- watcher.start
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
@@ -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('-f', '--file-match MATCH', 'The bash match for the file. Default: *.tex') do |match|
14
- options.file_match = match
13
+ opts.on '-v', '--[no-]verbose', 'Print additional information' do |verbose|
14
+ options.verbose = verbose
15
15
  end
16
16
 
17
- opts.on('-i', '--interval INTERVAL', OptionParser::DecimalNumeric, 'The number of seconds to wait unitl the next check. Default: 1') do |interval|
18
- options.interval = interval
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.on('-d', '--daemonize', 'Run the programm as a daemon') do
22
- options.daemonize = true
21
+ opts.on_tail '-h', '--help', 'Show this help' do
22
+ puts opts
23
+ exit
23
24
  end
24
25
 
25
- opts.on('-h', '--help', 'Show this help') do
26
- puts opts
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, :file_match, :interval, :daemonize
46
+ attr_reader :directory, :daemonize
45
47
 
46
- def initialize directory: nil, file_match: nil, interval: nil, daemonize: nil
48
+ def initialize directory:, daemonize: false, verbose: false
47
49
  raise 'The directory is required' unless directory
48
50
  @directory = directory
49
- @file_match = file_match || '*.tex'
50
- @interval = interval || 1
51
- @daemonize = !!daemonize
51
+ @daemonize = daemonize
52
+ @verbose = verbose
52
53
  end
53
54
  end
54
55
  end
@@ -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 = {}
@@ -1,3 +1,3 @@
1
1
  module Dirwatch
2
- VERSION = '0.0.0'
2
+ VERSION = Gem::Version.new '0.0.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dirwatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.0
4
+ version: 0.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nicolas Ganz