Module: Fingerprint
- Defined in:
- lib/fingerprint/version.rb,
lib/fingerprint.rb,
lib/fingerprint/find.rb,
lib/fingerprint/record.rb,
lib/fingerprint/checker.rb,
lib/fingerprint/command.rb,
lib/fingerprint/scanner.rb,
lib/fingerprint/checksums.rb,
lib/fingerprint/command/scan.rb,
lib/fingerprint/command/verify.rb,
lib/fingerprint/command/analyze.rb,
lib/fingerprint/command/compare.rb,
lib/fingerprint/command/duplicates.rb
Overview
Copyright, 2011, by Samuel G. D. Williams. <www.codeotaku.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Defined Under Namespace
Modules: Checksums, Command, Find Classes: Checker, Record, RecordSet, RecordSetPrinter, RecordSetWrapper, Scanner, SparseRecordSet
Constant Summary collapse
- MODES =
{ :configuration => 'C', :file => 'F', :link => 'L', :directory => 'D', :summary => 'S', :warning => 'W', :excluded => '#', }
- INDEX_FINGERPRINT =
"index.fingerprint"
- CHECKSUMS =
{ 'MD5' => lambda { Digest::MD5.new }, 'SHA1' => lambda { Digest::SHA1.new }, 'SHA2.256' => lambda { Digest::SHA2.new(256) }, 'SHA2.384' => lambda { Digest::SHA2.new(384) }, 'SHA2.512' => lambda { Digest::SHA2.new(512) }, }
- DEFAULT_CHECKSUMS =
['SHA2.256']
- VERSION =
"3.4.0"
Class Method Summary collapse
-
.check_paths(master_path, copy_path, **options, &block) ⇒ Object
A helper function to check two paths for consistency.
-
.identical?(source, destination, &block) ⇒ Boolean
Returns true if the given paths contain identical files.
Class Method Details
.check_paths(master_path, copy_path, **options, &block) ⇒ Object
A helper function to check two paths for consistency. Provides callback from Fingerprint::Checker
.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/fingerprint.rb', line 28 def self.check_paths(master_path, copy_path, **, &block) master = Scanner.new([master_path]) copy = Scanner.new([copy_path]) master_recordset = RecordSet.new copy_recordset = SparseRecordSet.new(copy) master.scan(master_recordset) checker = Checker.new(master_recordset, copy_recordset, **) checker.check(&block) return checker end |
.identical?(source, destination, &block) ⇒ Boolean
Returns true if the given paths contain identical files. Useful for expectations, e.g. ‘expect(Fingerprint).to be_identical(source, destination)`
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/fingerprint.rb', line 45 def self.identical?(source, destination, &block) failures = 0 check_paths(source, destination) do |record, name, | failures += 1 yield(record) if block_given? end return failures == 0 end |