Class: Pushwagner::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/pushwagner/environment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#configObject (readonly)

Returns the value of attribute config.



8
9
10
# File 'lib/pushwagner/environment.rb', line 8

def config
  @config
end

#currentObject

Returns the value of attribute current.



9
10
11
# File 'lib/pushwagner/environment.rb', line 9

def current
  @current
end

#versionObject

Returns the value of attribute version.



9
10
11
# File 'lib/pushwagner/environment.rb', line 9

def version
  @version
end

Instance Method Details

#environmentObject



46
47
48
# File 'lib/pushwagner/environment.rb', line 46

def environment
  environments[current] || {}
end

#environmentsObject



42
43
44
# File 'lib/pushwagner/environment.rb', line 42

def environments
  config['environments'] || {}
end

#hostsObject



50
51
52
# File 'lib/pushwagner/environment.rb', line 50

def hosts
  environment['hosts'] || []
end

#mavenObject



26
27
28
# File 'lib/pushwagner/environment.rb', line 26

def maven
  @maven = (config['maven'] ? Maven.new(config['maven'], version) : {})
end

#maven?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/pushwagner/environment.rb', line 30

def maven?
  maven.any?
end

#path_prefixObject



22
23
24
# File 'lib/pushwagner/environment.rb', line 22

def path_prefix
  config['path_prefix'] || '/srv/www'
end

#staticObject



34
35
36
# File 'lib/pushwagner/environment.rb', line 34

def static
  config['static'] || {}
end

#static?Boolean

Returns:

  • (Boolean)


38
39
40
# File 'lib/pushwagner/environment.rb', line 38

def static?
  static.any?
end

#userObject



54
55
56
# File 'lib/pushwagner/environment.rb', line 54

def user
  environment['user'] || "nobody"
end