dircrawl 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dircrawl.rb +11 -3
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7e5690898b1e1871c98dadfd82f32cfbd585581
|
4
|
+
data.tar.gz: c6acafff26cd8e707d76e36c47b1af392d396272
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fbb96bf938b8547ad4e4374fa0267ca6a2d4fef55c471c21abc2186d89ac6851cbc3455cd3aea7373e761b5e01f377e97f310d3770ce2982dd537e9c745c941
|
7
|
+
data.tar.gz: 8fab044c5e6c59c6161e04c7a36602454999b03e4ecc743fc739740aea87d944a21824375a75f2d044e8c4074e1bd612ccf0a3e56fcf8863abf413806fd89b67
|
data/lib/dircrawl.rb
CHANGED
@@ -2,12 +2,13 @@ require 'json'
|
|
2
2
|
require 'pry'
|
3
3
|
|
4
4
|
class DirCrawl
|
5
|
-
def initialize(path, output_dir, ignore_includes, save, process_block, include_block, *args)
|
6
|
-
|
5
|
+
def initialize(path, output_dir, ignore_includes, save, process_block, include_block, extras_block, *args)
|
6
|
+
@path = path
|
7
7
|
@output_dir = output_dir
|
8
8
|
@ignore_includes = ignore_includes
|
9
9
|
include_block.call
|
10
10
|
@process_block = process_block
|
11
|
+
@extras_block = extras_block
|
11
12
|
@output = Array.new
|
12
13
|
@save = save
|
13
14
|
crawl_dir(path, *args)
|
@@ -40,6 +41,14 @@ class DirCrawl
|
|
40
41
|
|
41
42
|
# Process file
|
42
43
|
elsif !file.include?(@ignore_includes)
|
44
|
+
|
45
|
+
# Create Dirs
|
46
|
+
create_write_dirs(dir.gsub(@path, @output_dir))
|
47
|
+
|
48
|
+
# Process Extras
|
49
|
+
extras = @extras_block.call(@output_dir+"/")
|
50
|
+
|
51
|
+
# Process Main
|
43
52
|
processed = @process_block.call(dir+"/"+file, *args)
|
44
53
|
|
45
54
|
# Only save in output if specified (to handle large dirs)
|
@@ -48,7 +57,6 @@ class DirCrawl
|
|
48
57
|
end
|
49
58
|
|
50
59
|
# Write to file
|
51
|
-
create_write_dirs(dir.gsub(@path, @output_dir))
|
52
60
|
File.write(get_write_dir(dir, file), processed)
|
53
61
|
end
|
54
62
|
end
|