Class: RemoteTerminal::Project
- Inherits:
-
Object
- Object
- RemoteTerminal::Project
- Defined in:
- lib/remote-terminal/project.rb
Instance Attribute Summary collapse
-
#address ⇒ Object
readonly
Returns the value of attribute address.
-
#remote_directory ⇒ Object
readonly
Returns the value of attribute remote_directory.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(dir) ⇒ Project
constructor
A new instance of Project.
- #load_config ⇒ Object
- #path_from(dir) ⇒ Object
- #path_to(dir) ⇒ Object
Constructor Details
#initialize(dir) ⇒ Project
Returns a new instance of Project.
7 8 9 10 11 12 13 14 15 16 17 18 |
# 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 |
Instance Attribute Details
#address ⇒ Object (readonly)
Returns the value of attribute address.
3 4 5 |
# File 'lib/remote-terminal/project.rb', line 3 def address @address end |
#remote_directory ⇒ Object (readonly)
Returns the value of attribute remote_directory.
5 6 7 |
# File 'lib/remote-terminal/project.rb', line 5 def remote_directory @remote_directory end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
4 5 6 |
# File 'lib/remote-terminal/project.rb', line 4 def user @user end |
Class Method Details
Instance Method Details
#load_config ⇒ Object
20 21 22 23 24 25 |
# 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) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# 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) ⇒ Object
48 49 50 51 52 53 54 55 |
# 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 |