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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dircrawl.rb +24 -17
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 93e0fad01c32c1c093589b04cffe6d51d9448230
4
- data.tar.gz: fcdc1e8f6828189069a06a1d2fa4c6c35c256636
3
+ metadata.gz: 07c65c7f7cd69dcb98029a38d70098bb30e1d244
4
+ data.tar.gz: dd5cc8606a8b722916053cc413febcccce8061cc
5
5
  SHA512:
6
- metadata.gz: 116f360fd86b9894f4eaa3f27db92a1ac1de524ac89fbbc3bd0e4199d087e503caf572ec2b4af35aa45f5c1b7eb868812348a4a4656a5fffd3cb14042437488c
7
- data.tar.gz: c87fe56332ae4bc198115d02e58950027bcd9a5a9f184b2e32ae8df7b1db6362219aa11664cd8a986b3c60c0f4e3343f10e817bbddc80e85b8be263668acfb55
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
- # Go to next dir
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
- # Create Dirs
58
+ # Create Output Directory
58
59
  create_write_dirs(dir.gsub(@path, @output_dir))
59
60
 
60
61
  begin
61
- # Process Extras
62
- if @extras_block != ""
63
- extras = @extras_block.call(@output_dir+"/")
64
- end
65
-
66
- # Process Main
67
- if !File.exist?(get_write_dir(dir, file))
68
- processed = @process_block.call(dir+"/"+file, *args)
69
- else
70
- processed = File.read(get_write_dir(dir, file))
71
- end
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dircrawl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - M. C. McGrath