Sha256: 73a55f98e6fb80f629793e7518a412a32e73eb584d7e2cd0bed73a1875ac91da

Contents?: true

Size: 824 Bytes

Versions: 10

Compression:

Stored size: 824 Bytes

Contents

module GitObjectBrowser

  module Models

    class PackedRefs
      def initialize(input)
        @content = input.read(nil)
        input.seek(0)
        @entries = []
        while (line = input.gets) do
          next if line =~ /\A\s*#/
          next unless line =~ /(\^)?([0-9a-f]{40})\s*(.*)/
          sha1 = $2
          ref  = $3
          if $1
            entry = @entries.last
            entry[:tag_sha1] = sha1 if entry
          else
            entry = {}
            entry[:sha1] = sha1
            entry[:ref]  = ref
            @entries << entry
          end
        end
      end

      def to_hash
        return {
          :entries => @entries,
          :content => @content
        }
      end

      def self.path?(relpath)
        return relpath == "packed-refs"
      end

    end

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
git-object-browser-0.1.3 lib/git-object-browser/models/packed_refs.rb
git-object-browser-0.1.2 lib/git-object-browser/models/packed_refs.rb
git-object-browser-0.1.1 lib/git-object-browser/models/packed_refs.rb
git-object-browser-0.1.0 lib/git-object-browser/models/packed_refs.rb
git-object-browser-0.0.9 lib/git-object-browser/models/packed_refs.rb
git-object-browser-0.0.8 lib/git-object-browser/models/packed_refs.rb
git-object-browser-0.0.7 lib/git-object-browser/models/packed_refs.rb
git-object-browser-0.0.6 lib/git-object-browser/models/packed_refs.rb
git-object-browser-0.0.4 lib/git-object-browser/models/packed_refs.rb
git-object-browser-0.0.3 lib/git-object-browser/models/packed_refs.rb