Class: Conspire::Conspirator

Inherits:
Object
  • Object
show all
Defined in:
lib/conspire/conspirator.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, port, name) ⇒ Conspirator

Returns a new instance of Conspirator.



5
6
7
8
# File 'lib/conspire/conspirator.rb', line 5

def initialize(host, port, name)
  # host has a trailing dot; remove it
  @host, @port, @name = host[0 .. -2], port, name
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



3
4
5
# File 'lib/conspire/conspirator.rb', line 3

def host
  @host
end

#nameObject

Returns the value of attribute name.



3
4
5
# File 'lib/conspire/conspirator.rb', line 3

def name
  @name
end

#portObject

Returns the value of attribute port.



3
4
5
# File 'lib/conspire/conspirator.rb', line 3

def port
  @port
end

Instance Method Details

#eql?(other) ⇒ Boolean

For set equality

Returns:

  • (Boolean)


25
# File 'lib/conspire/conspirator.rb', line 25

def eql?(other); self.url == other.url end

#hashObject



26
# File 'lib/conspire/conspirator.rb', line 26

def hash; url.hash end

#sync(path) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/conspire/conspirator.rb', line 10

def sync(path)
  # TODO: figure out conflictless rebasing; new content always wins. evan?
  if ENV['DEBUG']
    puts "cd #{path} && git pull --rebase #{url}"
    system "cd #{path} && git pull --rebase #{url}"
  else
    system "cd #{path} && git pull --rebase #{url} &> /dev/null"
  end or raise "could not rebase from #{url}" if ! success
end

#urlObject Also known as: to_s, inspect



20
# File 'lib/conspire/conspirator.rb', line 20

def url; "git://#{@host}:#{@port}/" end