chef
https://github.com/opscode/chef
Ruby
A systems integration framework, built to bring the benefits of configuration management to your entire infrastructure.
Chef::ChefFS::FileSystem::BaseFSObject#compare_to
Override this if you have a special comparison algorithm that can tell
you whether this entry is the same as another--either a quicker or a
more reliable one. Callers will use this to decide whether to upload,
download or diff an object.
You should not override this if you're going to do the standard
+self.read == other.read+. If you return +nil+, the caller will call
+other.compare_to(you)+ instead. Give them a chance :)
==== Parameters
* +other+ - the entry to compare to
==== Returns
* +[ are_same, value, other_value ]+
+are_same+ may be +true+, +false+ or +nil+ (which means "don't know").
+value+ and +other_value+ must either be the text of +self+ or +other+,
+:none+ (if the entry does not exist or has no value) or +nil+ if the
value was not retrieved.
* +nil+ if a definitive answer cannot be had and nothing was retrieved.
==== Example
are_same, value, other_value = entry.compare_to(other)
if are_same.nil?
are_same, other_value, value = other.compare_to(entry)
end
if are_same.nil?
value = entry.read if value.nil?
other_value = entry.read if other_value.nil?
are_same = (value == other_value)
endEdit
git clone [email protected]:opscode/chef.git
cd chef
open lib/chef/chef_fs/file_system/base_fs_object.rb
Contribute
# Make a new branchgit checkout -b -your-name--update-docs-Chef--ChefFS--FileSystem--BaseFSObject-compare_to-for-pr
# Commit to gitgit add lib/chef/chef_fs/file_system/base_fs_object.rbgit commit -m "better docs for Chef::ChefFS::FileSystem::BaseFSObject#compare_to"
# Open pull requestgem install hub # on a mac you can `brew install hub`
hub fork
git push <your name> -your-name--update-docs-Chef--ChefFS--FileSystem--BaseFSObject-compare_to-for-pr
hub pull-request
# Celebrate!