class RemoteTerminal::Project

Attributes

address[R]
remote_directory[R]
user[R]

Public Class Methods

find(dir) click to toggle source
# File lib/remote-terminal/project.rb, line 27
def Project.find(dir)
  if File.exist?(File.join(dir, '.remote-terminal.yml'))
    return Project.new(dir)
  else
    return Project.find(File.join(dir, '..'))
  end
end
new(dir) click to toggle source
# File lib/remote-terminal/project.rb, line 7
def initialize(dir)
  tmp = []
  dir.split('/').each do |d|
    if d == '..'
      tmp = tmp[0..-2]
    else
      tmp << d
    end
  end
  @dir = tmp.join('/')
  load_config
end

Public Instance Methods

load_config() click to toggle source
# File lib/remote-terminal/project.rb, line 20
def load_config
  config = YAML::load(File.open(File.join(@dir, '.remote-terminal.yml')))
  @address = config['address']
  @user = config['user']
  @remote_directory = config['remote_directory']
end
path_from(dir) click to toggle source
# File lib/remote-terminal/project.rb, line 35
def path_from(dir)
  path = ''
  d = dir.gsub(@dir, '').split('/').keep_if {|d| d != ''}
  if d == []
    path = './'
  else
    d.each do |x|
      path += '../'
    end
  end
  return path[0..-2]
end
path_to(dir) click to toggle source
# File lib/remote-terminal/project.rb, line 48
def path_to(dir)
  d = dir.gsub(@dir, '').split('/').keep_if {|d| d != ''}
  if d == []
    return ''
  else
    return "#{d.join('/')}/"
  end
end