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.
@@ -27,28 +27,34 @@ In the future,
27
27
 
28
28
  == SYNOPSIS:
29
29
 
30
- Setup:
30
+ Run:
31
31
 
32
- To set up filetter, put your .filetter file in the current directory.
32
+ filetter -m MODE
33
33
 
34
- .filetter example:
34
+ or (for development)
35
35
 
36
- require 'sample'
36
+ ./bin/debug -m MODE
37
37
 
38
- Run:
38
+ Example:
39
39
 
40
- filetter
40
+ run as 'mozrepl' mode for files named '*.css':
41
41
 
42
- or (for development)
42
+ filetter -m mozrepl -p './**/*.css'
43
43
 
44
- ./bin/debug
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 package is coming soon.
53
- gem パッケージをそのうち用意するよ!)
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 )
@@ -1,16 +1,14 @@
1
1
  # -*- coding: utf-8 -*-
2
- $:.unshift(File.dirname(__FILE__)) unless
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.on('-m mode', 'run mode') {|v| require v } # use mode
26
- opt.on('-f file', 'file to load') {|v| load v } # load user file
27
- opt.on('-p pattern', 'target files pattern') {|v| pattern = v }
28
- opt.on('-i interval', 'check files interval') {|v| interval = v }
29
- opt.on('-d', 'enable debug mode') {|v| debug = true}
30
- begin
31
- opt.parse!(ARGV)
32
- rescue LoadError => e
33
- puts e
34
- exit!
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)
@@ -1,4 +1,4 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module Filetter
3
- VERSION = '0.1.0'
3
+ VERSION = '0.2.0'
4
4
  end
@@ -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
- "Host" => "localhost",
5
- "Port" => 4242
6
- }){|c| print c}
7
- telnet.puts("content.location.reload(true)")
8
- telnet.close
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jugyo-filetter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - jugyo