filewatcher 0.3.0 → 0.3.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 +4 -4
- data/LICENSE +1 -1
- data/README.rdoc +11 -9
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/bin/filewatcher +16 -8
- data/lib/filewatcher.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e11975d24379196fffe99ab55fae2aa8c8f7d6e1
|
4
|
+
data.tar.gz: 9cc8ce2b4587d2f7753e613b82e18de81f17d076
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06ac3efd3fbf4e58c93a0b712470aa17d95a6459af64fb54fc8f6feac1710352d67a03044cb9aaa75ec14d688f14b065112adcdf319d8f2a69d31be18f2fc40c
|
7
|
+
data.tar.gz: c4db481b3f44d80cc8175690d7b662ffa8ac85caadf666b52ca067894dab5b668cdcab841ced8ba56b505ccea6f078ea1d35e8feb02f92d7dcfa95ed7c0bbc29
|
data/LICENSE
CHANGED
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= Filewatcher
|
2
2
|
|
3
|
-
Simple file watcher. Monitors changes in
|
3
|
+
Simple file watcher. Monitors changes in filesystem by polling. No dependencies.
|
4
4
|
|
5
5
|
= Install
|
6
6
|
|
@@ -24,12 +24,14 @@ Run the echo command when the file myfile is changed:
|
|
24
24
|
|
25
25
|
$ filewatcher "myfile" "echo 'myfile has changed'"
|
26
26
|
|
27
|
-
Run any javascript in current folder when it is updated
|
28
|
-
|
27
|
+
Run any javascript in the current folder when it is updated in Windows Powershell:
|
28
|
+
|
29
|
+
> filewatcher *.js "node %FILENAME%"
|
29
30
|
|
30
|
-
In
|
31
|
+
In Linux/OSX:
|
32
|
+
|
33
|
+
$ filewatcher *.js "node $FILENAME"
|
31
34
|
|
32
|
-
> filewatcher *.js "node %FILENAME%"
|
33
35
|
|
34
36
|
Run the ruby script when it is changed:
|
35
37
|
|
@@ -91,13 +93,13 @@ To detect if a file is updated or deleted:
|
|
91
93
|
|
92
94
|
FileWatcher.new(["README.rdoc"]).watch() do |filename, event|
|
93
95
|
if(event == :changed)
|
94
|
-
puts "
|
96
|
+
puts "File updated: " + filename
|
95
97
|
end
|
96
|
-
if(event == :
|
97
|
-
puts "
|
98
|
+
if(event == :delete)
|
99
|
+
puts "File deleted: " + filename
|
98
100
|
end
|
99
101
|
if(event == :new)
|
100
|
-
puts "New file " + filename
|
102
|
+
puts "New file: " + filename
|
101
103
|
end
|
102
104
|
end
|
103
105
|
|
data/Rakefile
CHANGED
@@ -13,7 +13,7 @@ begin
|
|
13
13
|
gem.authors = ["Thomas Flemming"]
|
14
14
|
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
15
15
|
gem.add_dependency "trollop", ">= 1.16.2"
|
16
|
-
|
16
|
+
gem.licenses = ["MIT"]
|
17
17
|
end
|
18
18
|
rescue LoadError
|
19
19
|
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
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 #{FileWatcher.VERSION} by Thomas Flemming
|
8
|
+
version "filewatcher, version #{FileWatcher.VERSION} by Thomas Flemming 2014"
|
9
9
|
banner <<-EOS
|
10
10
|
Filewatcher scans filesystem and execute shell commands when files changes.
|
11
11
|
|
@@ -48,13 +48,9 @@ if(options[:recurse])
|
|
48
48
|
files = inc - exc
|
49
49
|
end
|
50
50
|
|
51
|
-
if(options[:list])
|
52
|
-
puts "watching:", files.inspect
|
53
|
-
end
|
54
|
-
|
55
51
|
runners = {".py" => "python", ".rb" => "ruby", ".pl" => "perl", ".awk" => "awk"}
|
56
52
|
|
57
|
-
FileWatcher.new(files).watch(options[:interval]) do |filename|
|
53
|
+
FileWatcher.new(files, options[:list]).watch(options[:interval]) do |filename, event|
|
58
54
|
if(options[:exec])
|
59
55
|
extension = filename[/(\.[^\.]*)/,0]
|
60
56
|
runner = runners[extension].to_s
|
@@ -64,12 +60,24 @@ FileWatcher.new(files).watch(options[:interval]) do |filename|
|
|
64
60
|
cmd = ARGV[-1]
|
65
61
|
env = {
|
66
62
|
'FILENAME'=> path.to_s,
|
67
|
-
'FILEPATH' => path.realpath.to_s,
|
68
63
|
'FILEDIR' => path.parent.realpath.to_s
|
69
64
|
}
|
65
|
+
if(event != :delete)
|
66
|
+
ENV['FILEPATH'] = path.realpath.to_s
|
67
|
+
end
|
70
68
|
pid = Process.spawn(env, cmd);
|
71
69
|
pid = Process.wait();
|
72
70
|
else
|
73
|
-
|
71
|
+
case(event)
|
72
|
+
when :changed
|
73
|
+
print "file updated"
|
74
|
+
when :delete
|
75
|
+
print "file eleted"
|
76
|
+
when :new
|
77
|
+
print "new file"
|
78
|
+
else
|
79
|
+
print event.to_s
|
80
|
+
end
|
81
|
+
puts ": " + filename
|
74
82
|
end
|
75
83
|
end
|
data/lib/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.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Flemming
|
@@ -56,7 +56,8 @@ files:
|
|
56
56
|
- test/helper.rb
|
57
57
|
- test/test_filewatcher.rb
|
58
58
|
homepage: http://github.com/thomasfl/filewatcher
|
59
|
-
licenses:
|
59
|
+
licenses:
|
60
|
+
- MIT
|
60
61
|
metadata: {}
|
61
62
|
post_install_message:
|
62
63
|
rdoc_options: []
|