digestif 1.0.4 → 1.0.5

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.
@@ -1,3 +1,11 @@
1
+ === Version 1.0.5
2
+
3
+ * Added --print-sample-count option
4
+
5
+ === Version 1.0.4
6
+
7
+ * Library bugfixes
8
+
1
9
  === Version 1.0.3
2
10
 
3
11
  * Improved the usability of digestif as a library
@@ -20,3 +20,7 @@ Feature: Basic application operation
20
20
  Scenario: Hashing 2 files
21
21
  When I run "digestif -d sha1 test_file test_file_2"
22
22
  Then the output should be 2 digests
23
+
24
+ Scenario: Getting the sample count
25
+ When I run "digestif --print-sample-count test_file"
26
+ Then the output should contain "samples"
@@ -55,6 +55,12 @@ module Digestif
55
55
  options.digest = digest
56
56
  end
57
57
 
58
+ p.on("--print-sample-count",
59
+ "outputs the number of samples used to create the hash") do
60
+ options.print_sample_count = true
61
+ end
62
+
63
+
58
64
  p.on("-r", "--read-size SIZE", Integer,
59
65
  "Size of chunk to read, in bytes " +
60
66
  "(#{options.read_size})") do |size|
@@ -67,10 +73,6 @@ module Digestif
67
73
  options.seek_size = size
68
74
  end
69
75
 
70
- p.separator ""
71
- p.separator "Common options:"
72
- p.separator ""
73
-
74
76
  p.on_tail("-v", "--version", "Show version") do
75
77
  puts Digestif.version_string
76
78
  exit 0
@@ -15,13 +15,18 @@ module Digestif
15
15
 
16
16
  def digest
17
17
  hasher = Digest.const_get(options.digest.to_s.upcase).new
18
+ sample_count = 0
18
19
 
19
20
  File.open(filename, 'rb') do |f|
20
21
  until f.eof
21
22
  hasher.update(f.read(options.read_size))
22
23
  f.seek(options.seek_size, IO::SEEK_CUR)
24
+ sample_count += 1
23
25
  end
24
26
  end
27
+ if options.print_sample_count
28
+ puts "#{filename}\t#{File.size(filename)}b\t#{sample_count} samples"
29
+ end
25
30
  hasher.hexdigest
26
31
  end
27
32
 
@@ -1,6 +1,6 @@
1
1
  module Digestif
2
2
  def self.version
3
- "1.0.4"
3
+ "1.0.5"
4
4
  end
5
5
 
6
6
  def self.version_string
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: digestif
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 4
10
- version: 1.0.4
9
+ - 5
10
+ version: 1.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Andrew Roberts