Sha256: b1c70a962ff5267f82ed65d175cf18e4b4324ab0907c748ff78fa416f0b5a8b7

Contents?: true

Size: 886 Bytes

Versions: 45

Compression:

Stored size: 886 Bytes

Contents

module Rugged
  class Repository
    def attributes(path, options = {})
      Attributes.new(self, path, options)
    end

    class Attributes
      include Enumerable

      LOAD_PRIORITIES = {
        [:file, :index] => 0,
        [:index, :file] => 1,
        [:index] => 2,
      }

      def self.parse_opts(opt)
        flags = LOAD_PRIORITIES[opt[:priority]] || 0
        flags |= 4 if opt[:skip_system]
        flags
      end

      def initialize(repository, path, options = {})
        @repository = repository
        @path = path
        @load_flags = Attributes.parse_opts(options)
      end

      def [](attribute)
        @repository.fetch_attributes(@path, attribute, @load_flags)
      end

      def to_h
        @hash ||= @repository.fetch_attributes(@path, nil, @load_flags)
      end

      def each(&block)
        to_h.each(&block)
      end
    end
  end
end

Version data entries

45 entries across 45 versions & 2 rubygems

Version Path
rugged-0.24.6.1 lib/rugged/attributes.rb
rugged-0.24.5 lib/rugged/attributes.rb
rugged-0.25.0b10 lib/rugged/attributes.rb
rugged-0.25.0b9 lib/rugged/attributes.rb
rugged-0.25.0b8 lib/rugged/attributes.rb
rugged-0.25.0b7 lib/rugged/attributes.rb
rugged-0.25.0b6 lib/rugged/attributes.rb
rugged-0.25.0b5 lib/rugged/attributes.rb
rugged-0.25.0b4 lib/rugged/attributes.rb
rugged-0.25.0b3 lib/rugged/attributes.rb
rugged-0.25.0b2 lib/rugged/attributes.rb
rugged-0.25.0b1 lib/rugged/attributes.rb
rugged-0.24.0 lib/rugged/attributes.rb
rugged-0.24.0b14 lib/rugged/attributes.rb
rugged-0.24.0b13 lib/rugged/attributes.rb
rdavila-rugged-0.24.0b13 lib/rugged/attributes.rb
rugged-0.24.0b12 lib/rugged/attributes.rb
rugged-0.24.0b11 lib/rugged/attributes.rb
rugged-0.24.0b9 lib/rugged/attributes.rb
rugged-0.24.0b8 lib/rugged/attributes.rb