Class: Reservoir::Project
- Inherits:
-
Object
- Object
- Reservoir::Project
- Defined in:
- lib/reservoir/project.rb
Instance Attribute Summary collapse
-
#display ⇒ Object
Returns the value of attribute display.
-
#file ⇒ Object
Returns the value of attribute file.
-
#remote_server ⇒ Object
Returns the value of attribute remote_server.
-
#remote_user ⇒ Object
Returns the value of attribute remote_user.
-
#scripts ⇒ Object
Returns the value of attribute scripts.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(data = {}) ⇒ Project
constructor
A new instance of Project.
- #name ⇒ Object
- #template(clazz) ⇒ Object
Constructor Details
#initialize(data = {}) ⇒ Project
Returns a new instance of Project.
7 8 9 10 11 12 13 |
# File 'lib/reservoir/project.rb', line 7 def initialize(data = {}) @file = data[:file] @remote_user = data[:remote_user] @remote_server = data[:remote_server] @scripts = data[:scripts] || [] @display = Project.sym_entries(data[:display]) || :stdio end |
Instance Attribute Details
#display ⇒ Object
Returns the value of attribute display.
5 6 7 |
# File 'lib/reservoir/project.rb', line 5 def display @display end |
#file ⇒ Object
Returns the value of attribute file.
5 6 7 |
# File 'lib/reservoir/project.rb', line 5 def file @file end |
#remote_server ⇒ Object
Returns the value of attribute remote_server.
5 6 7 |
# File 'lib/reservoir/project.rb', line 5 def remote_server @remote_server end |
#remote_user ⇒ Object
Returns the value of attribute remote_user.
5 6 7 |
# File 'lib/reservoir/project.rb', line 5 def remote_user @remote_user end |
#scripts ⇒ Object
Returns the value of attribute scripts.
5 6 7 |
# File 'lib/reservoir/project.rb', line 5 def scripts @scripts end |
Class Method Details
.load_from_file(file) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/reservoir/project.rb', line 15 def self.load_from_file(file) = YAML::load( File.open( file ) ) default_args = { file: file, scripts: ["scripts"].each.collect { |script| script["name"] }, display: sym_entries(["display"]) } all_projects = [] all_servers = ["remotes"] if all_servers.nil? all_projects << Project.new(default_args) else all_servers.each do |remote| all_projects << Project.new(default_args.merge( remote_user: remote["user"], remote_server: remote["server"], display: resolve_placeholders(default_args[:display],remote))) end end all_projects end |
Instance Method Details
#name ⇒ Object
34 35 36 37 38 |
# File 'lib/reservoir/project.rb', line 34 def name return "local" if @remote_server.nil? return @remote_server if @remote_user.nil? "#{@remote_user}@#{@remote_server}" end |
#template(clazz) ⇒ Object
30 31 32 |
# File 'lib/reservoir/project.rb', line 30 def template(clazz) clazz.new(remote_user: @remote_user, remote_server: @remote_server) end |