filewatcher 2.0.0.beta2 → 2.0.0.beta3

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
  SHA256:
3
- metadata.gz: cbf8702009840bc579d652246d0a0540b9ce7bcfc29ebf9d94995cf53c1343db
4
- data.tar.gz: 4a2b253229620ae6ed2522a03d46105ce266161d116192615ce0bc3ecb396bf2
3
+ metadata.gz: e1058d188f32d31bdf63775a8ff6655e64de608669630ef775c0e4975d196421
4
+ data.tar.gz: 57406a8b0be947051f295de3d6208faaf4ec60e432edc22a71d1e3b22fb58415
5
5
  SHA512:
6
- metadata.gz: a711c6cfce133aad2892381de2804c4c3fd4f9405d280df85c2c1a496fceb8f77055559637728560ed96afb0cd4588b66a397b331e8006f416ea630501fb27d7
7
- data.tar.gz: ba768df36f5fd263645dfd5421473bd5b54d71472b808fd279ea844d76e517584123314fd1af4d246f056ec088463fccb45106e71cc80404594af9fdfbd68b06
6
+ metadata.gz: d930968943fd907aad26eb150de20fa8d2681223dad1f516f9a27c2c096893bacaa8decd0e4646753f529dbec38bba32dd1b6951b442e2df69f6a01f943116fc
7
+ data.tar.gz: cc8919f9f7036cb7599b22589e5b6abadd7b2674f502eae3e9c70c3e29b72d222356f5569244b63b1524dfd64430fc8617283b1bc0f565fffc91b5299b85980e
data/lib/filewatcher.rb CHANGED
@@ -14,6 +14,15 @@ class Filewatcher
14
14
  attr_accessor :interval
15
15
  attr_reader :keep_watching
16
16
 
17
+ class << self
18
+ def print_version
19
+ system 'ruby -v'
20
+ puts "Filewatcher #{self::VERSION}"
21
+
22
+ super if defined? super
23
+ end
24
+ end
25
+
17
26
  def initialize(unexpanded_filenames, options = {})
18
27
  @unexpanded_filenames = unexpanded_filenames
19
28
  @unexpanded_excluded_filenames = options[:exclude]
@@ -88,19 +97,6 @@ class Filewatcher
88
97
 
89
98
  private
90
99
 
91
- def expand_directories(patterns)
92
- patterns = Array(patterns) unless patterns.is_a? Array
93
- expanded_patterns = patterns.map do |pattern|
94
- pattern = File.expand_path(pattern)
95
- Dir[
96
- File.directory?(pattern) ? File.join(pattern, '**', '*') : pattern
97
- ]
98
- end
99
- expanded_patterns.flatten!
100
- expanded_patterns.uniq!
101
- expanded_patterns
102
- end
103
-
104
100
  def debug(data)
105
101
  @logger.debug "Thread ##{Thread.current.object_id} #{data}"
106
102
  end
@@ -25,8 +25,7 @@ class Filewatcher
25
25
  changes[filename] = :deleted unless self[filename]
26
26
  end
27
27
 
28
- changes.reject! { |_filename, event| event.nil? }
29
- changes
28
+ changes.tap(&:compact!)
30
29
  end
31
30
 
32
31
  # Class for one file from snapshot
@@ -22,25 +22,26 @@ class Filewatcher
22
22
 
23
23
  private
24
24
 
25
- def watching_files
26
- expand_directories(@unexpanded_filenames) - expand_directories(@unexpanded_excluded_filenames)
27
- end
28
-
29
25
  # Takes a snapshot of the current status of watched files.
30
26
  # (Allows avoidance of potential race condition during #finalize)
31
27
  def current_snapshot
32
- Filewatcher::Snapshot.new(watching_files)
28
+ Filewatcher::Snapshot.new(
29
+ expand_directories(@unexpanded_filenames) -
30
+ expand_directories(@unexpanded_excluded_filenames)
31
+ )
33
32
  end
34
33
 
35
- def file_mtime(filename)
36
- return Time.new(0) unless File.exist?(filename)
37
-
38
- result = File.mtime(filename)
39
- if @logger.level <= Logger::DEBUG
40
- debug "File.mtime = #{result.strftime('%F %T.%9N')}"
41
- debug "stat #{filename}: #{self.class.system_stat(filename)}"
34
+ def expand_directories(patterns)
35
+ patterns = Array(patterns) unless patterns.is_a? Array
36
+ expanded_patterns = patterns.map do |pattern|
37
+ pattern = File.expand_path(pattern)
38
+ Dir[
39
+ File.directory?(pattern) ? File.join(pattern, '**', '*') : pattern
40
+ ]
42
41
  end
43
- result
42
+ expanded_patterns.flatten!
43
+ expanded_patterns.uniq!
44
+ expanded_patterns
44
45
  end
45
46
 
46
47
  def file_system_updated?(snapshot = current_snapshot)
@@ -33,7 +33,7 @@ class Filewatcher
33
33
  seconds *= coefficient
34
34
  end
35
35
 
36
- if block_given?
36
+ if block
37
37
  wait_with_block seconds, interval, &block
38
38
  else
