filewatcher 0.1.9 → 0.2.0
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.
- data/VERSION +1 -1
- data/bin/filewatcher +9 -5
- data/lib/filewatcher.rb +10 -1
- data/test/helper.rb +1 -7
- data/test/test_filewatcher.rb +4 -0
- metadata +6 -6
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.2.0
|
data/bin/filewatcher
CHANGED
@@ -5,7 +5,7 @@ require 'trollop'
|
|
5
5
|
require 'pathname'
|
6
6
|
|
7
7
|
options = Trollop::options do
|
8
|
-
version "filewatcher, version
|
8
|
+
version "filewatcher, version #{FileWatcher.VERSION} by Thomas Flemming 2013"
|
9
9
|
banner <<-EOS
|
10
10
|
Filewatcher scans filesystem and execute shell commands when files changes.
|
11
11
|
|
@@ -61,10 +61,14 @@ FileWatcher.new(files).watch(options[:interval]) do |filename|
|
|
61
61
|
system(runner + " " + filename)
|
62
62
|
elsif(ARGV[-1])then
|
63
63
|
path = Pathname.new(filename)
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
64
|
+
cmd = ARGV[-1]
|
65
|
+
env = {
|
66
|
+
'FILENAME'=> path.to_s,
|
67
|
+
'FILEPATH' => path.realpath.to_s,
|
68
|
+
'FILEDIR' => path.parent.realpath.to_s
|
69
|
+
}
|
70
|
+
pid = Process.spawn(env, cmd);
|
71
|
+
pid = Process.wait();
|
68
72
|
else
|
69
73
|
puts "file updated: " + filename
|
70
74
|
end
|
data/lib/filewatcher.rb
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
# Issues: Currently doesn't monitor changes in directorynames
|
4
4
|
class FileWatcher
|
5
5
|
|
6
|
+
def self.VERSION
|
7
|
+
return "0.2.0"
|
8
|
+
end
|
9
|
+
|
6
10
|
def initialize(filenames,print_filelist=false)
|
7
11
|
if(filenames.kind_of?String)
|
8
12
|
filenames = [filenames]
|
@@ -42,7 +46,12 @@ class FileWatcher
|
|
42
46
|
|
43
47
|
def file_updated?
|
44
48
|
@filenames.each do |filename|
|
45
|
-
|
49
|
+
begin
|
50
|
+
mtime = File.stat(filename).mtime
|
51
|
+
rescue Errno::ENOENT
|
52
|
+
puts "filewatcher: File not found: " + filename
|
53
|
+
exit(66)
|
54
|
+
end
|
46
55
|
updated = @last_mtimes[filename] < mtime
|
47
56
|
@last_mtimes[filename] = mtime
|
48
57
|
if(updated)
|
data/test/helper.rb
CHANGED
@@ -1,10 +1,4 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'test/unit'
|
3
3
|
require 'shoulda'
|
4
|
-
|
5
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
6
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
7
|
-
require 'filewatcher'
|
8
|
-
|
9
|
-
class Test::Unit::TestCase
|
10
|
-
end
|
4
|
+
require_relative '../lib/filewatcher.rb'
|
data/test/test_filewatcher.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: filewatcher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-10-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: thoughtbot-shoulda
|
16
|
-
requirement: &
|
16
|
+
requirement: &70093896970560 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70093896970560
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: trollop
|
27
|
-
requirement: &
|
27
|
+
requirement: &70093896970060 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: 1.16.2
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70093896970060
|
36
36
|
description: Detect changes in files.
|
37
37
|
email: thomas.flemming@gmail.com
|
38
38
|
executables:
|