require_tree 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ingwen.rb +19 -10
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f18df98516b96f9ba0477750e149966f2a53bca
4
- data.tar.gz: 3b64077fee8fead14413d80c1b1d4cb2e386e28b
3
+ metadata.gz: a2b66d39a47740882c39cbd5eac4c853cae297e8
4
+ data.tar.gz: 26bc7ff4dfd9ce42f3612f7f1cde8ea862c8658d
5
5
  SHA512:
6
- metadata.gz: db31b55c2a565c9ad6d8a267c2769fd71b9bc4ee93c947540ee03682b8b0b5589560cac9955233962aa6925cacfcf56bdceae4065afda39e80ae67fc2a809274
7
- data.tar.gz: 34772bf4adb236143ea45ca03618ef2ed1a90e76cccd97749af02b2cb38fcc76544b3a16cdd90510b3c4875b20edcb0b6468bb79f559dccd3a899a9c1286b0b8
6
+ metadata.gz: 6579b81f5554b4ea7d3301d9c5d0a8ac1909a0523df657c0cce297684ad1feadc6e291ab1051188cfb8229bae13d788f3c518cf37fc4e14dc35cf176c31a10c4
7
+ data.tar.gz: a94a72c96d0da157cf98a9bc235c9872a1cf3d181895df132c6378a83cf8d468ba1b1dea3c66ec39586211a412778890fc550ba3fbf76b4a0ea1b6b63e9a7082
data/lib/ingwen.rb CHANGED
@@ -1,18 +1,27 @@
1
1
  module Kernel
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
2
+ def require_tree path, opt={}
3
+ force = opt[:force] || false
4
+ caller_file = caller_locations.first.absolute_path
5
+ caller_path = caller_file + '/..'
6
+ if force
7
+ rb_files_queue = []
8
+ parse_path_f path, caller_path, rb_files_queue
9
+ rb_files_queue.delete caller_file
10
+ try_and_error rb_files_queue
11
+ else
12
+
13
+ end
6
14
  end
7
15
 
8
16
  private
9
- def parse_path path, base, queue
10
- Dir["#{base}/#{path}/*"].each {|path|
17
+ def parse_path_f path, base, queue
18
+ full_path = path == '.' ? "#{base}/*" : "#{base}/#{path}/*"
19
+ Dir[full_path].each {|sym|
11
20
  begin
12
- if File.directory? path
13
- parse_path '.', path, queue
14
- elsif path =~ /\.rb$/
15
- queue << path
21
+ if File.directory? sym
22
+ parse_path_f '.', sym, queue
23
+ elsif sym =~ /\.rb$/
24
+ queue << sym
16
25
  end
17
26
  end
18
27
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: require_tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim.W