dircrawl 0.0.12 → 0.0.13
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/dircrawl.rb +24 -17
- 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: 07c65c7f7cd69dcb98029a38d70098bb30e1d244
|
4
|
+
data.tar.gz: dd5cc8606a8b722916053cc413febcccce8061cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d00b80695f80838f91fec5f6d0f956a1676e6c8c7540bfc68259895708fa57862401ae06ba08bb7239c399a03cee9e696520672484cafc04bca03b9b4851568a
|
7
|
+
data.tar.gz: b943e3bb63a37df8a203c17e14c6f8c698c251267c784ae3a288290968b9c983ac712f31cc0dc485da22647bb966b6f58a08b2412187f9c439ea785b8bcfb905
|
data/lib/dircrawl.rb
CHANGED
@@ -44,9 +44,10 @@ class DirCrawl
|
|
44
44
|
# Crawl dir and call block for each file
|
45
45
|
def crawl_dir(dir, *args)
|
46
46
|
Dir.foreach(dir) do |file|
|
47
|
+
# Skip . or .. files
|
47
48
|
next if file == '.' or file == '..'
|
48
|
-
|
49
|
-
#
|
49
|
+
|
50
|
+
# Recurse into directories
|
50
51
|
if File.directory?(dir+"/"+file)
|
51
52
|
report_status("Going to next directory: " + dir+"/"+file)
|
52
53
|
crawl_dir(dir+"/"+file, *args)
|
@@ -54,21 +55,27 @@ class DirCrawl
|
|
54
55
|
# Process file
|
55
56
|
elsif !file.include?(@ignore_includes)
|
56
57
|
|
57
|
-
|
58
|
+
# Create Output Directory
|
58
59
|
create_write_dirs(dir.gsub(@path, @output_dir))
|
59
60
|
|
60
61
|
begin
|
61
|
-
|
62
|
-
if
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
62
|
+
|
63
|
+
# Check if processed file exists
|
64
|
+
# Skip processing (if yes)
|
65
|
+
if !File.exist?(get_write_dir(dir, file))
|
66
|
+
|
67
|
+
# Process Extras
|
68
|
+
if @extras_block != ""
|
69
|
+
extras = @extras_block.call(@output_dir+"/")
|
70
|
+
end
|
71
|
+
|
72
|
+
# Now Process Main
|
73
|
+
processed = @process_block.call(dir+"/"+file, *args)
|
74
|
+
else
|
75
|
+
puts "Processed file exists, skipping"
|
76
|
+
puts " " + dir + file
|
77
|
+
processed = File.read(get_write_dir(dir, file))
|
78
|
+
end
|
72
79
|
|
73
80
|
rescue Exception => e # really catch any failures
|
74
81
|
report_status("Error on file "+file+": "+e.to_s)
|
@@ -78,11 +85,11 @@ class DirCrawl
|
|
78
85
|
IO.write(@output_dir+"/error_log.txt", file+"\n", mode: 'a')
|
79
86
|
end
|
80
87
|
end
|
81
|
-
|
88
|
+
|
82
89
|
# Only save in output if specified (to handle large dirs)
|
83
90
|
report_results([JSON.parse(processed)], dir+"/"+file)
|
84
|
-
|
85
|
-
# Write to file
|
91
|
+
|
92
|
+
# Write Output to file
|
86
93
|
File.write(get_write_dir(dir, file), processed)
|
87
94
|
end
|
88
95
|
end
|