Class: Git::Remote
- Inherits:
-
Object
- Object
- Git::Remote
- Defined in:
- lib/Git/Remote.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
class << self.
-
#url ⇒ Object
Returns the value of attribute url.
Class Method Summary collapse
- .add(remote_name, remote_url) ⇒ Object
- .add_command(remote_name, remote_url) ⇒ Object
- .all ⇒ Object
- .exist?(remote_name) ⇒ Boolean
- .find(remote_name) ⇒ Object
- .parse_line(remote_output_line) ⇒ Object
- .remote_output ⇒ Object
- .remove(remote_name, remote_url) ⇒ Object
- .remove_command(remote_name) ⇒ Object
Instance Method Summary collapse
-
#initialize(name:, url:) ⇒ Remote
constructor
A new instance of Remote.
- #remove ⇒ Object (also: #delete)
- #to_s ⇒ Object
Constructor Details
#initialize(name:, url:) ⇒ Remote
Returns a new instance of Remote.
72 73 74 75 |
# File 'lib/Git/Remote.rb', line 72 def initialize(name:, url:) @name = name @url = url end |
Instance Attribute Details
#name ⇒ Object
class << self
69 70 71 |
# File 'lib/Git/Remote.rb', line 69 def name @name end |
#url ⇒ Object
Returns the value of attribute url.
70 71 72 |
# File 'lib/Git/Remote.rb', line 70 def url @url end |
Class Method Details
.add(remote_name, remote_url) ⇒ Object
51 52 53 |
# File 'lib/Git/Remote.rb', line 51 def add(remote_name, remote_url) system add_command(remote_name, remote_url) end |
.add_command(remote_name, remote_url) ⇒ Object
47 48 49 |
# File 'lib/Git/Remote.rb', line 47 def add_command(remote_name, remote_url) ['git remote add', remote_name, remote_url].join(' ') end |
.all ⇒ Object
37 38 39 40 41 |
# File 'lib/Git/Remote.rb', line 37 def all remote_output.split("\n").collect do |remote| parse_line(remote) end.uniq{|remote| remote.name} end |
.exist?(remote_name) ⇒ Boolean
63 64 65 |
# File 'lib/Git/Remote.rb', line 63 def exist?(remote_name) !!find(remote_name) end |
.find(remote_name) ⇒ Object
43 44 45 |
# File 'lib/Git/Remote.rb', line 43 def find(remote_name) all.detect{|remote| remote.name == remote_name} end |
.parse_line(remote_output_line) ⇒ Object
28 29 30 31 |
# File 'lib/Git/Remote.rb', line 28 def parse_line(remote_output_line) name, url = remote_output_line.split new(name: name, url: url) end |
.remote_output ⇒ Object
33 34 35 |
# File 'lib/Git/Remote.rb', line 33 def remote_output `git remote --verbose` end |
.remove(remote_name, remote_url) ⇒ Object
59 60 61 |
# File 'lib/Git/Remote.rb', line 59 def remove(remote_name, remote_url) system remove_command(remote_name) end |
.remove_command(remote_name) ⇒ Object
55 56 57 |
# File 'lib/Git/Remote.rb', line 55 def remove_command(remote_name) ['git remote remove', remote_name].join(' ') end |
Instance Method Details
#remove ⇒ Object Also known as: delete
77 78 79 |
# File 'lib/Git/Remote.rb', line 77 def remove self.class.remove(@name, @url) end |
#to_s ⇒ Object
82 83 84 |
# File 'lib/Git/Remote.rb', line 82 def to_s "#{@name} #{@url}" end |