jugyo-filetter 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -14,7 +14,7 @@ Thread.abort_on_exception = true
14
14
 
15
15
  module Filetter
16
16
  class << self
17
- def run
17
+ def run(options)
18
18
  pattern = './**/*'
19
19
  interval = 1
20
20
  debug = false
@@ -67,7 +67,7 @@ module Filetter
67
67
  exit!
68
68
  end
69
69
 
70
- Observer.run(:pattern => pattern, :interval => interval, :debug => debug)
70
+ Observer.run({:pattern => pattern, :interval => interval, :debug => debug}.merge(options))
71
71
  end
72
72
 
73
73
  def add_hook(*args, &block)
@@ -33,8 +33,8 @@ module Filetter
33
33
  self.__send__("#{k.to_s}=".to_sym, v) if self.respond_to?(k)
34
34
  end
35
35
 
36
- puts "=> initializing. please wait..."
37
- collect_files(true)
36
+ puts "=> initializing..."
37
+ collect_files
38
38
 
39
39
  @input_thread = Thread.new do
40
40
  Readline.completion_proc = lambda {|input|
@@ -50,11 +50,12 @@ module Filetter
50
50
  end
51
51
  end
52
52
 
53
- sleep interval
53
+ sleep @interval
54
54
 
55
55
  @observe_thread = Thread.new do
56
56
  while @work
57
57
  begin
58
+ puts 'checking files...' if debug
58
59
  check_files
59
60
  rescue => e
60
61
  handle_error(e)
@@ -87,18 +88,17 @@ module Filetter
87
88
 
88
89
  private
89
90
 
90
- def collect_files(init = false)
91
+ def collect_files
91
92
  real_files = Pathname.glob(@pattern).map do |i|
92
- if init || debug
93
+ if debug
93
94
  print "\e[1K\e[0G#{i.basename.to_s}"
94
95
  $stdout.flush
95
96
  end
96
97
  i.realpath
97
98
  end
98
99
 
99
- if init || debug
100
+ if debug
100
101
  print "\e[1K\e[0G"
101
- print @prompt unless init
102
102
  $stdout.flush
103
103
  end
104
104
 
@@ -1,4 +1,4 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  module Filetter
3
- VERSION = '0.2.2'
3
+ VERSION = '0.2.3'
4
4
  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.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - jugyo