Sha256: 4a08cc2394b22cbac581c03a482c8631482a049294400c29a68ece0ce01b70f9

Contents?: true

Size: 1.04 KB

Versions: 52

Compression:

Stored size: 1.04 KB

Contents

# Copyright (C) the Rugged contributors.  All rights reserved.
#
# This file is part of Rugged, distributed under the MIT license.
# For full terms see the included LICENSE file.

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

52 entries across 52 versions & 1 rubygems

Version Path
rugged-1.9.0 lib/rugged/attributes.rb
rugged-1.7.2 lib/rugged/attributes.rb
rugged-1.6.5 lib/rugged/attributes.rb
rugged-1.7.1 lib/rugged/attributes.rb
rugged-1.6.3 lib/rugged/attributes.rb
rugged-1.6.2 lib/rugged/attributes.rb
rugged-1.5.1 lib/rugged/attributes.rb
rugged-1.4.5 lib/rugged/attributes.rb
rugged-1.5.0.1 lib/rugged/attributes.rb
rugged-1.5.0 lib/rugged/attributes.rb
rugged-1.3.2.3 lib/rugged/attributes.rb
rugged-1.4.4 lib/rugged/attributes.rb
rugged-1.3.2.1 lib/rugged/attributes.rb
rugged-1.4.3 lib/rugged/attributes.rb
rugged-1.3.2 lib/rugged/attributes.rb
rugged-1.4.2 lib/rugged/attributes.rb
rugged-1.3.1 lib/rugged/attributes.rb
rugged-1.3.0 lib/rugged/attributes.rb
rugged-1.2.0 lib/rugged/attributes.rb
rugged-1.1.1 lib/rugged/attributes.rb