require_tree 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ingwen.rb +29 -6
- 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: 7f18df98516b96f9ba0477750e149966f2a53bca
|
4
|
+
data.tar.gz: 3b64077fee8fead14413d80c1b1d4cb2e386e28b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: db31b55c2a565c9ad6d8a267c2769fd71b9bc4ee93c947540ee03682b8b0b5589560cac9955233962aa6925cacfcf56bdceae4065afda39e80ae67fc2a809274
|
7
|
+
data.tar.gz: 34772bf4adb236143ea45ca03618ef2ed1a90e76cccd97749af02b2cb38fcc76544b3a16cdd90510b3c4875b20edcb0b6468bb79f559dccd3a899a9c1286b0b8
|
data/lib/ingwen.rb
CHANGED
@@ -1,11 +1,34 @@
|
|
1
1
|
module Kernel
|
2
|
-
def require_tree path
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
def require_tree path
|
3
|
+
rb_files_queue = []
|
4
|
+
parse_path path, Dir.pwd, rb_files_queue
|
5
|
+
try_and_error rb_files_queue
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
def parse_path path, base, queue
|
10
|
+
Dir["#{base}/#{path}/*"].each {|path|
|
11
|
+
begin
|
12
|
+
if File.directory? path
|
13
|
+
parse_path '.', path, queue
|
14
|
+
elsif path =~ /\.rb$/
|
15
|
+
queue << path
|
16
|
+
end
|
8
17
|
end
|
9
18
|
}
|
10
19
|
end
|
20
|
+
|
21
|
+
def try_and_error queue
|
22
|
+
max_count = queue.count
|
23
|
+
loaded = []
|
24
|
+
queue.each_with_index do |file, i|
|
25
|
+
begin
|
26
|
+
require file
|
27
|
+
loaded << file
|
28
|
+
rescue Exception => e
|
29
|
+
next
|
30
|
+
end
|
31
|
+
end
|
32
|
+
try_and_error(queue - loaded) if loaded.count > 0
|
33
|
+
end
|
11
34
|
end
|