require_tree 0.1.3 → 0.1.4

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ingwen.rb +34 -17
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e1c653606568d0a21f9eb0c80be12d190786a3da
4
- data.tar.gz: 0198abb262969fcf67df8e7f0839f6af60d4a837
3
+ metadata.gz: 91307a976948eda0cf1a25f543953c4470551efd
4
+ data.tar.gz: fad0c347cb1feb17451d87b10a1abd8cf3808abd
5
5
  SHA512:
6
- metadata.gz: 3c8535f35141bf3eb18d44f0832075f25f45e3cdafa1e3fda2afad84845cc514d46e7993b7bc750711549e96b365f24591dddc1eb7ec230b0e502b4cec97f982
7
- data.tar.gz: 03c2d0edd2462affe9cdaec043652369e6f6975d48054967c732c578de71994fc4830ab04506882a030f61cc38d06c9a35fde830f14433fd549e5a144c8bc5cb
6
+ metadata.gz: d576b40217bad0f923a40b580452abe769413912fb4ea56a994eba3a5a41cad748322ab1a674886aea0c9b2716cfcf8b9edf16dc1278eace973128d95307f9d1
7
+ data.tar.gz: d1e5baa26cf4601c299cd1e6c38274dfc9a65130276a07dad684d48488ae269fd62ad9ce9490a66bfbbc73c13138f37d8023449fbc45408c68904d14df3c3eb5
@@ -1,31 +1,48 @@
1
+
1
2
  module Kernel
2
3
  def require_tree path, opt={}
3
4
  force = opt[:force] || false
4
5
  debug = opt[:debug] || false
5
6
  caller_file = caller_locations.first.absolute_path
6
7
  caller_path = caller_file + '/..'
7
- if force
8
- rb_files_queue = []
9
- parse_path_f path, caller_path, rb_files_queue
10
- rb_files_queue.delete caller_file
11
- try_and_error rb_files_queue, debug: debug
12
- else
13
-
14
- end
8
+ rb_files_queue = []
9
+ parse_path_f path: path, base: caller_path, queue: rb_files_queue, force: force
10
+ rb_files_queue.delete caller_file
11
+ try_and_error rb_files_queue, debug: debug
15
12
  end
16
13
 
17
14
  private
18
- def parse_path_f path, base, queue
15
+ def parse_path_f opt={}
16
+ path = opt[:path]
17
+ base = opt[:base]
18
+ queue = opt[:queue]
19
+ force = opt[:force]
19
20
  full_path = path == '.' ? "#{base}/*" : "#{base}/#{path}/*"
20
- Dir[full_path].each {|sym|
21
- begin
22
- if File.directory? sym
23
- parse_path_f '.', sym, queue
24
- elsif sym =~ /\.rb$/
25
- queue << sym
21
+ if force
22
+ Dir[full_path].each {|sym|
23
+ begin
24
+ if File.directory? sym
25
+ parse_path_f path: '.', base: sym, queue: queue
26
+ elsif sym =~ /\.rb$/
27
+ queue << sym
28
+ end
26
29
  end
27
- end
28
- }
30
+ }
31
+ else
32
+ folders = []
33
+ Dir[full_path].each {|sym|
34
+ begin
35
+ if File.directory? sym
36
+ folders << sym
37
+ elsif sym =~ /\.rb$/
38
+ queue << sym
39
+ end
40
+ end
41
+ }
42
+ folders.each {|sym|
43
+ parse_path_f path: '.', base: sym, queue: queue
44
+ }
45
+ end
29
46
  end
30
47
 
31
48
  def try_and_error queue, opt={}
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: require_tree
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim.W
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-16 00:00:00.000000000 Z
11
+ date: 2018-01-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: require all files in given relative path!
14
14
  email: aaasdslee@gmail.com