Class: Kleiber::Project
- Inherits:
-
Object
- Object
- Kleiber::Project
- Includes:
- Commands
- Defined in:
- lib/kleiber/project.rb
Overview
Provides api to control such project
Constant Summary collapse
- VARS =
{ host: 'HOST', guest_port: 'PORT' }
Instance Attribute Summary collapse
-
#guest_port ⇒ Object
readonly
Returns the value of attribute guest_port.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#host_port ⇒ Object
readonly
Returns the value of attribute host_port.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
Instance Method Summary collapse
-
#command_with(command, params) ⇒ String
Returns command with option to run.
- #env ⇒ Object
-
#environment ⇒ Hash
Return env variables of this project.
-
#initialize(settings) ⇒ Project
constructor
A new instance of Project.
- #tasks ⇒ Object
Methods included from Commands
#apply_env_line, #handle_halt, #handle_reload, #handle_ssh, #handle_up, #in_machine, #scriptify, #ssh_exec_line, #tasks_line, #terminal_execute, #vagrant, #vagrant_, #vagrant_destroy, #vagrant_halt, #vagrant_provision, #vagrant_reload, #vagrant_ssh, #vagrant_up, #with_tmpfile_script
Constructor Details
#initialize(settings) ⇒ Project
Returns a new instance of Project.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/kleiber/project.rb', line 9 def initialize(settings) @name = settings[:name] @prefix = settings[:prefix] @path = settings[:path] @guest_port = settings[:guest_port] @host_port = settings[:host_port] @host = settings[:host] @tasks = settings[:tasks] @env = settings[:env] end |
Instance Attribute Details
#guest_port ⇒ Object (readonly)
Returns the value of attribute guest_port.
8 9 10 |
# File 'lib/kleiber/project.rb', line 8 def guest_port @guest_port end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
8 9 10 |
# File 'lib/kleiber/project.rb', line 8 def host @host end |
#host_port ⇒ Object (readonly)
Returns the value of attribute host_port.
8 9 10 |
# File 'lib/kleiber/project.rb', line 8 def host_port @host_port end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'lib/kleiber/project.rb', line 8 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'lib/kleiber/project.rb', line 8 def path @path end |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
8 9 10 |
# File 'lib/kleiber/project.rb', line 8 def prefix @prefix end |
Instance Method Details
#command_with(command, params) ⇒ String
Returns command with option to run
50 51 52 |
# File 'lib/kleiber/project.rb', line 50 def command_with(command, params) ["cd #{path}", send("handle_#{command}", params)].join(' && ') end |
#env ⇒ Object
25 26 27 |
# File 'lib/kleiber/project.rb', line 25 def env @env || {} end |
#environment ⇒ Hash
Return env variables of this project
35 36 37 38 39 |
# File 'lib/kleiber/project.rb', line 35 def environment @env_vars ||= VARS.reduce({}) do |hash, (key, value)| hash.merge("#{prefix}_#{value}" => send(key)) end.merge(env) end |
#tasks ⇒ Object
29 30 31 |
# File 'lib/kleiber/project.rb', line 29 def tasks @tasks || {} end |