application_digester 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/application_digester/version.rb +1 -1
- data/lib/application_digester.rb +15 -1
- 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: 1b6b2c68a2fa91ab24144c185fd0f3dc1edd8c41
|
4
|
+
data.tar.gz: 10db55afbeac043c1c0d5cded313c9ac77a2a114
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f37c68e4bf0f2b297438c2a0094725f25ccc79092e255290c36151967e43c9fa536eb99c5072c6862a6e8554c88601f7b618afddc93c452f06fb85957cdfd597
|
7
|
+
data.tar.gz: 04b7f676517cf473c46c0d606c231d685bd4b4ef9d0f069ff7ca09e00ad118341454c49fd0c57897106165c03e4f811fb22de02ece673ab0ddc2ec983d933a15
|
data/README.md
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
Disclaimer: This library is still in early stages of development.
|
4
4
|
|
5
|
-
This gem is intended to be used with a rails application,
|
6
|
-
on
|
5
|
+
This gem is intended to be used with a rails application, and has a dependency
|
6
|
+
on `Rails.root`. By default, files in `log` and `tmp` are excluded in digesting.
|
7
7
|
|
8
8
|
Having a digest of the application running files is useful to know what code is
|
9
9
|
actually running. Typically, a git SHA will be superior to calculating your own
|
data/lib/application_digester.rb
CHANGED
@@ -4,11 +4,25 @@ class ApplicationDigester
|
|
4
4
|
# Taking into account the location of every file helps capture changes such as
|
5
5
|
# a file moving location, but the contents remain unchanged.
|
6
6
|
def digest
|
7
|
-
Digest::SHA256.hexdigest(file_digests.join +
|
7
|
+
Digest::SHA256.hexdigest(file_digests.join + relative_paths.join)
|
8
8
|
end
|
9
9
|
|
10
10
|
private
|
11
11
|
|
12
|
+
def relative_paths
|
13
|
+
paths.map do |path|
|
14
|
+
if path.start_with?(absolute_path_prefix)
|
15
|
+
path.split(absolute_path_prefix, 2).last
|
16
|
+
else
|
17
|
+
fail "Expected string to start with #{absolute_path_prefix}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def absolute_path_prefix
|
23
|
+
Rails.root.to_path + '/' # Not sure if we need to add this.
|
24
|
+
end
|
25
|
+
|
12
26
|
def file_digests
|
13
27
|
files.map { |path| Digest::SHA256.hexdigest(File.read(path)) }
|
14
28
|
end
|