Sha256: 303bca2f8a6b13e3103873d5b5ae98014ebbf962ced556fa28674044fa36cae2

Contents?: true

Size: 972 Bytes

Versions: 6

Compression:

Stored size: 972 Bytes

Contents

module Assets

  # Rule evaluator
  class Evaluator
    include Adamantium, Concord.new(:rule)

    # Return asset
    #
    # @return [Asset]
    #
    # @api private
    #
    def asset
      rule = self.rule
      Asset.new(
        :name       => rule.name,
        :mime       => rule.mime,
        :created_at => Time.now,
        :body       => body,
        :size       => size,
        :sha1       => sha1
      )
    end

    # Return sha1 hexdigest of body
    #
    # @return [String]
    #
    # @api private
    #
    def sha1
      Digest::SHA1.hexdigest(body)
    end

    # Return body
    #
    # @return [String]
    #
    # @api private
    #
    def body
      rule.body
    end
    memoize :body

    # Return size in bytes
    #
    # @return [Fixnum]
    #
    # @api private
    #
    def size
      body.bytesize
    end

    # Return mime
    #
    # @return [Mime]
    #
    # @api private
    #
    def mime
      rule.mime
    end

  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
mbj-assets-0.0.8 lib/assets/evaluator.rb
mbj-assets-0.0.7 lib/assets/evaluator.rb
mbj-assets-0.0.6 lib/assets/evaluator.rb
mbj-assets-0.0.5 lib/assets/evaluator.rb
mbj-assets-0.0.4 lib/assets/evaluator.rb
mbj-assets-0.0.3 lib/assets/evaluator.rb