Sha256: bacb10848aa45698ca13433645641828aa90e338335b919448c306b6e17f0efe

Contents?: true

Size: 596 Bytes

Versions: 11

Compression:

Stored size: 596 Bytes

Contents

require 'digest/md5'
 
module Trackman
  module Assets
    module Components
      module Hashable
        def data
          @data ||= read_file(path)
        end

        def file_hash
          @file_hash ||= (data.nil? ? "" : Digest::MD5.hexdigest(data))
        end
        
        protected
          def read_file(file_path)
            begin
              file = File.open(file_path)
              return file.read
            rescue
              return nil
            ensure
              file.close unless file.nil?
            end    
          end
      end      
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
trackman-0.5.4 lib/trackman/assets/components/hashable.rb
trackman-0.5.3 lib/trackman/assets/components/hashable.rb
trackman-0.5.2 lib/trackman/assets/components/hashable.rb
trackman-0.5.1 lib/trackman/assets/components/hashable.rb
trackman-0.5.0 lib/trackman/assets/components/hashable.rb
trackman-0.4.8 lib/trackman/assets/components/hashable.rb
trackman-0.4.7 lib/trackman/assets/components/hashable.rb
trackman-0.4.6 lib/trackman/assets/components/hashable.rb
trackman-0.4.5 lib/trackman/assets/components/hashable.rb
trackman-0.4.4 lib/trackman/assets/components/hashable.rb
trackman-0.4.3 lib/trackman/assets/components/hashable.rb