Class: Capistrano::Alice::Release
- Inherits:
-
Object
- Object
- Capistrano::Alice::Release
- Defined in:
- lib/capistrano-alice/release_managment.rb
Instance Attribute Summary collapse
-
#deploy_reference ⇒ Object
Returns the value of attribute deploy_reference.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#id ⇒ Object
Returns the value of attribute id.
-
#number ⇒ Object
Returns the value of attribute number.
-
#path_rules ⇒ Object
Returns the value of attribute path_rules.
-
#processes ⇒ Object
Returns the value of attribute processes.
-
#repository_reference ⇒ Object
Returns the value of attribute repository_reference.
-
#servers ⇒ Object
Returns the value of attribute servers.
Instance Method Summary collapse
- #activate! ⇒ Object
- #create! ⇒ Object
- #destroy! ⇒ Object
-
#initialize(config) ⇒ Release
constructor
A new instance of Release.
Constructor Details
#initialize(config) ⇒ Release
Returns a new instance of Release.
12 13 14 15 |
# File 'lib/capistrano-alice/release_managment.rb', line 12 def initialize(config) @config = config @environment = {} end |
Instance Attribute Details
#deploy_reference ⇒ Object
Returns the value of attribute deploy_reference.
6 7 8 |
# File 'lib/capistrano-alice/release_managment.rb', line 6 def deploy_reference @deploy_reference end |
#environment ⇒ Object
Returns the value of attribute environment.
5 6 7 |
# File 'lib/capistrano-alice/release_managment.rb', line 5 def environment @environment end |
#id ⇒ Object
Returns the value of attribute id.
9 10 11 |
# File 'lib/capistrano-alice/release_managment.rb', line 9 def id @id end |
#number ⇒ Object
Returns the value of attribute number.
10 11 12 |
# File 'lib/capistrano-alice/release_managment.rb', line 10 def number @number end |
#path_rules ⇒ Object
Returns the value of attribute path_rules.
4 5 6 |
# File 'lib/capistrano-alice/release_managment.rb', line 4 def path_rules @path_rules end |
#processes ⇒ Object
Returns the value of attribute processes.
3 4 5 |
# File 'lib/capistrano-alice/release_managment.rb', line 3 def processes @processes end |
#repository_reference ⇒ Object
Returns the value of attribute repository_reference.
7 8 9 |
# File 'lib/capistrano-alice/release_managment.rb', line 7 def repository_reference @repository_reference end |
#servers ⇒ Object
Returns the value of attribute servers.
2 3 4 |
# File 'lib/capistrano-alice/release_managment.rb', line 2 def servers @servers end |
Instance Method Details
#activate! ⇒ Object
46 47 48 49 50 51 52 53 54 |
# File 'lib/capistrano-alice/release_managment.rb', line 46 def activate! Net::HTTP.start(@config.alice_host, @config.alice_port) do |http| request = Net::HTTP::Post.new("/api_v1/releases/#{@id}/activate.json") request.body = Yajl::Encoder.encode({}) request.content_type = "application/json" request['Accepts'] = "application/json" response = http.request(request) end end |
#create! ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/capistrano-alice/release_managment.rb', line 17 def create! body = { "application" => @config.application, "machines" => @servers, "processes" => @processes, "path_rules" => (@path_rules || {}).to_a, "environment" => @environment, "deploy_reference" => @deploy_reference, "repository_reference" => @repository_reference } Net::HTTP.start(@config.alice_host, @config.alice_port) do |http| request = Net::HTTP::Post.new("/api_v1/releases.json") request.body = Yajl::Encoder.encode(body) request.content_type = "application/json" request['Accepts'] = "application/json" response = http.request(request) if Net::HTTPSuccess === response response = Yajl::Parser.parse(response.body) @id = response['release']['id'] @number = response['release']['number'] @environment = response['release']['environment'] else raise "Failed to create release!" end end end |
#destroy! ⇒ Object
56 57 58 59 60 61 62 63 |
# File 'lib/capistrano-alice/release_managment.rb', line 56 def destroy! Net::HTTP.start(@config.alice_host, @config.alice_port) do |http| request = Net::HTTP::Delete.new("/api_v1/releases/#{@id}.json") request.content_type = "application/json" request['Accepts'] = "application/json" response = http.request(request) end end |