monkey-reloader 0.0.4 → 0.0.5

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: 716dbb88b043f708ffe48d905278539914757e28
4
- data.tar.gz: 82a60e131266fd7e18fe91c0fe457fc6a015c758
3
+ metadata.gz: 69478d7f3571aac4cc17a941339d77e4df81e4d3
4
+ data.tar.gz: b78e13ca9d6707e2ec4bd4fa2b180f37590fe579
5
5
  SHA512:
6
- metadata.gz: 53597bcdc89edf732809b4ec440958adcc31042afc1d1c9aff7c7c82538c41b9394d0c1e2daad8c8e068f97b422c79744e72a364ba8b69937799ca42b5eb9694
7
- data.tar.gz: 532dbb52c91ba348339385a96449c930db2c50479e770ddca0247c26799f7afda6dcf0259f85df4d4bd8c87cb59cb246da366971129844ed702df8d492dc5a9f
6
+ metadata.gz: c5a00cf25711e19ff714893e7fd5e5baba0680ada1f1978c820e81f072af6b7040d4c10b8bbcb304bf7d60daea9e408f9dc6212effa85f7d643a02b42dd6f02a
7
+ data.tar.gz: 41bf48c835532532cfe53cc47d7ee59100f2c8662a71b56a8c3f69272a5dbf813433d347c5fed598cba6f27f80252dc4933af36223055423ff8cd9b0f84f484c
@@ -1,3 +1,3 @@
1
1
  module MonkeyReloader
2
- VERSION = "0.0.4"
2
+ VERSION = '0.0.5'
3
3
  end
@@ -10,7 +10,22 @@ module MonkeyReloader
10
10
  @@blacklist = nil
11
11
 
12
12
 
13
- def init(whitelist = [], blacklist = [])
13
+ def config(opts = {})
14
+ whitelist = opts[:whitelist]
15
+ if !whitelist or whitelist.empty?
16
+ raise ArgumentError.new 'whitelist expected'
17
+ end
18
+
19
+ blacklist = opts.key?(:blacklist) ? opts[:blacklist] : [
20
+ # by default, block dangerous Rails behavior
21
+ 'bin',
22
+ 'config',
23
+ 'db',
24
+ 'log',
25
+ 'script',
26
+ 'spec',
27
+ ].select {|dir| Dir.exists? dir}
28
+
14
29
  @@whitelist = Set.new
15
30
  self.whitelist whitelist
16
31
 
@@ -23,6 +38,7 @@ module MonkeyReloader
23
38
  end
24
39
 
25
40
  def load
41
+ # reload all changed files
26
42
  wlist = whitelist
27
43
  blist = blacklist
28
44
 
@@ -37,9 +53,6 @@ module MonkeyReloader
37
53
 
38
54
  files.each do |file|
39
55
  Kernel.load file
40
- end.map do |file|
41
- # map back to relative pathnames for convenience
42
- Pathname.new(file).relative_path_from(pwd).to_s
43
56
  end
44
57
  end
45
58
 
@@ -79,10 +92,16 @@ module MonkeyReloader
79
92
  end
80
93
 
81
94
  def expand_paths(paths = [])
82
- # recalculate path expansions - caching will miss filesystem changes
95
+ # recalculate path expansions, but keep relative paths.
96
+ # note that caching will miss filesystem changes
97
+
98
+ pwd = Pathname.new Dir.pwd
83
99
  Array(paths).map do |path|
84
100
  Dir[path]
85
- end.flatten
101
+ end.flatten.map do |path|
102
+ # map back to relative paths
103
+ Pathname.new(path).relative_path_from(pwd).to_s
104
+ end
86
105
  end
87
106
 
88
107
  def update_hash
@@ -106,8 +125,6 @@ module MonkeyReloader
106
125
  # a branch change
107
126
  files.select do |file|
108
127
  /\.rb$/.match file and File.exists? file
109
- end.map do |file|
110
- File.expand_path file
111
128
  end
112
129
  end
113
130
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: monkey-reloader
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Pepper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-12-14 00:00:00.000000000 Z
11
+ date: 2016-12-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  fast IRB reloading for non-conventional file naming, using git