Class: Regrit::Ref
- Inherits:
-
Object
- Object
- Regrit::Ref
- Defined in:
- lib/regrit/ref.rb
Instance Attribute Summary collapse
-
#commit ⇒ Object
readonly
Returns the value of attribute commit.
-
#full_name ⇒ Object
readonly
Returns the value of attribute full_name.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
- #abbrev_commit ⇒ Object
- #branch? ⇒ Boolean
-
#initialize(repo, ref) ⇒ Ref
constructor
A new instance of Ref.
- #match?(named) ⇒ Boolean
- #tag? ⇒ Boolean
Constructor Details
#initialize(repo, ref) ⇒ Ref
Returns a new instance of Ref.
3 4 5 6 7 8 |
# File 'lib/regrit/ref.rb', line 3 def initialize(repo, ref) @repo = repo @commit, @full_name = ref.split(/\t/) @type, @name = @full_name.scan(%r#refs/([^/]+)/(.+)#).first || [nil, @full_name] raise InvalidRefsFormat.new(ref) if @name.nil? end |
Instance Attribute Details
#commit ⇒ Object (readonly)
Returns the value of attribute commit.
10 11 12 |
# File 'lib/regrit/ref.rb', line 10 def commit @commit end |
#full_name ⇒ Object (readonly)
Returns the value of attribute full_name.
10 11 12 |
# File 'lib/regrit/ref.rb', line 10 def full_name @full_name end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
10 11 12 |
# File 'lib/regrit/ref.rb', line 10 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
10 11 12 |
# File 'lib/regrit/ref.rb', line 10 def type @type end |
Instance Method Details
#abbrev_commit ⇒ Object
20 21 22 |
# File 'lib/regrit/ref.rb', line 20 def abbrev_commit commit[0...7] end |
#branch? ⇒ Boolean
16 17 18 |
# File 'lib/regrit/ref.rb', line 16 def branch? type == 'heads' end |
#match?(named) ⇒ Boolean
24 25 26 |
# File 'lib/regrit/ref.rb', line 24 def match?(named) name == named || full_name == named || [type,name].compact.join('/') == named end |
#tag? ⇒ Boolean
12 13 14 |
# File 'lib/regrit/ref.rb', line 12 def tag? type == 'tags' end |