lib/zip-container/entries/file.rb in zip-container-3.0.2 vs lib/zip-container/entries/file.rb in zip-container-4.0.1

- old
+ new

@@ -28,11 +28,11 @@ # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # POSSIBILITY OF SUCH DAMAGE. # # Author: Robert Haines -# +## module ZipContainer # A ManagedFile is used to reserve a filename in a Container namespace. class ManagedFile < ManagedEntry @@ -55,17 +55,17 @@ # The following example creates a ManagedFile that is not required to be # present in the container, but if it is, its contents must be the single # word "Boo!". # # valid = Proc.new { |contents| contents == "Boo!" } - # ManagedFile.new("Surprize.txt", :required => false, - # :validation_proc => valid) + # ManagedFile.new("Surprize.txt", required: false, + # validation_proc: valid) def initialize(name, options = {}) options = { - :required => false, - :hidden => false, - :validation_proc => nil + required: false, + hidden: false, + validation_proc: nil }.merge(options) super(name, options[:required], options[:hidden]) @validation_proc = @@ -81,12 +81,14 @@ # If it does not pass verification a list of reasons why it fails is # returned. The empty list is returned if verification passes. def verify messages = super - unless (exists? ? validate : true) - messages << "The contents of file '#{full_name}' do not pass validation." + valid = exists? ? validate : true + unless valid + messages << + "The contents of file '#{full_name}' do not pass validation." end messages end @@ -108,8 +110,7 @@ # Grab the contents of this ManagedFile def contents container.read(full_name) end - end end