filetter 0.2.7 → 0.2.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -58,5 +58,9 @@ Default file to load is '.filetter' in the current directory if exist.
58
58
 
59
59
  == INSTALL:
60
60
 
61
+ sudo gem install filetter
62
+
63
+ or
64
+
61
65
  gem source -a http://gems.github.com
62
66
  sudo gem install jugyo-filetter
@@ -14,7 +14,7 @@ Thread.abort_on_exception = true
14
14
  module Filetter
15
15
  class << self
16
16
  def run(options = {})
17
- pattern = './**/*'
17
+ patterns = []
18
18
  interval = 2
19
19
  debug = false
20
20
  mode = nil
@@ -29,7 +29,7 @@ module Filetter
29
29
  opt.on('-m', '--mode=mode', 'Run mode' ) {|v| mode = v }
30
30
  opt.on('-f', '--loadfile=file', 'File to load' ) {|v| load_file = v }
31
31
  opt.on('-c', '--cd=directory', 'cd to directory' ) {|v| work_dir = v }
32
- opt.on('-p', '--pattern=pattern', 'Pattern of target files' ) {|v| pattern = v }
32
+ opt.on('-p', '--pattern=pattern', 'Pattern of target files' ) {|v| patterns << v }
33
33
  opt.on('-i', '--interval=interval', 'Interval of check files', Integer ) {|v| interval = v }
34
34
  opt.on('-d', '--debug', 'Enable debug mode' ) {|v| debug = true }
35
35
  opt.on('-l', '--list', 'List up available modes' ) {|v| list = true }
@@ -42,6 +42,8 @@ module Filetter
42
42
  puts "=> cd to #{work_dir}"
43
43
  end
44
44
 
45
+ patterns << './**/*' if patterns.empty?
46
+
45
47
  begin
46
48
  if mode.nil? && !File.exist?(load_file)
47
49
  if list
@@ -52,8 +54,10 @@ module Filetter
52
54
  exit!
53
55
  end
54
56
  else
55
- puts "=> load \"#{load_file}\""
56
- load load_file
57
+ if File.exist?(load_file)
58
+ puts "=> load \"#{load_file}\""
59
+ load load_file
60
+ end
57
61
  if mode
58
62
  puts "=> Run as \"#{mode}\" mode"
59
63
  require "modes/#{mode}"
@@ -69,7 +73,7 @@ module Filetter
69
73
  exit!
70
74
  end
71
75
 
72
- Observer.run({:pattern => pattern, :interval => interval, :debug => debug}.merge(options))
76
+ Observer.run({:patterns => patterns, :interval => interval, :debug => debug}.merge(options))
73
77
  end
74
78
 
75
79
  def add_hook(*args, &block)
@@ -17,10 +17,10 @@ module Filetter
17
17
  instance.run(options)
18
18
  end
19
19
 
20
- attr_accessor :pattern, :interval, :debug, :prompt
20
+ attr_accessor :patterns, :interval, :debug, :prompt
21
21
 
22
22
  def initialize
23
- @pattern = './**/*'
23
+ @patterns = './**/*'
24
24
  @interval = 1
25
25
  @work = true
26
26
  @file_infos = {}
@@ -90,7 +90,7 @@ module Filetter
90
90
  private
91
91
 
92
92
  def collect_files
93
- real_files = Pathname.glob(@pattern).map do |i|
93
+ real_files = Pathname.glob(@patterns).map do |i|
94
94
  if debug
95
95
  print "\e[1K\e[0G#{i.basename.to_s}"
96
96
  $stdout.flush
@@ -1,4 +1,4 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module Filetter
3
- VERSION = '0.2.7'
3
+ VERSION = '0.2.8'
4
4
  end
@@ -0,0 +1,16 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require File.dirname(__FILE__) + '/spec_helper'
4
+
5
+ module Filetter
6
+ describe Filetter do
7
+ before do
8
+ end
9
+ it 'spec 1' do
10
+ block_for_modify = proc {|files|}
11
+ Filetter.add_hook :modify, &block_for_modify
12
+ Thread.new {Filetter.run}
13
+ block_for_modify.should_receive(:call).with(['test.txt'])
14
+ end
15
+ end
16
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filetter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - jugyo
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-02-22 00:00:00 +09:00
12
+ date: 2009-02-28 00:00:00 +09:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -71,6 +71,7 @@ files:
71
71
  - lib/modes/sample.rb
72
72
  - lib/modes/twitter.rb
73
73
  - spec/filetter/observer_spec.rb
74
+ - spec/filetter_spec.rb
74
75
  - spec/spec_helper.rb
75
76
  - README.rdoc
76
77
  - History.txt