dircrawl 0.0.6 → 0.0.7

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 +15 -5
  3. metadata +3 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c18fd6e3bcf2c82a96a8d14a915f25f5c6259bfa
4
- data.tar.gz: 38b9fc3619888f1304e779668c192cf63077725f
3
+ metadata.gz: 5eae167b0003fb369af7a4202e05347fb32abe5e
4
+ data.tar.gz: ba3ccea4b241563ec7b148a65642a9fd2a850582
5
5
  SHA512:
6
- metadata.gz: 1a97e653c7c7b177c7ee598c3a7ce6232a58f5f7c104d7171c67a88531d146055d1a4a355e7ba3b435b62da3f3bb6f21c41d36967e14c69f3cf5afc3d0c538ea
7
- data.tar.gz: e4778c1a25a72a74df0fd9cf2bbc2cfbaf12cd5c4b334be1b908f30b27ef83bea060141d7088769ed86a59c77fb2a46d49eeeec5135bebbd17ef08e7570e535b
6
+ metadata.gz: 20447152ef43e06f8f685da480a08d2579e893fe635e04243e3aba48952d828c0aa06cf5feebb1f00fa41fbb903e0a51c4b5ccbdf99f7eff34ef68ebbb90a9ec
7
+ data.tar.gz: c0f73edad160315e8675d4cfecf31ead5da3d048600a95bfa0abd3f625c0b88e15f70e2f24e2a4e1bab8da6dc65c6e38e9d5220948cf308b09576949cc5f1c38
data/lib/dircrawl.rb CHANGED
@@ -2,13 +2,14 @@ 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, extras_block, *args)
6
- @path = path
5
+ def initialize(path, output_dir, ignore_includes, save, process_block, include_block, extras_block, failure_mode, *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
+ @extras_block = extras_block
12
+ @failure_mode = failure_mode
12
13
  @output = Array.new
13
14
  @save = save
14
15
  crawl_dir(path, *args)
@@ -42,17 +43,26 @@ class DirCrawl
42
43
  # Process file
43
44
  elsif !file.include?(@ignore_includes)
44
45
 
45
- # Create Dirs
46
+ # Create Dirs
46
47
  create_write_dirs(dir.gsub(@path, @output_dir))
47
48
 
49
+ begin
48
50
  # Process Extras
49
51
  if @extras_block != ""
50
52
  extras = @extras_block.call(@output_dir+"/")
51
53
  end
52
54
 
53
55
  # Process Main
54
- processed = @process_block.call(dir+"/"+file, *args)
56
+ processed = @process_block.call(dir+"/"+file, *args)
55
57
 
58
+ rescue # Catch any failures
59
+ if @failure_mode == "debug"
60
+ binding.pry
61
+ elsif @failure_mode == "log"
62
+ IO.write(@output_dir+"/error_log.txt", file+"\n", mode: 'a')
63
+ end
64
+ end
65
+
56
66
  # Only save in output if specified (to handle large dirs)
57
67
  if @save
58
68
  @output.push(JSON.parse(processed))
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.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - M. C. McGrath
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-08-09 00:00:00.000000000 Z
12
+ date: 2016-08-15 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Run block on all files in dir
15
15
  email: shidash@shidash.com
@@ -38,9 +38,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
38
38
  version: '0'
39
39
  requirements: []
40
40
  rubyforge_project:
41
- rubygems_version: 2.4.8
41
+ rubygems_version: 2.5.1
42
42
  signing_key:
43
43
  specification_version: 4
44
44
  summary: Run block on all files in dir
45
45
  test_files: []
46
- has_rdoc: