Class: Pushwagner::Environment
- Inherits:
-
Object
- Object
- Pushwagner::Environment
- Defined in:
- lib/pushwagner/environment.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#current ⇒ Object
Returns the value of attribute current.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #environment ⇒ Object
- #environments ⇒ Object
- #hosts ⇒ Object
-
#initialize(opts = {}) ⇒ Environment
constructor
A new instance of Environment.
- #maven ⇒ Object
- #maven? ⇒ Boolean
- #path_prefix ⇒ Object
- #static ⇒ Object
- #static? ⇒ Boolean
- #user ⇒ Object
Constructor Details
#initialize(opts = {}) ⇒ Environment
Returns a new instance of Environment.
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/pushwagner/environment.rb', line 11 def initialize(opts = {}) opts = HashWithIndifferentAccess.new(opts) config_file = look_for_config_file(opts[:config_file]) @version = opts[:version] && opts[:version].to_s @current = opts[:environment] || 'development' @config = HashWithIndifferentAccess.new(YAML::load_file(config_file) || {}) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
8 9 10 |
# File 'lib/pushwagner/environment.rb', line 8 def config @config end |
#current ⇒ Object
Returns the value of attribute current.
9 10 11 |
# File 'lib/pushwagner/environment.rb', line 9 def current @current end |
#version ⇒ Object
Returns the value of attribute version.
9 10 11 |
# File 'lib/pushwagner/environment.rb', line 9 def version @version end |
Instance Method Details
#environment ⇒ Object
46 47 48 |
# File 'lib/pushwagner/environment.rb', line 46 def environment environments[current] || {} end |
#environments ⇒ Object
42 43 44 |
# File 'lib/pushwagner/environment.rb', line 42 def environments config['environments'] || {} end |
#hosts ⇒ Object
50 51 52 |
# File 'lib/pushwagner/environment.rb', line 50 def hosts environment['hosts'] || [] end |
#maven ⇒ Object
26 27 28 |
# File 'lib/pushwagner/environment.rb', line 26 def maven @maven = (config['maven'] ? Maven.new(config['maven'], version) : {}) end |
#maven? ⇒ Boolean
30 31 32 |
# File 'lib/pushwagner/environment.rb', line 30 def maven? maven.any? end |
#path_prefix ⇒ Object
22 23 24 |
# File 'lib/pushwagner/environment.rb', line 22 def path_prefix config['path_prefix'] || '/srv/www' end |
#static ⇒ Object
34 35 36 |
# File 'lib/pushwagner/environment.rb', line 34 def static config['static'] || {} end |
#static? ⇒ Boolean
38 39 40 |
# File 'lib/pushwagner/environment.rb', line 38 def static? static.any? end |
#user ⇒ Object
54 55 56 |
# File 'lib/pushwagner/environment.rb', line 54 def user environment['user'] || "nobody" end |