39
39
  wait_without_block seconds
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Filewatcher
4
- VERSION = '2.0.0.beta2'
4
+ VERSION = '2.0.0.beta3'
5
5
  end
@@ -48,6 +48,19 @@ describe Filewatcher do
48
48
 
49
49
  let(:processed_files) { watch_run.processed.flat_map(&:keys) }
50
50
 
51
+ describe '.print_version' do
52
+ subject(:method_call) { described_class.print_version }
53
+
54
+ let(:ruby_version_regexp) { 'j?ruby \d+\.\d+\.\d+.*' }
55
+ let(:filewatcher_version_regexp) { "Filewatcher #{Filewatcher::VERSION}" }
56
+
57
+ it do
58
+ expect { method_call }.to output(
59
+ /^#{ruby_version_regexp}\n#{filewatcher_version_regexp}$/
60
+ ).to_stdout_from_any_process
61
+ end
62
+ end
63
+
51
64
  describe '#initialize' do
52
65
  describe 'regular run' do
53
66
  before { watch_run.run }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filewatcher
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0.beta2
4
+ version: 2.0.0.beta3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas Flemming
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-09-20 00:00:00.000000000 Z
12
+ date: 2021-02-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -26,33 +26,47 @@ dependencies:
26
26
  - !ruby/object:Gem::Version
27
27
  version: '2.0'
28
28
  - !ruby/object:Gem::Dependency
29
- name: codecov
29
+ name: gem_toys
30
+ requirement: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - "~>"
33
+ - !ruby/object:Gem::Version
34
+ version: 0.6.1
35
+ type: :development
36
+ prerelease: false
37
+ version_requirements: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - "~>"
40
+ - !ruby/object:Gem::Version
41
+ version: 0.6.1
42
+ - !ruby/object:Gem::Dependency
43
+ name: toys
30
44
  requirement: !ruby/object:Gem::Requirement
31
45
  requirements:
32
46
  - - "~>"
33
47
  - !ruby/object:Gem::Version
34
- version: 0.2.5
48
+ version: 0.11.4
35
49
  type: :development
36
50
  prerelease: false
37
51
  version_requirements: !ruby/object:Gem::Requirement
38
52
  requirements:
39
53
  - - "~>"
40
54
  - !ruby/object:Gem::Version
41
- version: 0.2.5
55
+ version: 0.11.4
42
56
  - !ruby/object:Gem::Dependency
43
- name: rake
57
+ name: codecov
44
58
  requirement: !ruby/object:Gem::Requirement
45
59
  requirements:
46
60
  - - "~>"
47
61
  - !ruby/object:Gem::Version
48
- version: '13.0'
62
+ version: 0.4.3
49
63
  type: :development
50
64
  prerelease: false
51
65
  version_requirements: !ruby/object:Gem::Requirement
52
66
  requirements:
53
67
  - - "~>"
54
68
  - !ruby/object:Gem::Version
55
- version: '13.0'
69
+ version: 0.4.3
56
70
  - !ruby/object:Gem::Dependency
57
71
  name: rspec
58
72
  requirement: !ruby/object:Gem::Requirement
@@ -73,14 +87,14 @@ dependencies:
73
87
  requirements:
74
88
  - - "~>"
75
89
  - !ruby/object:Gem::Version
76
- version: 0.91.0
90
+ version: '1.3'
77
91
  type: :development
78
92
  prerelease: false
79
93
  version_requirements: !ruby/object:Gem::Requirement
80
94
  requirements:
81
95
  - - "~>"
82
96
  - !ruby/object:Gem::Version
83
- version: 0.91.0
97
+ version: '1.3'
84
98
  - !ruby/object:Gem::Dependency
85
99
  name: rubocop-performance
86
100
  requirement: !ruby/object:Gem::Requirement
@@ -101,14 +115,14 @@ dependencies:
101
115
  requirements:
102
116
  - - "~>"
103
117
  - !ruby/object:Gem::Version
104
- version: '1.43'
118
+ version: '2.0'
105
119
  type: :development
106
120
  prerelease: false
107
121
  version_requirements: !ruby/object:Gem::Requirement
108
122
  requirements:
109
123
  - - "~>"
110
124
  - !ruby/object:Gem::Version
111
- version: '1.43'
125
+ version: '2.0'
112
126
  description: Detect changes in file system. Works anywhere.
113
127
  email:
114
128
  - thomas.flemming@gmail.com
@@ -139,16 +153,19 @@ require_paths:
139
153
  - lib
140
154
  required_ruby_version: !ruby/object:Gem::Requirement
141
155
  requirements:
142
- - - "~>"
156
+ - - ">="
143
157
  - !ruby/object:Gem::Version
144
158
  version: '2.4'
159
+ - - "<"
160
+ - !ruby/object:Gem::Version
161
+ version: '4'
145
162
  required_rubygems_version: !ruby/object:Gem::Requirement
146
163
  requirements:
147
164
  - - ">"
148
165
  - !ruby/object:Gem::Version
149
166
  version: 1.3.1
150
167
  requirements: []
151
- rubygems_version: 3.1.2
168
+ rubygems_version: 3.2.3
152
169
  signing_key:
153
170
  specification_version: 4
154
171
  summary: Lightweight filewatcher.