auto_reloader 0.2.1 → 0.2.2

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: 16551c2344afe661a841af495ae36fc631de4c4c
4
- data.tar.gz: cda47b63ff8f825edac189b39d1ef6bbb1edd093
3
+ metadata.gz: feb71c3d0ec8e2a360b148d65768c855f37ce7b5
4
+ data.tar.gz: 91ea374ea7eeeacf2b94ae520fc550521db55aca
5
5
  SHA512:
6
- metadata.gz: d6b94516fd14447ccdc77e2c26a40e85b4f64ea33353a8c833333612be4c7e88e09d028f658e3bbdd075159c4a4103e330f1197eb5345b941a4ad4ba82385fbf
7
- data.tar.gz: 3db77d13f21fffeb66cc90cd887306284d5123f0433f93589242224805fc1e7b37dd8e2f147a9c3ede24d5ffccd639ec1e6261818cc05b554039cb85f002357f
6
+ metadata.gz: b8763aad06e1b64d02921ed6565151bf4335c5dfc590e000215993ecc8f82c44dae50e98c95af474b71b47727419a7592d51c91250b496465c12894ea5566cc5
7
+ data.tar.gz: ac7e93fbfa390bc686dd5cea7bf8b4dc0adc71e3b3062cf791af493bba4d98eeec8c572946c32d38adc948a478d9f943d64d7a80ab204161e4d90a30a7e89520
data/.rspec CHANGED
@@ -1,3 +1,2 @@
1
1
  --format documentation
2
2
  --color
3
- --order default
data/.travis.yml CHANGED
@@ -3,3 +3,5 @@ rvm:
3
3
  - 2.3.1
4
4
  - jruby-9.1.2.0
5
5
  before_install: gem install bundler -v 1.11.2
6
+ env:
7
+ - WATCH_SLEEP_TIME=3
data/lib/auto_reloader.rb CHANGED
@@ -88,12 +88,12 @@ class AutoReloader
88
88
  end
89
89
 
90
90
  InvalidUsage = Class.new RuntimeError
91
- def reload!(delay: default_delay, onchange: default_onchange)
91
+ def reload!(delay: default_delay, onchange: default_onchange, watch_paths: @watch_paths)
92
92
  if onchange && !block_given?
93
93
  raise InvalidUsage, 'A block must be provided to reload! when onchange is true (the default)'
94
94
  end
95
95
 
96
- unload! unless reload_ignored = ignore_reload?(delay, onchange)
96
+ unload! unless reload_ignored = ignore_reload?(delay, onchange, watch_paths)
97
97
 
98
98
  result = nil
99
99
  if block_given?
@@ -108,7 +108,7 @@ class AutoReloader
108
108
  @force_reload = false
109
109
  @reload_lock.synchronize do
110
110
  @unload_files.each{|f| $LOADED_FEATURES.delete f }
111
- @unload_constants.each{|c| Object.send :remove_const, c }
111
+ @unload_constants.each{|c| safe_remove_constant c }
112
112
  @unload_files = Set.new
113
113
  @unload_constants = Set.new
114
114
  end
@@ -153,13 +153,13 @@ class AutoReloader
153
153
  @reloadable_paths.any?{|rp| fullpath.start_with? rp}
154
154
  end
155
155
 
156
- def ignore_reload?(delay, onchange)
156
+ def ignore_reload?(delay, onchange, watch_paths = @watch_paths)
157
157
  return false if @force_reload
158
- (delay && (clock_time - @last_reloaded < delay)) || (onchange && !changed?)
158
+ (delay && (clock_time - @last_reloaded < delay)) || (onchange && !changed?(watch_paths))
159
159
  end
160
160
 
161
- def changed?
162
- return false if @watch_paths && !@paths_changed
161
+ def changed?(watch_paths = @watch_paths)
162
+ return false if watch_paths && !@paths_changed
163
163
  @paths_changed = false
164
164
  return true unless @last_mtime_by_path
165
165
  @reload_lock.synchronize do
@@ -178,4 +178,9 @@ class AutoReloader
178
178
  end
179
179
  @last_mtime_by_path
180
180
  end
181
+
182
+ def safe_remove_constant(constant)
183
+ Object.send :remove_const, constant
184
+ rescue NameError # ignore if it has been already removed
185
+ end
181
186
  end
@@ -1,3 +1,3 @@
1
1
  class AutoReloader
2
- VERSION = '0.2.1'
2
+ VERSION = '0.2.2'
3
3
  end
metadata CHANGED
@@ -1,72 +1,72 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auto_reloader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Rosenfeld Rosas
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-17 00:00:00.000000000 Z
11
+ date: 2016-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: bundler
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
16
  - - "~>"
18
17
  - !ruby/object:Gem::Version
19
18
  version: '1.11'
20
- type: :development
19
+ name: bundler
21
20
  prerelease: false
21
+ type: :development
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.11'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
30
  - - "~>"
32
31
  - !ruby/object:Gem::Version
33
32
  version: '10.0'
34
- type: :development
33
+ name: rake
35
34
  prerelease: false
35
+ type: :development
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: rspec
43
42
  requirement: !ruby/object:Gem::Requirement
44
43
  requirements:
45
44
  - - "~>"
46
45
  - !ruby/object:Gem::Version
47
46
  version: '3.0'
48
- type: :development
47
+ name: rspec
49
48
  prerelease: false
49
+ type: :development
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: listen
57
56
  requirement: !ruby/object:Gem::Requirement
58
57
  requirements:
59
58
  - - "~>"
60
59
  - !ruby/object:Gem::Version
61
60
  version: '3.0'
62
- type: :development
61
+ name: listen
63
62
  prerelease: false
63
+ type: :development
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '3.0'
69
- description:
69
+ description:
70
70
  email:
71
71
  - rr.rosas@gmail.com
72
72
  executables: []
@@ -89,7 +89,7 @@ homepage: https://github.com/rosenfeld/auto_reloader
89
89
  licenses:
90
90
  - MIT
91
91
  metadata: {}
92
- post_install_message:
92
+ post_install_message:
93
93
  rdoc_options: []
94
94
  require_paths:
95
95
  - lib
@@ -104,9 +104,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  - !ruby/object:Gem::Version
105
105
  version: '0'
106
106
  requirements: []
107
- rubyforge_project:
108
- rubygems_version: 2.5.1
109
- signing_key:
107
+ rubyforge_project:
108
+ rubygems_version: 2.6.4
109
+ signing_key:
110
110
  specification_version: 4
111
111
  summary: A transparent code reloader.
112
112
  test_files: []