fingerprint 1.3.2 → 1.3.3

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.
@@ -37,6 +37,7 @@ OPTIONS = {
37
37
  :checksums => Fingerprint::DEFAULT_CHECKSUMS,
38
38
  :lockfile => true,
39
39
  :additions => false,
40
+ :failures_exit_status => 0,
40
41
  }
41
42
 
42
43
  ARGV.options do |o|
@@ -106,6 +107,10 @@ ARGV.options do |o|
106
107
  OPTIONS[:lockfile] = false
107
108
  end
108
109
 
110
+ o.on("-X", "Give a non-zero exit code if errors are detected by check or verify.") do
111
+ OPTIONS[:failures_exit_status] = 1
112
+ end
113
+
109
114
  o.separator ""
110
115
  o.separator "Help and Copyright information:"
111
116
 
@@ -157,6 +162,16 @@ def with_lock
157
162
  return true
158
163
  end
159
164
 
165
+ def finish_check(error_count)
166
+ if error_count == 0
167
+ $stderr.puts "Data verified, 0 errors found."
168
+ exit(0)
169
+ else
170
+ $stderr.puts "Data inconsistent, #{error_count} errors found!"
171
+ exit(OPTIONS[:failures_exit_status])
172
+ end
173
+ end
174
+
160
175
  case (OPTIONS[:mode])
161
176
  when :analyze
162
177
  result = with_lock do
@@ -214,13 +229,7 @@ case (OPTIONS[:mode])
214
229
 
215
230
  error_count += Fingerprint::Checker::verify(master, copy, options)
216
231
 
217
- if error_count == 0
218
- $stderr.puts "Data verified, 0 errors found."
219
- exit(0)
220
- else
221
- $stderr.puts "Data inconsistent, #{error_count} errors found!"
222
- exit(1)
223
- end
232
+ finish_check(error_count)
224
233
  when :scan
225
234
  roots = ARGV
226
235
  roots << Dir.pwd if roots.size == 0
@@ -242,5 +251,6 @@ case (OPTIONS[:mode])
242
251
  options = OPTIONS.dup
243
252
 
244
253
  error_count = Fingerprint::Checker.check_files(ARGV[0], ARGV[1], options)
245
- exit(error_count > 0 ? 1 : 0)
254
+
255
+ finish_check(error_count)
246
256
  end
@@ -59,6 +59,10 @@ module Fingerprint
59
59
  @master.records.each_with_index do |record, processed_count|
60
60
  copy_paths.delete(record.path)
61
61
 
62
+ if @options[:progress]
63
+ $stderr.puts "# Checking: #{record.path}"
64
+ end
65
+
62
66
  next if record.mode != :file
63
67
 
64
68
  result, message = @copy.compare(record)
@@ -74,7 +78,7 @@ module Fingerprint
74
78
  end
75
79
 
76
80
  if @options[:progress]
77
- $stderr.puts "# Progress: File #{processed_count} / #{total_count} = #{sprintf('%0.2f%', processed_count.to_f / total_count.to_f * 100.0)}; Byte #{processed_size} / #{total_size} = #{sprintf('%0.2f%', processed_size.to_f / total_size.to_f * 100.0)}"
81
+ $stderr.puts "# Progress: File #{processed_count} / #{total_count}; Byte #{processed_size} / #{total_size} = #{sprintf('%0.2f%', processed_size.to_f / total_size.to_f * 100.0)}"
78
82
 
79
83
  processed_size += (record['file.size'] || 0).to_i
80
84
  end
@@ -82,7 +86,9 @@ module Fingerprint
82
86
 
83
87
  if @options[:additions]
84
88
  copy_paths.each do |path, record|
85
- yield record, :addition, "File #{path} added."
89
+ next unless record.mode == :file || record.mode == :directory
90
+
91
+ yield record, :addition, "File added"
86
92
  end
87
93
  end
88
94
  end
@@ -23,7 +23,7 @@ module Fingerprint
23
23
  module VERSION
24
24
  MAJOR = 1
25
25
  MINOR = 3
26
- TINY = 2
26
+ TINY = 3
27
27
 
28
28
  STRING = [MAJOR, MINOR, TINY].join('.')
29
29
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fingerprint
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 3
9
- - 2
10
- version: 1.3.2
9
+ - 3
10
+ version: 1.3.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - Samuel Williams