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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a3c683bb5e780a58f343ce65371348ac48357fc9
4
- data.tar.gz: fa1e6e608fa030a3cd5802abaf4e2c97b292f275
3
+ metadata.gz: 1b6b2c68a2fa91ab24144c185fd0f3dc1edd8c41
4
+ data.tar.gz: 10db55afbeac043c1c0d5cded313c9ac77a2a114
5
5
  SHA512:
6
- metadata.gz: bb4782fb6271906d56fcffc6019e033729f19f0921c2210f49bf0cac4302605e33296d3f0d384201854850b60aa6bd58d4e9857a2e738c28515de78b795d6e8b
7
- data.tar.gz: 21bd9d3f6a730d552dacbbc99d83f94bf7c17f47c8b4d39d853db7c189abcf6f6b5cc7bec8cf02a3fdf216a305a358a52059dd46fa181f6eb46609abac62a8d1
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, but has no dependencies
6
- on rails. By default, files in `log` and `tmp` are excluded in digesting.
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
@@ -1,3 +1,3 @@
1
1
  class ApplicationDigester
2
- VERSION = "0.1.2"
2
+ VERSION = "0.1.3"
3
3
  end
@@ -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 + paths.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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: application_digester
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Derek Schneider