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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba4a09d3953bfde28a2af58974520277a6586f66
4
- data.tar.gz: fbf78f768bb8ea66ec1ca341f74ecae6fe0c207c
3
+ metadata.gz: 10d211ee236cf788def54e33a156ea5e7c6d7ba0
4
+ data.tar.gz: 0f4e6c959bcaa7d4ff5a097370dc2938d3e1598a
5
5
  SHA512:
6
- metadata.gz: c307052c4138e40de2855ace66cb2c5369771ce2aadaa8366cb4bf146dde3e8fc59733fd37a79b2a72f47a0692485d68d62681816e46245f992fd41c7a3694d6
7
- data.tar.gz: 40fd961e6b85db733047235bef5099fe5d9a2e18492845495c94e98307d000c9047ed564532b552b617db7b55bb2698f6d31d6d91c03a3a94d3036f212cfa562
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
 
@@ -1,3 +1,3 @@
1
1
  class AutoReloader
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
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
- @delay = delay
37
- @onchange = onchange
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!(*args)
89
+ def self.reload!(delay: instance.default_delay, onchange: instance.default_onchange)
90
90
  if block_given?
91
- instance.reload!(*args){ yield }
91
+ instance.reload!(delay: delay, onchange: onchange){ yield }
92
92
  else
93
- instance.reload!(*args)
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: @default_delay, onchange: @default_onchange)
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?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auto_reloader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rodrigo Rosenfeld Rosas