jugyo-filetter 0.1.0 → 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/README.rdoc +18 -12
- data/Rakefile +0 -1
- data/lib/filetter.rb +27 -15
- data/lib/filetter/version.rb +1 -1
- data/lib/modes/mozrepl.rb +15 -6
- metadata +1 -1
data/README.rdoc
CHANGED
@@ -27,28 +27,34 @@ In the future,
|
|
27
27
|
|
28
28
|
== SYNOPSIS:
|
29
29
|
|
30
|
-
|
30
|
+
Run:
|
31
31
|
|
32
|
-
|
32
|
+
filetter -m MODE
|
33
33
|
|
34
|
-
|
34
|
+
or (for development)
|
35
35
|
|
36
|
-
|
36
|
+
./bin/debug -m MODE
|
37
37
|
|
38
|
-
|
38
|
+
Example:
|
39
39
|
|
40
|
-
|
40
|
+
run as 'mozrepl' mode for files named '*.css':
|
41
41
|
|
42
|
-
|
42
|
+
filetter -m mozrepl -p './**/*.css'
|
43
43
|
|
44
|
-
|
44
|
+
Configuration:
|
45
|
+
|
46
|
+
Default configuration file is '.filetter' in the current directory.
|
47
|
+
Filetter will load it if exist.
|
48
|
+
|
49
|
+
Or you specify it as follows:
|
50
|
+
|
51
|
+
filtter -m MODE -c my_config_file
|
45
52
|
|
46
53
|
== REQUIREMENTS:
|
47
54
|
|
48
|
-
|
55
|
+
configatron
|
49
56
|
|
50
57
|
== INSTALL:
|
51
58
|
|
52
|
-
gem
|
53
|
-
|
54
|
-
|
59
|
+
gem source -a http://gems.github.com
|
60
|
+
sudo gem install jugyo-filetter
|
data/Rakefile
CHANGED
@@ -20,7 +20,6 @@ Gem::Specification.new do |s|
|
|
20
20
|
s.description = "Filetter is a pluggable tool for file system."
|
21
21
|
s.files = %w( #{Dir['lib/**/*.rb'].join(' ')}
|
22
22
|
#{Dir['spec/**/*.rb'].join(' ')}
|
23
|
-
#{Dir['examples/**/*.rb'].join(' ')}
|
24
23
|
README.rdoc
|
25
24
|
History.txt
|
26
25
|
Rakefile )
|
data/lib/filetter.rb
CHANGED
@@ -1,16 +1,14 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
$:.unshift(File.dirname(__FILE__))
|
3
|
-
$:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
|
4
|
-
|
5
|
-
$: << File.dirname(__FILE__) + '/modes'
|
2
|
+
$:.unshift(File.dirname(__FILE__) + '/modes')
|
6
3
|
|
4
|
+
require 'optparse'
|
7
5
|
require 'rubygems'
|
8
6
|
require 'configatron'
|
7
|
+
def config; configatron; end
|
9
8
|
|
10
9
|
require 'filetter/version'
|
11
10
|
require 'filetter/file_info'
|
12
11
|
require 'filetter/observer'
|
13
|
-
require 'optparse'
|
14
12
|
|
15
13
|
Thread.abort_on_exception = true
|
16
14
|
|
@@ -20,19 +18,33 @@ module Filetter
|
|
20
18
|
pattern = './**/*'
|
21
19
|
interval = 1
|
22
20
|
debug = false
|
21
|
+
config_file = '.filetter'
|
22
|
+
mode = nil
|
23
|
+
load_file = nil
|
23
24
|
|
24
25
|
OptionParser.new do |opt|
|
25
|
-
opt.
|
26
|
-
opt.
|
27
|
-
opt.on('-
|
28
|
-
opt.on('-
|
29
|
-
opt.on('-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
26
|
+
opt.version = VERSION
|
27
|
+
opt.program_name = self.to_s
|
28
|
+
opt.on('-c', '--config=file', 'Configuration file' ) {|v| config_file = v }
|
29
|
+
opt.on('-m', '--mode=mode', 'Run mode' ) {|v| mode = v }
|
30
|
+
opt.on('-f', '--file=file', 'File to load' ) {|v| load_file = v }
|
31
|
+
opt.on('-p', '--pattern=pattern', 'Pattern of target files' ) {|v| pattern = v }
|
32
|
+
opt.on('-i', '--interval=interval', 'Interval of check files' ) {|v| interval = v }
|
33
|
+
opt.on('-d', '--debug', 'Enable debug mode' ) {|v| debug = true }
|
34
|
+
opt.parse!(ARGV)
|
35
|
+
end
|
36
|
+
|
37
|
+
begin
|
38
|
+
unless mode || load_file
|
39
|
+
require 'sample'
|
40
|
+
else
|
41
|
+
require mode if mode
|
42
|
+
load load_file if load_file && File.exist?(load_file)
|
35
43
|
end
|
44
|
+
load config_file if config_file && File.exist?(config_file)
|
45
|
+
rescue LoadError => e
|
46
|
+
puts e
|
47
|
+
exit!
|
36
48
|
end
|
37
49
|
|
38
50
|
Observer.run(:pattern => pattern, :interval => interval, :debug => debug)
|
data/lib/filetter/version.rb
CHANGED
data/lib/modes/mozrepl.rb
CHANGED
@@ -1,9 +1,18 @@
|
|
1
1
|
require 'net/telnet'
|
2
|
+
|
3
|
+
config.mozrepl.set_default(:host, 'localhost')
|
4
|
+
config.mozrepl.set_default(:port, 4242)
|
5
|
+
config.mozrepl.set_default(:commands, ['content.location.reload(true)'])
|
6
|
+
|
2
7
|
Filetter.add_hook do |files, event|
|
3
|
-
telnet = Net::Telnet.new(
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
8
|
+
telnet = Net::Telnet.new( "Host" => config.mozrepl.host,
|
9
|
+
"Port" => config.mozrepl.port ) {|c| print c }
|
10
|
+
begin
|
11
|
+
config.mozrepl.commands.each do |cmd|
|
12
|
+
puts "> #{cmd}"
|
13
|
+
telnet.puts(cmd)
|
14
|
+
end
|
15
|
+
ensure
|
16
|
+
telnet.close
|
17
|
+
end
|
9
18
|
end
|