listen 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,62 @@
1
+ require 'spec_helper'
2
+
3
+ describe Listen::Silencer do
4
+ let(:silencer) { Listen::Silencer.new(options) }
5
+
6
+ describe "#silenced?" do
7
+ let(:options) { {} }
8
+ let(:pwd) { Pathname.new(Dir.pwd) }
9
+
10
+ context "default ignore" do
11
+ Listen::Silencer::DEFAULT_IGNORED_DIRECTORIES.each do |dir|
12
+ let(:path) { pwd.join(dir) }
13
+
14
+ it "silences default ignored directory: #{dir}" do
15
+ expect(silencer.silenced?(path)).to be_true
16
+ end
17
+ end
18
+
19
+ Listen::Silencer::DEFAULT_IGNORED_EXTENSIONS.each do |extension|
20
+ let(:path) { pwd.join(extension) }
21
+
22
+ it "silences default ignored extension: #{extension}" do
23
+ expect(silencer.silenced?(path)).to be_true
24
+ end
25
+ end
26
+ end
27
+
28
+ context "with ignore options" do
29
+ let(:options) { { ignore: [%r{foo/bar}, /\.pid$/] } }
30
+
31
+ it "silences custom ignored directory" do
32
+ path = pwd.join('foo', 'bar')
33
+ expect(silencer.silenced?(path)).to be_true
34
+ end
35
+
36
+ it "silences custom ignored extension" do
37
+ path = pwd.join('foo.pid')
38
+ expect(silencer.silenced?(path)).to be_true
39
+ end
40
+ end
41
+
42
+ context "with ignore! options" do
43
+ let(:options) { { ignore!: %r{foo/bar} } }
44
+
45
+ it "silences custom ignored directory" do
46
+ path = pwd.join('foo', 'bar')
47
+ expect(silencer.silenced?(path)).to be_true
48
+ end
49
+
50
+ it "doesn't silence default ignored directory" do
51
+ path = pwd.join(Listen::Silencer::DEFAULT_IGNORED_DIRECTORIES.first)
52
+ expect(silencer.silenced?(path)).to be_false
53
+ end
54
+ end
55
+
56
+ it "doesn't silence normal path" do
57
+ path = pwd.join('some_dir', 'some_file.rb')
58
+ expect(silencer.silenced?(path)).to be_false
59
+ end
60
+ end
61
+
62
+ end
@@ -0,0 +1,10 @@
1
+ require 'spec_helper'
2
+
3
+ describe Listen do
4
+ describe '#to' do
5
+ it "initalizes listner" do
6
+ expect(Listen::Listener).to receive(:new).with('/path')
7
+ described_class.to('/path')
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,34 @@
1
+ require 'rubygems'
2
+ require 'listen'
3
+
4
+ def ci?; ENV['CI'] end
5
+
6
+ if ci?
7
+ require 'coveralls'
8
+ Coveralls.wear!
9
+ end
10
+
11
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
12
+
13
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
14
+ RSpec.configure do |config|
15
+ config.color_enabled = true
16
+ config.order = :random
17
+ config.filter_run focus: true
18
+ config.treat_symbols_as_metadata_keys_with_true_values = true
19
+ config.run_all_when_everything_filtered = true
20
+ config.fail_fast = !ci?
21
+ config.expect_with :rspec do |c|
22
+ c.syntax = :expect
23
+ end
24
+ end
25
+
26
+
27
+ # Crash loud in tests!
28
+ Thread.abort_on_exception = true
29
+ Celluloid.logger.level = Logger::ERROR
30
+
31
+ require 'rspec/retry'
32
+ RSpec.configure do |config|
33
+ config.default_retry_count = ci? ? 3 : 1
34
+ end
@@ -0,0 +1,45 @@
1
+ def listen
2
+ sleep 0.25 # wait for changes
3
+ sleep_until_next_second
4
+ reset_changes
5
+ yield
6
+ sleep 0.25 # wait for changes
7
+ @changes
8
+ end
9
+
10
+ def setup_listener(options, callback)
11
+ reset_changes
12
+ Listen.to(paths, options, &callback)
13
+ end
14
+
15
+ def reset_changes
16
+ @changes = { modified: [], added: [], removed: [] }
17
+ end
18
+
19
+ def add_changes(type, changes)
20
+ @changes[type] += relative_path(changes)
21
+ @changes[type].sort!
22
+ end
23
+
24
+ def relative_path(changes)
25
+ changes.map do |change|
26
+ [paths].flatten.each { |path| change.gsub!(%r{#{path.to_s}/}, '') }
27
+ change
28
+ end
29
+ end
30
+
31
+ # Generates a small time difference before performing a time sensitive
32
+ # task (like comparing mtimes of files).
33
+ #
34
+ # @note Modification time for files only includes the milliseconds on Linux with MRI > 1.9.2
35
+ # and platform that support it (OS X 10.8 not included),
36
+ # that's why we generate a difference that's greater than 1 second.
37
+ #
38
+ def sleep_until_next_second
39
+ return unless darwin?
40
+
41
+ t = Time.now
42
+ diff = t.to_f - t.to_i
43
+
44
+ sleep(1.05 - diff)
45
+ end
@@ -0,0 +1,13 @@
1
+ RSpec.configuration.before(:each) do
2
+ Celluloid.logger = nil
3
+ Celluloid.shutdown
4
+ Celluloid.boot
5
+ if RUBY_PLATFORM != "java"
6
+ class Celluloid::ActorProxy
7
+ unless @rspec_compatible
8
+ @rspec_compatible = true
9
+ undef_method :should_receive
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,27 @@
1
+ require 'tmpdir'
2
+
3
+ include FileUtils
4
+
5
+ # Prepares temporary fixture-directories and
6
+ # cleans them afterwards.
7
+ #
8
+ # @param [Fixnum] number_of_directories the number of fixture-directories to make
9
+ #
10
+ # @yield [path1, path2, ...] the empty fixture-directories
11
+ # @yieldparam [String] path the path to a fixture directory
12
+ #
13
+ def fixtures(number_of_directories = 1)
14
+ current_pwd = pwd
15
+ paths = 1.upto(number_of_directories).map do
16
+ File.expand_path(File.join(pwd, "spec/.fixtures/#{Time.now.to_f.to_s.sub('.', '') + rand(9999).to_s}"))
17
+ end
18
+
19
+ # Create the dirs
20
+ paths.each { |p| mkdir_p(p) }
21
+
22
+ cd(paths.first) if number_of_directories == 1
23
+ yield(*paths)
24
+ ensure
25
+ cd current_pwd
26
+ paths.map { |p| rm_rf(p) if File.exists?(p) }
27
+ end
@@ -0,0 +1,15 @@
1
+ def darwin?
2
+ RbConfig::CONFIG['target_os'] =~ /darwin/i
3
+ end
4
+
5
+ def linux?
6
+ RbConfig::CONFIG['target_os'] =~ /linux/i
7
+ end
8
+
9
+ def bsd?
10
+ RbConfig::CONFIG['target_os'] =~ /freebsd/i
11
+ end
12
+
13
+ def windows?
14
+ RbConfig::CONFIG['target_os'] =~ /mswin|mingw/i
15
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: listen
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thibaud Guillaume-Gentil
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-05 00:00:00.000000000 Z
11
+ date: 2013-10-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: celluloid
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '>='
18
18
  - !ruby/object:Gem::Version
19
- version: 0.15.1
19
+ version: 0.15.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '>='
25
25
  - !ruby/object:Gem::Version
26
- version: 0.15.1
26
+ version: 0.15.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rb-fsevent
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -54,6 +54,20 @@ dependencies:
54
54
  version: '0.9'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: 1.3.5
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: 1.3.5
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
73
  - - '>='
@@ -101,13 +115,25 @@ executables: []
101
115
  extensions: []
102
116
  extra_rdoc_files: []
103
117
  files:
118
+ - .gitignore
119
+ - .rspec
120
+ - .travis.yml
121
+ - .yardopts
122
+ - CHANGELOG.md
123
+ - CONTRIBUTING.md
124
+ - Gemfile
125
+ - Guardfile
126
+ - LICENSE.txt
127
+ - README.md
128
+ - Rakefile
129
+ - lib/listen.rb
130
+ - lib/listen/adapter.rb
104
131
  - lib/listen/adapter/base.rb
105
132
  - lib/listen/adapter/bsd.rb
106
133
  - lib/listen/adapter/darwin.rb
107
134
  - lib/listen/adapter/linux.rb
108
135
  - lib/listen/adapter/polling.rb
109
136
  - lib/listen/adapter/windows.rb
110
- - lib/listen/adapter.rb
111
137
  - lib/listen/change.rb
112
138
  - lib/listen/directory.rb
113
139
  - lib/listen/file.rb
@@ -115,10 +141,27 @@ files:
115
141
  - lib/listen/record.rb
116
142
  - lib/listen/silencer.rb
117
143
  - lib/listen/version.rb
118
- - lib/listen.rb
119
- - CHANGELOG.md
120
- - LICENSE
121
- - README.md
144
+ - listen.gemspec
145
+ - spec/acceptance/listen_spec.rb
146
+ - spec/lib/listen/adapter/base_spec.rb
147
+ - spec/lib/listen/adapter/bsd_spec.rb
148
+ - spec/lib/listen/adapter/darwin_spec.rb
149
+ - spec/lib/listen/adapter/linux_spec.rb
150
+ - spec/lib/listen/adapter/polling_spec.rb
151
+ - spec/lib/listen/adapter/windows_spec.rb
152
+ - spec/lib/listen/adapter_spec.rb
153
+ - spec/lib/listen/change_spec.rb
154
+ - spec/lib/listen/directory_spec.rb
155
+ - spec/lib/listen/file_spec.rb
156
+ - spec/lib/listen/listener_spec.rb
157
+ - spec/lib/listen/record_spec.rb
158
+ - spec/lib/listen/silencer_spec.rb
159
+ - spec/lib/listen_spec.rb
160
+ - spec/spec_helper.rb
161
+ - spec/support/acceptance_helper.rb
162
+ - spec/support/actor_helper.rb
163
+ - spec/support/fixtures_helper.rb
164
+ - spec/support/platform_helper.rb
122
165
  homepage: https://github.com/guard/listen
123
166
  licenses:
124
167
  - MIT
@@ -136,11 +179,31 @@ required_rubygems_version: !ruby/object:Gem::Requirement
136
179
  requirements:
137
180
  - - '>='
138
181
  - !ruby/object:Gem::Version
139
- version: 1.3.6
182
+ version: '0'
140
183
  requirements: []
141
- rubyforge_project: listen
184
+ rubyforge_project:
142
185
  rubygems_version: 2.1.3
143
186
  signing_key:
144
187
  specification_version: 4
145
188
  summary: Listen to file modifications
146
- test_files: []
189
+ test_files:
190
+ - spec/acceptance/listen_spec.rb
191
+ - spec/lib/listen/adapter/base_spec.rb
192
+ - spec/lib/listen/adapter/bsd_spec.rb
193
+ - spec/lib/listen/adapter/darwin_spec.rb
194
+ - spec/lib/listen/adapter/linux_spec.rb
195
+ - spec/lib/listen/adapter/polling_spec.rb
196
+ - spec/lib/listen/adapter/windows_spec.rb
197
+ - spec/lib/listen/adapter_spec.rb
198
+ - spec/lib/listen/change_spec.rb
199
+ - spec/lib/listen/directory_spec.rb
200
+ - spec/lib/listen/file_spec.rb
201
+ - spec/lib/listen/listener_spec.rb
202
+ - spec/lib/listen/record_spec.rb
203
+ - spec/lib/listen/silencer_spec.rb
204
+ - spec/lib/listen_spec.rb
205
+ - spec/spec_helper.rb
206
+ - spec/support/acceptance_helper.rb
207
+ - spec/support/actor_helper.rb
208
+ - spec/support/fixtures_helper.rb
209
+ - spec/support/platform_helper.rb