Module: Pairzone::Api::PairzoneConnection

Included in:
Pairzone
Defined in:
lib/pairzone/api/pairzone_connection.rb

Instance Method Summary collapse

Instance Method Details

#connect(identity) ⇒ Object



4
5
6
7
# File 'lib/pairzone/api/pairzone_connection.rb', line 4

def connect(identity)
  Logger.info("Connecting to Pairzone...")
  shell(identity).run(%{ssh -i #{identity} -t pairzone@#{ip} "/usr/local/bin/pairzone-tmux.sh"})
end

#fetch_code(identity) ⇒ Object



18
19
20
21
# File 'lib/pairzone/api/pairzone_connection.rb', line 18

def fetch_code(identity)
  shell(identity).git "git fetch #{git_location} master:pairzone"
  Logger.info("Your git code has been placed in a local 'pairzone' branch. To merge this code into your HEAD, run this commmand:\n\ngit merge pairzone")
end

#git_locationObject



27
28
29
# File 'lib/pairzone/api/pairzone_connection.rb', line 27

def git_location
  "pairzone@#{ip}:#{project_name}"
end

#push_code(identity) ⇒ Object



9
10
11
12
13
14
15
16
# File 'lib/pairzone/api/pairzone_connection.rb', line 9

def push_code(identity)
  Logger.debug("pushing local code to pairzone instance")
  shell(identity).remote(ip, "git init #{project_name} &&
    cd #{project_name} &&
    git config receive.denyCurrentBranch ignore")
  shell(identity).git("git push --mirror #{git_location}")
  shell(identity).remote(ip, "cd #{project_name} && git reset --hard")
end

#shell(identity) ⇒ Object



23
24
25
# File 'lib/pairzone/api/pairzone_connection.rb', line 23

def shell(identity)
  @shell ||= Shell.new(identity)
end