Sha256: 82e6b3ed9ccf7a1639f14258370d50318be9c4a49765e8ad7e914f32da3dcf91

Contents?: true

Size: 626 Bytes

Versions: 10

Compression:

Stored size: 626 Bytes

Contents

module GitObjectBrowser

  module Models

    class Ref
      def initialize(input)
        @content = input.read(nil)

        if @content =~ %r{\Aref:\s*(.+)}
          @ref = $1
        elsif @content =~ %r{\A([0-9a-f]{40})}
          @sha1 = $1
        end
      end

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

      def self.path?(relpath)
        ref_names = %w{HEAD FETCH_HEAD ORIG_HEAD MERGE_HEAD CHERRY_PICK_HEAD}
        return (ref_names.include?(relpath) || relpath =~ %r{\Arefs/})
      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/ref.rb
git-object-browser-0.1.2 lib/git-object-browser/models/ref.rb
git-object-browser-0.1.1 lib/git-object-browser/models/ref.rb
git-object-browser-0.1.0 lib/git-object-browser/models/ref.rb
git-object-browser-0.0.9 lib/git-object-browser/models/ref.rb
git-object-browser-0.0.8 lib/git-object-browser/models/ref.rb
git-object-browser-0.0.7 lib/git-object-browser/models/ref.rb
git-object-browser-0.0.6 lib/git-object-browser/models/ref.rb
git-object-browser-0.0.4 lib/git-object-browser/models/ref.rb
git-object-browser-0.0.3 lib/git-object-browser/models/ref.rb