Class: EY::Deploy::Configuration
- Inherits:
-
Object
- Object
- EY::Deploy::Configuration
show all
- Defined in:
- lib/engineyard-serverside/configuration.rb
Constant Summary
collapse
- DEFAULT_CONFIG =
Thor::CoreExt::HashWithIndifferentAccess.new({
"branch" => "master",
"strategy" => "Git",
})
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
Returns a new instance of Configuration.
16
17
18
19
20
|
# File 'lib/engineyard-serverside/configuration.rb', line 16
def initialize(opts={})
@release_path = opts[:release_path]
config = JSON.parse(opts["config"] || "{}")
@configuration = DEFAULT_CONFIG.merge(config).merge(opts)
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &blk) ⇒ Object
Delegate to the configuration objects
23
24
25
|
# File 'lib/engineyard-serverside/configuration.rb', line 23
def method_missing(meth, *args, &blk)
c.key?(meth.to_s) ? c[meth.to_s] : super
end
|
Instance Attribute Details
#configuration ⇒ Object
Also known as:
c
Returns the value of attribute configuration.
11
12
13
|
# File 'lib/engineyard-serverside/configuration.rb', line 11
def configuration
@configuration
end
|
#release_path ⇒ Object
136
137
138
|
# File 'lib/engineyard-serverside/configuration.rb', line 136
def release_path
@release_path ||= File.join(release_dir, Time.now.utc.strftime("%Y%m%d%H%M%S"))
end
|
Instance Method Details
31
32
33
34
35
36
37
|
# File 'lib/engineyard-serverside/configuration.rb', line 31
def [](key)
if respond_to?(key.to_sym)
send(key.to_sym)
else
c[key]
end
end
|
#all_releases ⇒ Object
112
113
114
|
# File 'lib/engineyard-serverside/configuration.rb', line 112
def all_releases
Dir.glob("#{release_dir}/*").sort
end
|
#binstubs_path ⇒ Object
116
117
118
|
# File 'lib/engineyard-serverside/configuration.rb', line 116
def binstubs_path
release_path + '/ey_bundler_binstubs'
end
|
#copy_exclude ⇒ Object
91
92
93
|
# File 'lib/engineyard-serverside/configuration.rb', line 91
def copy_exclude
@copy_exclude ||= Array(configuration.fetch("copy_exclude", []))
end
|
#current_path ⇒ Object
124
125
126
|
# File 'lib/engineyard-serverside/configuration.rb', line 124
def current_path
File.join(deploy_to, "current")
end
|
#current_role ⇒ Object
87
88
89
|
# File 'lib/engineyard-serverside/configuration.rb', line 87
def current_role
current_roles.first
end
|
#deploy_to ⇒ Object
63
64
65
|
# File 'lib/engineyard-serverside/configuration.rb', line 63
def deploy_to
configuration['deploy_to'] || "/data/#{app}"
end
|
#environment ⇒ Object
95
96
97
|
# File 'lib/engineyard-serverside/configuration.rb', line 95
def environment
configuration['framework_env']
end
|
#exclusions ⇒ Object
140
141
142
|
# File 'lib/engineyard-serverside/configuration.rb', line 140
def exclusions
copy_exclude.map { |e| %|--exclude="#{e}"| }.join(' ')
end
|
#framework_envs ⇒ Object
120
121
122
|
# File 'lib/engineyard-serverside/configuration.rb', line 120
def framework_envs
"RAILS_ENV=#{environment} RACK_ENV=#{environment} MERB_ENV=#{environment}"
end
|
79
80
81
|
# File 'lib/engineyard-serverside/configuration.rb', line 79
def group
configuration['group'] || user
end
|
#has_key?(key) ⇒ Boolean
39
40
41
42
43
44
45
|
# File 'lib/engineyard-serverside/configuration.rb', line 39
def has_key?(key)
if respond_to?(key.to_sym)
true
else
c.has_key?(key)
end
end
|
#latest_release ⇒ Object
99
100
101
|
# File 'lib/engineyard-serverside/configuration.rb', line 99
def latest_release
all_releases.last
end
|
#migrate? ⇒ Boolean
67
68
69
|
# File 'lib/engineyard-serverside/configuration.rb', line 67
def migrate?
!!configuration['migrate']
end
|
#migration_command ⇒ Object
71
72
73
|
# File 'lib/engineyard-serverside/configuration.rb', line 71
def migration_command
configuration['migrate'] == "migrate" ? DEFAULT_CONFIG["migrate"] : configuration['migrate']
end
|
51
52
53
|
# File 'lib/engineyard-serverside/configuration.rb', line 51
def node
EY.node
end
|
#oldest_release ⇒ Object
108
109
110
|
# File 'lib/engineyard-serverside/configuration.rb', line 108
def oldest_release
all_releases.first
end
|
#previous_release(current = latest_release) ⇒ Object
103
104
105
106
|
# File 'lib/engineyard-serverside/configuration.rb', line 103
def previous_release(current=latest_release)
index = all_releases.index(current)
all_releases[index-1]
end
|
#release_dir ⇒ Object
132
133
134
|
# File 'lib/engineyard-serverside/configuration.rb', line 132
def release_dir
File.join(deploy_to, "releases")
end
|
#repository_cache ⇒ Object
59
60
61
|
# File 'lib/engineyard-serverside/configuration.rb', line 59
def repository_cache
configuration['repository_cache'] || File.join(deploy_to, "/shared/cached-copy")
end
|
#respond_to?(meth, include_private = false) ⇒ Boolean
27
28
29
|
# File 'lib/engineyard-serverside/configuration.rb', line 27
def respond_to?(meth, include_private=false)
c.key?(meth.to_s) ? true : super
end
|
55
56
57
|
# File 'lib/engineyard-serverside/configuration.rb', line 55
def revision
IO.read(File.join(latest_release, 'REVISION'))
end
|
83
84
85
|
# File 'lib/engineyard-serverside/configuration.rb', line 83
def role
node['instance_role']
end
|
#shared_path ⇒ Object
128
129
130
|
# File 'lib/engineyard-serverside/configuration.rb', line 128
def shared_path
File.join(deploy_to, "shared")
end
|
47
48
49
|
# File 'lib/engineyard-serverside/configuration.rb', line 47
def to_json
configuration.to_json
end
|
75
76
77
|
# File 'lib/engineyard-serverside/configuration.rb', line 75
def user
configuration['user'] || ENV['USER']
end
|