auto_reloader 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/auto_reloader/version.rb +1 -1
- data/lib/auto_reloader.rb +8 -8
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 10d211ee236cf788def54e33a156ea5e7c6d7ba0
|
4
|
+
data.tar.gz: 0f4e6c959bcaa7d4ff5a097370dc2938d3e1598a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7204e0efb27b81beb4790fdf36f105766816e791ec450dc6f7d076aafb1e76fd1ac2e941394d9f03ac687f48d335c8b8441ba3770144a2b353324c173dfd6ec
|
7
|
+
data.tar.gz: 8b79ba4dfdf0365b652b1eaa0dcb18cb1991c1ec7034819da7b6ebfc020b6fd933a8bb526d1ec01579e6e3b6a2feab65e57d40546148e5cb847922b694566067
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# AutoReloader
|
1
|
+
# AutoReloader [![Build Status](https://travis-ci.org/rosenfeld/auto_reloader.svg?branch=master)](https://travis-ci.org/rosenfeld/auto_reloader)
|
2
2
|
|
3
3
|
AutoReloader is a lightweight code reloader intended to be used specially in development mode of server applications.
|
4
4
|
|
data/lib/auto_reloader.rb
CHANGED
@@ -8,7 +8,7 @@ require 'time' unless defined?(Process::CLOCK_MONOTONIC)
|
|
8
8
|
class AutoReloader
|
9
9
|
include Singleton
|
10
10
|
|
11
|
-
attr_reader :reloadable_paths
|
11
|
+
attr_reader :reloadable_paths, :default_onchange, :default_delay
|
12
12
|
|
13
13
|
module RequireOverride
|
14
14
|
def require(path)
|
@@ -33,8 +33,8 @@ class AutoReloader
|
|
33
33
|
def activate(reloadable_paths: [], onchange: true, delay: nil)
|
34
34
|
@activate_lock.synchronize do
|
35
35
|
raise ActivatedMoreThanOnce, "Can only activate Autoreloader once" if @reloadable_paths
|
36
|
-
@
|
37
|
-
@
|
36
|
+
@default_delay = delay
|
37
|
+
@default_onchange = onchange
|
38
38
|
self.reloadable_paths = reloadable_paths
|
39
39
|
Object.include RequireOverride
|
40
40
|
@require_lock = Monitor.new # monitor is like Mutex, but reentrant
|
@@ -86,21 +86,21 @@ class AutoReloader
|
|
86
86
|
Object.require fullpath
|
87
87
|
end
|
88
88
|
|
89
|
-
def self.reload!(
|
89
|
+
def self.reload!(delay: instance.default_delay, onchange: instance.default_onchange)
|
90
90
|
if block_given?
|
91
|
-
instance.reload!(
|
91
|
+
instance.reload!(delay: delay, onchange: onchange){ yield }
|
92
92
|
else
|
93
|
-
instance.reload!(
|
93
|
+
instance.reload!(delay: delay, onchange: onchange)
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
97
|
InvalidUsage = Class.new RuntimeError
|
98
|
-
def reload!(delay:
|
98
|
+
def reload!(delay: default_delay, onchange: default_onchange)
|
99
99
|
if onchange && !block_given?
|
100
100
|
raise InvalidUsage, 'A block must be provided to reload! when onchange is true (the default)'
|
101
101
|
end
|
102
102
|
|
103
|
-
unload! unless ignore_reload?(delay, onchange)
|
103
|
+
unload! unless reload_ignored = ignore_reload?(delay, onchange)
|
104
104
|
|
105
105
|
result = nil
|
106
106
|
if block_given?
|