file-monitor 0.1.3 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +37 -0
- data/bin/f5.rb +0 -0
- data/bin/watch.rb +61 -0
- data/examples/f5.rb +0 -0
- data/examples/simple.rb +15 -0
- data/lib/file-monitor.rb +13 -10
- metadata +39 -51
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7b978751c254b8d7da4741b2250b0c1a89ce0cf5
|
4
|
+
data.tar.gz: 864c9b31b94d575560933770bb97d9d0fbad68bb
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b1f78303e045851b3c2b0a1b972d986084f6ea21b5464ff8bb42739dfb4f5fa48f1d4a9c9c79d04a9d02052f829380482cf70a8d165aaf3daae89738022b161e
|
7
|
+
data.tar.gz: f22b283565d45e4aee994733aba6f945ef272653a811c588641a288014e7ffd104fd185bd9db2975f204c28d135552a7148d86018e862a3de1a9b4d04bb8c055
|
data/README.md
CHANGED
@@ -89,6 +89,24 @@ Usage
|
|
89
89
|
}
|
90
90
|
end
|
91
91
|
|
92
|
+
#### Simple
|
93
|
+
|
94
|
+
#!/usr/bin/env ruby
|
95
|
+
# coding: utf-8
|
96
|
+
# File: examples/simple.rb
|
97
|
+
require 'rubygems'
|
98
|
+
require 'file-monitor'
|
99
|
+
|
100
|
+
FileMonitor.watch '.' do
|
101
|
+
# missing 'dirs' file-monitor will watch all sub directories
|
102
|
+
|
103
|
+
# only record ruby file
|
104
|
+
files /\.rb$/
|
105
|
+
exec {
|
106
|
+
system('rake test')
|
107
|
+
}
|
108
|
+
end
|
109
|
+
|
92
110
|
Examples
|
93
111
|
--------
|
94
112
|
### Auto F5
|
@@ -138,3 +156,22 @@ Edit and save README.md by gvim, examples/use-block outputs
|
|
138
156
|
# ./README.md
|
139
157
|
5 events
|
140
158
|
do something
|
159
|
+
|
160
|
+
### File Monitor Cli
|
161
|
+
|
162
|
+
$ watch.rb
|
163
|
+
|
164
|
+
Usage: watch.rb [options] [directory]
|
165
|
+
|
166
|
+
-d, --dir the directory regexp to watch
|
167
|
+
-e, --exec the command will be execuate
|
168
|
+
-f, --file the file regexp to watch
|
169
|
+
-h, --help display this help message
|
170
|
+
|
171
|
+
Example:
|
172
|
+
|
173
|
+
Watch current working dir and sub directory lib and src,
|
174
|
+
if any ruby file(match \.rb$) changes
|
175
|
+
then execute 'ls' command
|
176
|
+
|
177
|
+
watch.rb -d 'lib$' -d 'src$' -f '\.rb$' -e 'ls'
|
data/bin/f5.rb
CHANGED
File without changes
|
data/bin/watch.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'file-monitor'
|
5
|
+
require 'getoptlong'
|
6
|
+
|
7
|
+
opts = GetoptLong.new(
|
8
|
+
['--dir', '-d', GetoptLong::OPTIONAL_ARGUMENT],
|
9
|
+
['--file', '-f', GetoptLong::OPTIONAL_ARGUMENT],
|
10
|
+
['--exec', '-e', GetoptLong::OPTIONAL_ARGUMENT],
|
11
|
+
['--help', '-h', GetoptLong::OPTIONAL_ARGUMENT]
|
12
|
+
)
|
13
|
+
|
14
|
+
$dirs = []
|
15
|
+
$files = []
|
16
|
+
$command = 'echo do something'
|
17
|
+
opts.each do|opt, arg|
|
18
|
+
case opt
|
19
|
+
when '--dir'
|
20
|
+
$dirs.push Regexp.new arg
|
21
|
+
when '--file'
|
22
|
+
$files.push Regexp.new arg
|
23
|
+
when '--exec'
|
24
|
+
$command = arg
|
25
|
+
when '--help'
|
26
|
+
puts <<EOT
|
27
|
+
|
28
|
+
Usage: watch.rb [options] [directory]
|
29
|
+
|
30
|
+
-d, --dir the directory regexp to watch
|
31
|
+
-e, --exec the command will be execuate
|
32
|
+
-f, --file the file regexp to watch
|
33
|
+
-h, --help display this help message
|
34
|
+
|
35
|
+
Example:
|
36
|
+
|
37
|
+
Watch current working dir and sub directory lib and src,
|
38
|
+
if any ruby file(match \.rb$) changes
|
39
|
+
then execute 'ls' command
|
40
|
+
|
41
|
+
watch.rb -d 'lib$' -d 'src$' -f '.rb$' -e 'ls'
|
42
|
+
|
43
|
+
EOT
|
44
|
+
exit(0)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
dir = ARGV[0] || '.'
|
49
|
+
|
50
|
+
print 'dirs: '
|
51
|
+
puts $dirs.inspect
|
52
|
+
print 'files: '
|
53
|
+
puts $files.inspect
|
54
|
+
|
55
|
+
FileMonitor.watch dir do
|
56
|
+
dirs *$dirs
|
57
|
+
files *$files
|
58
|
+
exec do
|
59
|
+
system $command
|
60
|
+
end
|
61
|
+
end
|
data/examples/f5.rb
CHANGED
File without changes
|
data/examples/simple.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
# File: examples/simple.rb
|
4
|
+
require 'rubygems'
|
5
|
+
require 'file-monitor'
|
6
|
+
|
7
|
+
FileMonitor.watch '.' do
|
8
|
+
# missing 'dirs' file-monitor will watch all sub directories
|
9
|
+
|
10
|
+
# only record ruby file
|
11
|
+
files /\.rb$/
|
12
|
+
exec {
|
13
|
+
system('rake test')
|
14
|
+
}
|
15
|
+
end
|
data/lib/file-monitor.rb
CHANGED
@@ -153,16 +153,19 @@ class FileMonitor
|
|
153
153
|
|
154
154
|
# Watch a directory
|
155
155
|
def watch(dir)
|
156
|
-
|
157
|
-
if
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
156
|
+
# always allow watching @project_dir
|
157
|
+
if dir != @project_dir
|
158
|
+
dir = trim_dir(dir)
|
159
|
+
if !@follow_symlink and File.symlink? dir
|
160
|
+
puts "ignore symlink directory #{dir}"
|
161
|
+
return false
|
162
|
+
end
|
163
|
+
if ignored_dir?(dir)
|
164
|
+
puts "ignore #{dir}"
|
165
|
+
return false
|
166
|
+
else
|
167
|
+
puts "watching #{dir}"
|
168
|
+
end
|
166
169
|
end
|
167
170
|
|
168
171
|
@notifier.watch dir, :modify, :create, :move, :delete, :onlydir do|event|
|
metadata
CHANGED
@@ -1,82 +1,70 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: file-monitor
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 0.1.3
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.5
|
6
5
|
platform: ruby
|
7
|
-
authors:
|
6
|
+
authors:
|
8
7
|
- JiangMiao
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- !ruby/object:Gem::Dependency
|
11
|
+
date: 2016-03-27 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
16
14
|
name: rb-inotify
|
17
|
-
|
18
|
-
|
19
|
-
none: false
|
20
|
-
requirements:
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
21
17
|
- - ">="
|
22
|
-
- !ruby/object:Gem::Version
|
18
|
+
- !ruby/object:Gem::Version
|
23
19
|
version: 0.8.8
|
24
20
|
type: :runtime
|
25
|
-
version_requirements: *id001
|
26
|
-
- !ruby/object:Gem::Dependency
|
27
|
-
name: rb-inotify
|
28
21
|
prerelease: false
|
29
|
-
|
30
|
-
|
31
|
-
requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
32
24
|
- - ">="
|
33
|
-
- !ruby/object:Gem::Version
|
25
|
+
- !ruby/object:Gem::Version
|
34
26
|
version: 0.8.8
|
35
|
-
|
36
|
-
|
37
|
-
description: Ruby File Monitor is a easy way to watch the directories and files, execute commands when them changed.
|
27
|
+
description: Ruby File Monitor is a easy way to watch the directories and files, execute
|
28
|
+
commands when them changed.
|
38
29
|
email: jiangfriend@gmail.com
|
39
|
-
executables:
|
30
|
+
executables:
|
40
31
|
- f5.rb
|
32
|
+
- watch.rb
|
41
33
|
extensions: []
|
42
|
-
|
43
34
|
extra_rdoc_files: []
|
44
|
-
|
45
|
-
|
46
|
-
-
|
35
|
+
files:
|
36
|
+
- README.md
|
37
|
+
- bin/f5.rb
|
38
|
+
- bin/watch.rb
|
39
|
+
- examples/f5.rb
|
40
|
+
- examples/simple.rb
|
47
41
|
- examples/use-block.rb
|
48
|
-
- examples/use-inherit.rb
|
49
|
-
- examples/use-filter.rb
|
50
42
|
- examples/use-creator.rb
|
51
|
-
- examples/
|
52
|
-
-
|
53
|
-
-
|
43
|
+
- examples/use-filter.rb
|
44
|
+
- examples/use-inherit.rb
|
45
|
+
- lib/file-monitor.rb
|
54
46
|
homepage: https://github.com/jiangmiao/ruby-file-monitor
|
55
|
-
licenses:
|
56
|
-
|
47
|
+
licenses:
|
48
|
+
- MIT
|
49
|
+
metadata: {}
|
57
50
|
post_install_message:
|
58
51
|
rdoc_options: []
|
59
|
-
|
60
|
-
require_paths:
|
52
|
+
require_paths:
|
61
53
|
- lib
|
62
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
-
|
64
|
-
requirements:
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
65
56
|
- - ">="
|
66
|
-
- !ruby/object:Gem::Version
|
57
|
+
- !ruby/object:Gem::Version
|
67
58
|
version: 1.8.7
|
68
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
-
|
70
|
-
requirements:
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
requirements:
|
71
61
|
- - ">="
|
72
|
-
- !ruby/object:Gem::Version
|
73
|
-
version:
|
62
|
+
- !ruby/object:Gem::Version
|
63
|
+
version: '0'
|
74
64
|
requirements: []
|
75
|
-
|
76
65
|
rubyforge_project: file-monitor
|
77
|
-
rubygems_version:
|
66
|
+
rubygems_version: 2.2.5
|
78
67
|
signing_key:
|
79
|
-
specification_version:
|
68
|
+
specification_version: 4
|
80
69
|
summary: File Monitor Library
|
81
70
|
test_files: []
|
82
|
-
|