Class: MultiGit::RefSpec

Inherits:
Struct
  • Object
show all
Extended by:
Utils::AbstractMethods
Defined in:
lib/multi_git/refspec.rb

Overview

A RefSpec describes which and how references are updated during push and pull.

It basically says: set the “to” ref to the target of “from”

Examples:

refspecs = MultiGit::RefSpec.parse('master')

Defined Under Namespace

Classes: Parser

Constant Summary collapse

DEFAULT_PARSER =
Parser.new('refs/remotes/origin/')

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utils::AbstractMethods

abstract

Constructor Details

#initialize(from, to, forced = false) ⇒ RefSpec

Returns a new instance of RefSpec.

Parameters:

  • from (String)
  • to (String)
  • forced (Boolean) (defaults to: false)


29
30
31
# File 'lib/multi_git/refspec.rb', line 29

def initialize(from,to,forced = false)
  super
end

Instance Attribute Details

#forcedBoolean Also known as: forced?

Returns:

  • (Boolean)


11
12
13
# File 'lib/multi_git/refspec.rb', line 11

def forced
  @forced
end

#fromString

Returns:

  • (String)


11
12
13
# File 'lib/multi_git/refspec.rb', line 11

def from
  @from
end

#toString

Returns:

  • (String)


11
12
13
# File 'lib/multi_git/refspec.rb', line 11

def to
  @to
end

Class Method Details

.parse(arg) ⇒ Object



122
123
124
# File 'lib/multi_git/refspec.rb', line 122

def parse(arg)
  DEFAULT_PARSER[arg].first
end

Instance Method Details

#inspectObject



33
34
35
# File 'lib/multi_git/refspec.rb', line 33

def inspect
  ['#<',self.class,' ',forced ? '+':'',from,':',to,'>'].join
end

#to_sObject



37
38
39
# File 'lib/multi_git/refspec.rb', line 37

def to_s
  [forced ? '+':'',from,':',to].join
end