dircrawl 0.0.2 → 0.0.3
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 +8 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a1d0872ea23fdf687f86c262492f3cc0780e423
|
4
|
+
data.tar.gz: a5dc01e83439b4c0f57939bf7c89be4d4043a3ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf39bf5f4557309105dd7ff75518a32b99ed8f47fe1763e6794b39963bb39c1f6ec1ec96abda82d0a0c4569c71acc7722f443aad9860844e4dcd2f6b8d185c2d
|
7
|
+
data.tar.gz: fecb62153ceb6e9d8770176009a2fe344371bb09ca21f26a53c41f82bc380befc8950be16d7559f1bbcdd39bb163bda55327ef93470551fa670eaea72235f4cb
|
data/lib/dircrawl.rb
CHANGED
@@ -2,20 +2,21 @@ require 'json'
|
|
2
2
|
require 'pry'
|
3
3
|
|
4
4
|
class DirCrawl
|
5
|
-
def initialize(path, output_dir, ignore_includes, process_block, include_block, *args)
|
5
|
+
def initialize(path, output_dir, ignore_includes, save, process_block, include_block, *args)
|
6
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
11
|
@output = Array.new
|
12
|
+
@save = save
|
12
13
|
crawl_dir(path, *args)
|
13
14
|
end
|
14
15
|
|
15
16
|
# Figure out where to write it
|
16
17
|
def get_write_dir(dir, file)
|
17
18
|
dir_save = dir.gsub(@path, @output_dir)
|
18
|
-
return dir_save+"/"+file
|
19
|
+
return dir_save+"/"+file+".json"
|
19
20
|
end
|
20
21
|
|
21
22
|
# Create if they don't exist
|
@@ -40,8 +41,12 @@ class DirCrawl
|
|
40
41
|
# Process file
|
41
42
|
elsif !file.include?(@ignore_includes)
|
42
43
|
processed = @process_block.call(dir+"/"+file, *args)
|
43
|
-
@output.push(JSON.parse(processed))
|
44
44
|
|
45
|
+
# Only save in output if specified (to handle large dirs)
|
46
|
+
if @save
|
47
|
+
@output.push(JSON.parse(processed))
|
48
|
+
end
|
49
|
+
|
45
50
|
# Write to file
|
46
51
|
create_write_dirs(dir.gsub(@path, @output_dir))
|
47
52
|
File.write(get_write_dir(dir, file), processed)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dircrawl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- M. C. McGrath
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Run block on all files in dir
|
14
14
|
email: shidash@shidash.com
|