Class: EY::Serverside::Paths
- Defined in:
- lib/engineyard-serverside/paths.rb
Defined Under Namespace
Modules: LegacyHelpers
Constant Summary collapse
- MAINTENANCE_CANDIDATES =
Maintenance page candidates in order of search preference.
[ "public/maintenance.html.custom", "public/maintenance.html.tmp", "public/maintenance.html", "public/system/maintenance.html.default", ]
- DEFAULT_MAINTENANCE_PAGE =
This one is guaranteed to exist.
Pathname.new("default_maintenance_page.html").(File.dirname(__FILE__))
Instance Attribute Summary collapse
-
#deploy_root ⇒ Object
readonly
Returns the value of attribute deploy_root.
-
#home ⇒ Object
readonly
Returns the value of attribute home.
Class Method Summary collapse
-
.def_path(name, parts) ⇒ Object
Define methods that get us paths.
Instance Method Summary collapse
- #active_release ⇒ Object
- #all_releases ⇒ Object
- #deploy_hook(hook_name) ⇒ Object
- #deploy_key ⇒ Object
- #deployed? ⇒ Boolean
-
#initialize(opts) ⇒ Paths
constructor
A new instance of Paths.
-
#latest_release ⇒ Object
deploy_root/releases/<latest timestamp>.
- #maintenance_page_candidates ⇒ Object
-
#path(root, *parts) ⇒ Object
Load a path given a root and more parts.
-
#previous_release(from_release = latest_release) ⇒ Object
deploy_root/releases/<release before argument release path>.
- #repository_cache ⇒ Object
- #rollback ⇒ Object
- #ssh_wrapper ⇒ Object
Constructor Details
#initialize(opts) ⇒ Paths
Returns a new instance of Paths.
87 88 89 90 91 92 93 94 |
# File 'lib/engineyard-serverside/paths.rb', line 87 def initialize(opts) @opts = opts @home = Pathname.new(@opts[:home] || ENV['HOME']) @app_name = @opts[:app_name] @active_release = Pathname.new(@opts[:active_release]) if @opts[:active_release] @repository_cache = Pathname.new(@opts[:repository_cache]) if @opts[:repository_cache] @deploy_root = Pathname.new(@opts[:deploy_root] || "/data/#{@app_name}") end |
Instance Attribute Details
#deploy_root ⇒ Object (readonly)
Returns the value of attribute deploy_root.
58 59 60 |
# File 'lib/engineyard-serverside/paths.rb', line 58 def deploy_root @deploy_root end |
#home ⇒ Object (readonly)
Returns the value of attribute home.
58 59 60 |
# File 'lib/engineyard-serverside/paths.rb', line 58 def home @home end |
Class Method Details
.def_path(name, parts) ⇒ Object
Define methods that get us paths
49 50 51 |
# File 'lib/engineyard-serverside/paths.rb', line 49 def self.def_path(name, parts) define_method(name.to_sym) { path(*parts) } end |
Instance Method Details
#active_release ⇒ Object
112 113 114 |
# File 'lib/engineyard-serverside/paths.rb', line 112 def active_release @active_release ||= path(:releases, Time.now.utc.strftime("%Y%m%d%H%M%S")) end |
#all_releases ⇒ Object
116 117 118 |
# File 'lib/engineyard-serverside/paths.rb', line 116 def all_releases @all_releases ||= Pathname.glob(releases.join('*')).sort end |
#deploy_hook(hook_name) ⇒ Object
104 105 106 |
# File 'lib/engineyard-serverside/paths.rb', line 104 def deploy_hook(hook_name) path(:active_release, 'deploy', "#{hook_name}.rb") end |
#deploy_key ⇒ Object
96 97 98 |
# File 'lib/engineyard-serverside/paths.rb', line 96 def deploy_key path(:home, '.ssh', "#{@app_name}-deploy-key") end |
#deployed? ⇒ Boolean
135 136 137 |
# File 'lib/engineyard-serverside/paths.rb', line 135 def deployed? !!latest_release end |
#latest_release ⇒ Object
deploy_root/releases/<latest timestamp>
131 132 133 |
# File 'lib/engineyard-serverside/paths.rb', line 131 def latest_release all_releases.last end |
#maintenance_page_candidates ⇒ Object
139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/engineyard-serverside/paths.rb', line 139 def maintenance_page_candidates if latest_release candidates = MAINTENANCE_CANDIDATES.map do |file| path(:latest_release, file) end else candidates = [] end candidates << DEFAULT_MAINTENANCE_PAGE candidates end |
#path(root, *parts) ⇒ Object
Load a path given a root and more parts
54 55 56 |
# File 'lib/engineyard-serverside/paths.rb', line 54 def path(root, *parts) send(root).join(*parts) end |
#previous_release(from_release = latest_release) ⇒ Object
deploy_root/releases/<release before argument release path>
121 122 123 124 125 126 127 128 |
# File 'lib/engineyard-serverside/paths.rb', line 121 def previous_release(from_release=latest_release) index = all_releases.index(from_release) if index && index > 0 all_releases[index-1] else nil end end |
#repository_cache ⇒ Object
108 109 110 |
# File 'lib/engineyard-serverside/paths.rb', line 108 def repository_cache @repository_cache ||= default_repository_cache end |
#rollback ⇒ Object
151 152 153 154 155 156 157 |
# File 'lib/engineyard-serverside/paths.rb', line 151 def rollback if deployed? && previous_release self.class.new(@opts.dup.merge(:active_release => previous_release)) else nil end end |
#ssh_wrapper ⇒ Object
100 101 102 |
# File 'lib/engineyard-serverside/paths.rb', line 100 def ssh_wrapper path(:shared_config, "#{@app_name}-ssh-wrapper") end |