filewatch 0.6.8 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d9bf179bb78fa086471f144cc90404a616076d09
4
- data.tar.gz: e0579d790be4bc6a400f4db10097cf610fbc219a
3
+ metadata.gz: 942a2b016e43afadaa980bf4964646a425ed763a
4
+ data.tar.gz: eed10c3d4d6368803121747a1d9777bc01df7f5f
5
5
  SHA512:
6
- metadata.gz: 49599f9831b7f87285e819f926f5748f318dcd636313968f00013dc62bf969f43fa74e119374de73bc36a9ef7f39f5ec198f15397892a48e605287fdd216b828
7
- data.tar.gz: 80afb0abad3f869aeb7461f7de3d9e9e49b9bbaf010d9c37f4a9803f5cd3d006224aa65d56ac789869a92f0efe974558f16d6f5185566bc686447e09264b8e96
6
+ metadata.gz: bc6dc3c1a2ad58f9e5e34d2d60a73d44c1f6727e698ee13ef6d5dbc72c9d215488577a121dd084c3e6316b435d3f5c98effe631de90d31dd9b3ae4405eebb71a
7
+ data.tar.gz: 8212663fd9cfd801ecf88f214c2d30356c20cc3f29a7af18b0ec1794eca87adbd72e330e7fac744ad36cd86dd6826b90c7cbe83ccfa3af4c263fe2560ee17400
@@ -45,7 +45,6 @@ module FileWatch
45
45
  :discover_interval => 5,
46
46
  :exclude => [],
47
47
  :start_new_files_at => :end,
48
- # :ignore_after => 24 * 60 * 60,
49
48
  :delimiter => "\n"
50
49
  }.merge(opts)
51
50
  if !@opts.include?(:sincedb_path)
@@ -56,7 +55,8 @@ module FileWatch
56
55
  raise NoSinceDBPathGiven.new("No HOME or SINCEDB_PATH set in environment. I need one of these set so I can keep track of the files I am following.")
57
56
  end
58
57
  @watch.exclude(@opts[:exclude])
59
- @watch.ignore_after = @opts[:ignore_after]
58
+ @watch.close_older = @opts[:close_older]
59
+ @watch.ignore_older = @opts[:ignore_older]
60
60
 
61
61
  _sincedb_open
62
62
  end # def initialize
@@ -82,11 +82,11 @@ module FileWatch
82
82
  private
83
83
 
84
84
  def file_expired?(stat)
85
- return false if @opts[:ignore_after].nil?
85
+ return false if @opts[:ignore_older].nil?
86
86
  # (Time.now - stat.mtime) <- in jruby, this does int and float
87
87
  # conversions before the subtraction and returns a float.
88
88
  # so use all ints instead
89
- (Time.now.to_i - stat.mtime.to_i) > @opts[:ignore_after]
89
+ (Time.now.to_i - stat.mtime.to_i) > @opts[:ignore_older]
90
90
  end
91
91
 
92
92
  def _open_file(path, event)
@@ -45,7 +45,7 @@ module FileWatch
45
45
  def to_s() inspect; end
46
46
  end
47
47
 
48
- attr_accessor :logger, :ignore_after
48
+ attr_accessor :logger, :close_older, :ignore_older
49
49
 
50
50
  public
51
51
  def initialize(opts={})
@@ -148,7 +148,7 @@ module FileWatch
148
148
  next
149
149
  end
150
150
 
151
- if expired?(stat, watched_file)
151
+ if file_closable?(stat, watched_file)
152
152
  if !watched_file.timeout_sent?
153
153
  @logger.debug? && @logger.debug("#{path}: file expired")
154
154
  yield(:timeout, path)
@@ -207,20 +207,24 @@ module FileWatch
207
207
  end # def subscribe
208
208
 
209
209
  private
210
- def expired?(stat, watched_file)
211
- file_expired?(stat) && watched_file.size == stat.size
210
+ def file_closable?(stat, watched_file)
211
+ file_can_close?(stat) && watched_file.size == stat.size
212
212
  end
213
213
 
214
- def discover_expired?(stat)
215
- file_expired?(stat)
214
+ def file_ignorable?(stat)
215
+ return false unless expiry_ignore_enabled?
216
+ # (Time.now - stat.mtime) <- in jruby, this does int and float
217
+ # conversions before the subtraction and returns a float.
218
+ # so use all ints instead
219
+ (Time.now.to_i - stat.mtime.to_i) > @ignore_older
216
220
  end
217
221
 
218
- def file_expired?(stat)
219
- return false unless expiry_enabled?
222
+ def file_can_close?(stat)
223
+ return false unless expiry_close_enabled?
220
224
  # (Time.now - stat.mtime) <- in jruby, this does int and float
221
225
  # conversions before the subtraction and returns a float.
222
226
  # so use all ints instead
223
- (Time.now.to_i - stat.mtime.to_i) > @ignore_after
227
+ (Time.now.to_i - stat.mtime.to_i) > @close_older
224
228
  end
225
229
 
226
230
  private
@@ -247,9 +251,13 @@ module FileWatch
247
251
  # let the caller build the object in its context
248
252
  watched_file = yield(file, stat)
249
253
 
250
- if discover_expired?(stat)
251
- msg = "_discover_file: #{file}: skipping because it was last modified more than #{@ignore_after} seconds ago"
254
+ if file_ignorable?(stat)
255
+ msg = "_discover_file: #{file}: skipping because it was last modified more than #{@ignore_older} seconds ago"
252
256
  @logger.debug? && @logger.debug(msg)
257
+ # we update the size on discovery here
258
+ # so the existing contents are not read.
259
+ # because, normally, a newly discovered file will
260
+ # have a watched_file size of zero
253
261
  watched_file.update(stat)
254
262
  end
255
263
 
@@ -258,8 +266,13 @@ module FileWatch
258
266
  end # def _discover_file
259
267
 
260
268
  private
261
- def expiry_enabled?
262
- !@ignore_after.nil?
269
+ def expiry_close_enabled?
270
+ !@close_older.nil?
271
+ end
272
+
273
+ private
274
+ def expiry_ignore_enabled?
275
+ !@ignore_older.nil?
263
276
  end
264
277
 
265
278
  private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filewatch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.8
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jordan Sissel
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-12-21 00:00:00.000000000 Z
12
+ date: 2015-12-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  requirement: !ruby/object:Gem::Requirement