Class: Rubber::Configuration::Environment::BoundEnv
- Inherits:
-
HashValueProxy
- Object
- Hash
- HashValueProxy
- Rubber::Configuration::Environment::BoundEnv
- Defined in:
- lib/rubber/environment.rb
Instance Attribute Summary collapse
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#roles ⇒ Object
readonly
Returns the value of attribute roles.
Attributes inherited from HashValueProxy
Instance Method Summary collapse
-
#bind_config(global) ⇒ Object
Forces role/host overrides into config.
- #full_host ⇒ Object
-
#initialize(global, roles, host, env) ⇒ BoundEnv
constructor
A new instance of BoundEnv.
- #local_platform ⇒ Object
- #local_posix? ⇒ Boolean
- #local_windows? ⇒ Boolean
- #method_missing(method_id) ⇒ Object
Methods inherited from HashValueProxy
#[], #each, #expand, #expand_string, #known_roles, #rubber_instances, #to_a
Constructor Details
#initialize(global, roles, host, env) ⇒ BoundEnv
Returns a new instance of BoundEnv.
219 220 221 222 223 224 225 |
# File 'lib/rubber/environment.rb', line 219 def initialize(global, roles, host, env) @roles = roles @host = host @env = env bound_global = bind_config(global) super(nil, bound_global) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_id) ⇒ Object
267 268 269 |
# File 'lib/rubber/environment.rb', line 267 def method_missing(method_id) self[method_id.id2name] end |
Instance Attribute Details
#env ⇒ Object (readonly)
Returns the value of attribute env.
217 218 219 |
# File 'lib/rubber/environment.rb', line 217 def env @env end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
216 217 218 |
# File 'lib/rubber/environment.rb', line 216 def host @host end |
#roles ⇒ Object (readonly)
Returns the value of attribute roles.
215 216 217 |
# File 'lib/rubber/environment.rb', line 215 def roles @roles end |
Instance Method Details
#bind_config(global) ⇒ Object
Forces role/host overrides into config
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 |
# File 'lib/rubber/environment.rb', line 232 def bind_config(global) global = global.clone() role_overrides = global.delete("roles") || {} env_overrides = global.delete("environments") || {} host_overrides = global.delete("hosts") || {} Array(roles).each do |role| Array(role_overrides[role]).each do |k, v| global[k] = Environment.combine(global[k], v) end end Array(env_overrides[env]).each do |k, v| global[k] = Environment.combine(global[k], v) end Array(host_overrides[host]).each do |k, v| global[k] = Environment.combine(global[k], v) end global end |
#full_host ⇒ Object
227 228 229 |
# File 'lib/rubber/environment.rb', line 227 def full_host @full_host ||= "#{host}.#{domain}" rescue nil end |
#local_platform ⇒ Object
255 256 257 |
# File 'lib/rubber/environment.rb', line 255 def local_platform RbConfig::CONFIG['host_os'] =~ /mswin|mingw/ ? 'windows' : 'posix' end |
#local_posix? ⇒ Boolean
263 264 265 |
# File 'lib/rubber/environment.rb', line 263 def local_posix? local_platform == 'posix' end |
#local_windows? ⇒ Boolean
259 260 261 |
# File 'lib/rubber/environment.rb', line 259 def local_windows? local_platform == 'windows' end |