filewatcher 0.3.2 → 0.3.3
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/README.rdoc +22 -16
- data/Rakefile +2 -9
- data/VERSION +1 -1
- data/lib/filewatcher.rb +11 -11
- metadata +7 -23
- data/test/helper.rb +0 -4
- data/test/test_filewatcher.rb +0 -34
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8ce65dd1aeaf7054fd9a91b6787778569bccf8a8
|
4
|
+
data.tar.gz: 55cd4d125598d649b22f44c7225183c7163bf3f5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4c8b05df1ad574ce4a7c47d2b462c052d6c5e722b01f9b2da86c030af313170a2fd650988f2849ef32ad53e07c1217ac7ca72ed3b1b4b0c78a94af2357beb800
|
7
|
+
data.tar.gz: ad255b8e5655655f974dcd2e43623c9b0eefb660c6f5c99c50c174f8425eb6d4f6e80b477e0b954bbfb1a349dd7be013613caad4f3e90698610b4d84cacf4a82
|
data/README.rdoc
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
= Filewatcher
|
2
2
|
|
3
|
-
Simple file watcher. Monitors changes in filesystem by polling.
|
3
|
+
Simple file watcher. Monitors changes in filesystem by polling. API has no dependencies.
|
4
4
|
|
5
5
|
= Install
|
6
6
|
|
@@ -46,7 +46,7 @@ Print a list of all files matching *.css first and the print filename when a fil
|
|
46
46
|
= Available enviroment variables
|
47
47
|
|
48
48
|
The environment variable $FILENAME is available in the command. On unix like systems the command
|
49
|
-
has to be enclosed in single quotes. To run node whenever a javascript file is
|
49
|
+
has to be enclosed in single quotes. To run node whenever a javascript file is updated:
|
50
50
|
|
51
51
|
$ filewatcher *.js 'node $FILENAME'
|
52
52
|
|
@@ -75,20 +75,6 @@ Watch a list of files and directories:
|
|
75
75
|
puts "Updated " + filename
|
76
76
|
end
|
77
77
|
|
78
|
-
Print the names of files beeing watched before we begin:
|
79
|
-
|
80
|
-
FileWatcher.new(["lib/"],"Watching files:").watch do |filename|
|
81
|
-
puts "Updated " + filename
|
82
|
-
end
|
83
|
-
=> Watching files:
|
84
|
-
lib/filewatcher.rb
|
85
|
-
|
86
|
-
To check for changes more often than the default once every second:
|
87
|
-
|
88
|
-
FileWatcher.new(["README.rdoc"]).watch(0.5) do |filename|
|
89
|
-
puts "Updated " + filename
|
90
|
-
end
|
91
|
-
|
92
78
|
To detect if a file is updated or deleted:
|
93
79
|
|
94
80
|
FileWatcher.new(["README.rdoc"]).watch() do |filename, event|
|
@@ -103,6 +89,26 @@ To detect if a file is updated or deleted:
|
|
103
89
|
end
|
104
90
|
end
|
105
91
|
|
92
|
+
To check for changes more often than the default once every second:
|
93
|
+
|
94
|
+
FileWatcher.new(["README.rdoc"]).watch(0.5) do |filename|
|
95
|
+
puts "Updated " + filename
|
96
|
+
end
|
97
|
+
|
98
|
+
Print the names of files beeing watched before we begin:
|
99
|
+
|
100
|
+
FileWatcher.new(["lib/"],true).watch do |filename|
|
101
|
+
puts "Updated " + filename
|
102
|
+
end
|
103
|
+
=> Watching files:
|
104
|
+
lib/filewatcher.rb
|
105
|
+
|
106
|
+
Use patterns to match filenames. The pattern is not a regular expression; instead it follows rules similar to shell filename globbing. Se Ruby documentation[http://www.ruby-doc.org/core-2.1.1/File.html#method-c-fnmatch] for syntax.
|
107
|
+
|
108
|
+
FileWatcher.new(["*.rb", "*.xml"]).watch do |filename|
|
109
|
+
puts "Updated " + filename
|
110
|
+
end
|
111
|
+
|
106
112
|
= TODO
|
107
113
|
|
108
114
|
The Ruby API is fairly well tested but the command line program is buggy at the time beeing.
|
data/Rakefile
CHANGED
@@ -11,21 +11,14 @@ begin
|
|
11
11
|
gem.homepage = "http://github.com/thomasfl/filewatcher"
|
12
12
|
gem.executables = ["filewatcher"]
|
13
13
|
gem.authors = ["Thomas Flemming"]
|
14
|
-
gem.
|
15
|
-
gem.add_dependency
|
14
|
+
# gem.add_dependency "trollop", ">= 1.16.2"
|
15
|
+
gem.add_dependency 'trollop', '~> 2.0'
|
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"
|
20
20
|
end
|
21
21
|
|
22
|
-
require 'rake/testtask'
|
23
|
-
Rake::TestTask.new(:test) do |test|
|
24
|
-
test.libs << 'lib' << 'test'
|
25
|
-
test.pattern = 'test/**/test_*.rb'
|
26
|
-
test.verbose = true
|
27
|
-
end
|
28
|
-
|
29
22
|
begin
|
30
23
|
require 'rcov/rcovtask'
|
31
24
|
Rcov::RcovTask.new do |test|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.3
|
data/lib/filewatcher.rb
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
class FileWatcher
|
5
5
|
|
6
6
|
def self.VERSION
|
7
|
-
return "0.3.
|
7
|
+
return "0.3.3"
|
8
8
|
end
|
9
9
|
|
10
10
|
def initialize(unexpanded_filenames, print_filelist=false)
|
@@ -73,20 +73,20 @@ class FileWatcher
|
|
73
73
|
return false
|
74
74
|
end
|
75
75
|
|
76
|
-
def expand_directories(
|
77
|
-
if(
|
78
|
-
|
76
|
+
def expand_directories(patterns)
|
77
|
+
if(!patterns.kind_of?Array)
|
78
|
+
patterns = [patterns]
|
79
79
|
end
|
80
|
-
|
81
|
-
|
80
|
+
filenames = []
|
81
|
+
patterns.each do |filename|
|
82
82
|
if(File.directory?(filename))
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
files << filename
|
83
|
+
filenames = filenames + find(filename)
|
84
|
+
else
|
85
|
+
filenames = filenames + find(".", filename, true)
|
87
86
|
end
|
88
87
|
end
|
89
|
-
|
88
|
+
|
89
|
+
return filenames.uniq
|
90
90
|
end
|
91
91
|
|
92
92
|
def find(dir, filename="*.*", subdirs=true)
|
metadata
CHANGED
@@ -1,43 +1,29 @@
|
|
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.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Flemming
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: thoughtbot-shoulda
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - '>='
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
20
|
-
type: :development
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - '>='
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '0'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: trollop
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
30
16
|
requirements:
|
31
|
-
- -
|
17
|
+
- - ~>
|
32
18
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
19
|
+
version: '2.0'
|
34
20
|
type: :runtime
|
35
21
|
prerelease: false
|
36
22
|
version_requirements: !ruby/object:Gem::Requirement
|
37
23
|
requirements:
|
38
|
-
- -
|
24
|
+
- - ~>
|
39
25
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
26
|
+
version: '2.0'
|
41
27
|
description: Detect changes in filesystem.
|
42
28
|
email: thomas.flemming@gmail.com
|
43
29
|
executables:
|
@@ -53,8 +39,6 @@ files:
|
|
53
39
|
- VERSION
|
54
40
|
- bin/filewatcher
|
55
41
|
- lib/filewatcher.rb
|
56
|
-
- test/helper.rb
|
57
|
-
- test/test_filewatcher.rb
|
58
42
|
homepage: http://github.com/thomasfl/filewatcher
|
59
43
|
licenses:
|
60
44
|
- MIT
|
@@ -75,7 +59,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
75
59
|
version: '0'
|
76
60
|
requirements: []
|
77
61
|
rubyforge_project:
|
78
|
-
rubygems_version: 2.
|
62
|
+
rubygems_version: 2.2.2
|
79
63
|
signing_key:
|
80
64
|
specification_version: 4
|
81
65
|
summary: Simple filewatcher.
|
data/test/helper.rb
DELETED
data/test/test_filewatcher.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '.'))
|
2
|
-
require 'helper'
|
3
|
-
|
4
|
-
class TestFilewatcher < Test::Unit::TestCase
|
5
|
-
|
6
|
-
should "should detect directories and extract filenames" do
|
7
|
-
|
8
|
-
FileWatcher.new(["test/"],"Watching files. Ctrl-C to abort.").watch(0.1) do |filename, event|
|
9
|
-
puts "updated: '#{filename.to_s} event:'#{event.to_s}'"
|
10
|
-
end
|
11
|
-
|
12
|
-
end
|
13
|
-
|
14
|
-
# should "should detect changes in files" do
|
15
|
-
|
16
|
-
# @pid = fork do
|
17
|
-
|
18
|
-
# trap("SIGINT") do
|
19
|
-
# exit
|
20
|
-
# end
|
21
|
-
|
22
|
-
# FileWatcher.new(["test/helper.rb"]).watch(0.1) do |filename|
|
23
|
-
# puts "updated: " + filename
|
24
|
-
# end
|
25
|
-
|
26
|
-
# end
|
27
|
-
# sleep(1)
|
28
|
-
# FileUtils.touch("test/helper.rb")
|
29
|
-
# sleep(1)
|
30
|
-
# Process.kill('SIGINT', @pid) rescue nil
|
31
|
-
|
32
|
-
# end
|
33
|
-
|
34
|
-
end
|