directory-digest 1.0.9 → 1.0.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/directory-digest/digest.rb +12 -11
- 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: fba379a6e0a6dc1ee8244f4706327f7c4d52a2fc
|
4
|
+
data.tar.gz: 2d63dd3b5ad5be5ee33fad0fc9b5efa00bc6b427
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de9514f76d276e2213cb8d6e76b527a49d07a198d652e0f4c45ad1631cf54928e1c16c67f9bbb5f2b198ad7dd8215bb0c82c810ed04e4a997b71e59368a17971
|
7
|
+
data.tar.gz: f3cd4b27d636ebe3ae22cf65a1361962c468e7767faf3dcc852b6611552c86a1e1db9f961d77668ebb3fe80cd0265614f29784136dc260ac1fef35ac5489e6f5
|
@@ -3,7 +3,7 @@ require 'json'
|
|
3
3
|
require 'fileutils'
|
4
4
|
|
5
5
|
module DirectoryDigest
|
6
|
-
# DirectoryDigest::Digest - Creates a SHA256 digest of a directory's content
|
6
|
+
# DirectoryDigest::Digest - Creates a SHA256 digest of a directory's content.
|
7
7
|
class Digest
|
8
8
|
attr_reader :directory
|
9
9
|
attr_reader :directory_digest
|
@@ -15,18 +15,19 @@ module DirectoryDigest
|
|
15
15
|
@file_digests = file_digests.freeze
|
16
16
|
end
|
17
17
|
|
18
|
-
def self.sha256(directory, glob = '**/*',
|
19
|
-
|
18
|
+
def self.sha256(directory, glob = '**/*', include = proc { true })
|
19
|
+
if include.is_a?(Array)
|
20
|
+
regex_list = include
|
21
|
+
include = lambda do |path|
|
22
|
+
matches = regex_list.select { |regex| regex.size > 1 && path =~ /#{regex[1..-1]}/ }
|
23
|
+
matches.count.zero? || matches.last[0] == '+'
|
24
|
+
end
|
25
|
+
end
|
20
26
|
directory_digest = OpenSSL::Digest::SHA256.new
|
21
27
|
file_digests = {}
|
22
28
|
Dir["#{directory}/#{glob}"].each do |filename|
|
23
|
-
|
24
|
-
|
25
|
-
included = true
|
26
|
-
includes.each do |include|
|
27
|
-
included = include[0] == '+' if include.size > 1 && path =~ /#{include[1, 99_999]}/i
|
28
|
-
end
|
29
|
-
next unless included
|
29
|
+
path = filename[directory.size..-1]
|
30
|
+
next unless File.file?(filename) && include.call(path)
|
30
31
|
file_digest = OpenSSL::Digest::SHA256.new
|
31
32
|
File.open(filename, 'rb') do |file|
|
32
33
|
until file.eof?
|
@@ -86,7 +87,7 @@ module DirectoryDigest
|
|
86
87
|
end
|
87
88
|
end
|
88
89
|
|
89
|
-
# DirectoryDigest::MirrorActions - Provider for standard mirror making activities
|
90
|
+
# DirectoryDigest::MirrorActions - Provider for standard mirror making activities.
|
90
91
|
class MirrorActions
|
91
92
|
def initialize(chunk_size = 4096)
|
92
93
|
@chunk_size = chunk_size
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: directory-digest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Heald
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06-
|
11
|
+
date: 2016-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|