capistrano-isitdeployed 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3553474a256853809eebe7aa7aa06ea5e07352bd
4
+ data.tar.gz: 697a5e20c409a10c9a86aae82c4b6c77cd947fe6
5
+ SHA512:
6
+ metadata.gz: f23411e27b9466f56ec0b802fc610e84f34317c6731fe8d661fd996a83126fd86e69531fe308953f6848f27b79120b1f8bebf14392ee0b28e400315dcc976257
7
+ data.tar.gz: 832ea7ccb6667af11fcbcb2d4251a6ba7c65420f7d74d079a1a098179bc5b7c52206d3bea14be0651121a44727f872bad67ab57ed1a03b46fb3dcb00ea678d94
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Thomas VIAL
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Manifest.yml ADDED
@@ -0,0 +1,9 @@
1
+ - Manifest.yml
2
+ - README.md
3
+ - Rakefile
4
+ - LICENSE.txt
5
+ - lib/capistrano/isitdeployed.rb
6
+ - lib/capistrano/isitdeployed/version.rb
7
+ - lib/capistrano/isitdeployed/config.rb
8
+ - lib/capistrano/isitdeployed/debug.rb
9
+ - lib/capistrano/isitdeployed/template/isitdeployed.yml
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Capistrano::Isitdeployed
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'capistrano-isitdeployed'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install capistrano-isitdeployed
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,9 @@
1
+ module Capistrano
2
+ module Isitdeployed
3
+
4
+ ENDPOINT = 'http://staging.isitdeployed.com'
5
+ CONFIG_SRC = 'template/isitdeployed.yml'
6
+ CONFIG_DEST = 'config/isitdeployed.yml'
7
+
8
+ end
9
+ end
@@ -0,0 +1,37 @@
1
+ module Capistrano
2
+ module Isitdeployed
3
+ module Debug
4
+ def self.load_into(configuration)
5
+ configuration.load do
6
+ ############################################################
7
+ # /!\ DEBUG ONLY
8
+ # Do not use unless you want to poluate your data
9
+ namespace :isit do
10
+ namespace :check do
11
+ desc "Check feature for success"
12
+ task :success do
13
+ find_and_execute_task("isit:deploy")
14
+ sleep(5)
15
+ find_and_execute_task("isit:status:success")
16
+ find_and_execute_task("isit:update")
17
+ end
18
+
19
+ desc "Check feature for rollback"
20
+ task :rollback do
21
+ find_and_execute_task("isit:deploy")
22
+ sleep(5)
23
+ find_and_execute_task("isit:status:rollback")
24
+ find_and_execute_task("isit:update")
25
+ end
26
+ end
27
+ ############################################################
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+
35
+ if Capistrano::Configuration.instance
36
+ Capistrano::Isitdeployed::Debug.load_into(Capistrano::Configuration.instance(:must_exist))
37
+ end
@@ -0,0 +1,10 @@
1
+ #
2
+ # isitdeploye.yml configuration file
3
+ #
4
+
5
+ # required configuration
6
+ isitdeployed_pid: x
7
+ isitdeployed_token: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
8
+
9
+ # optional parameters:
10
+ # "isitdeployed_app", to override :application variable
@@ -0,0 +1,5 @@
1
+ module Capistrano
2
+ module Isitdeployed
3
+ VERSION = "0.0.2"
4
+ end
5
+ end
@@ -0,0 +1,110 @@
1
+ require 'capistrano/isitdeployed/version'
2
+ require 'capistrano/isitdeployed/config'
3
+ require 'capistrano/isitdeployed/debug'
4
+ require 'active_support/core_ext'
5
+ require 'rest_client'
6
+
7
+ module Capistrano
8
+ module Isitdeployed
9
+
10
+ CONFIG = YAML.load_file(Capistrano::Isitdeployed::CONFIG_DEST)
11
+
12
+ def self.timestamp
13
+ return Time.now.utc.strftime("%Y%m%d%H%M%S")
14
+ end
15
+
16
+ def self.load_into(configuration)
17
+ configuration.load do
18
+
19
+ # task hooks
20
+ before 'deploy', 'isit:deploy'
21
+ after 'deploy', 'isit:status:success'
22
+ after 'deploy:rollback', 'isit:status:rollback'
23
+ after 'isit:status_success', 'isit:update'
24
+ after 'isit:status_rollback', 'isit:update'
25
+
26
+ # task definitions
27
+ namespace :isit do
28
+
29
+ desc "Creates a configuration file"
30
+ task :setup do
31
+ if File.exists?('config/isitdeployed.yml')
32
+ logger.trace "WARNING: A configuration file already exists. Remove it before running setup again."
33
+ else
34
+ path = File.dirname(File.expand_path(__FILE__))
35
+ source = path + '/isitdeployed/' + Capistrano::Isitdeployed::CONFIG_SRC
36
+ dest = Capistrano::Isitdeployed::CONFIG_DEST
37
+ FileUtils.cp source, dest
38
+ logger.trace "IsItDeployed > #"
39
+ logger.trace "IsItDeployed > # A configuration file '#{dest}' has been created."
40
+ logger.trace "IsItDeployed > # Please edit this file before your next deploy."
41
+ logger.trace "IsItDeployed > #"
42
+ end
43
+ end
44
+
45
+ desc "Creates a new deploy using the API"
46
+ task :deploy do
47
+ if File.exists?('config/isitdeployed.yml')
48
+ else
49
+ logger.trace "IsItDeployed > WARNING: No configuration file found, please run cap 'isit:setup'"
50
+ end
51
+ started = Capistrano::Isitdeployed.timestamp
52
+ RestClient.post(Capistrano::Isitdeployed::ENDPOINT + "/p/#{Capistrano::Isitdeployed::CONFIG['isitdeployed_pid']}/d", { :status => 1, :platform => "#{stage}", :release => "#{release_name}", :started => started, :token => Capistrano::Isitdeployed::CONFIG['isitdeployed_token'] }.to_json, :content_type => :json, :accept => :json, :timeout => 5, :open_timeout => 5){ |response, request, result| response
53
+ case response.code
54
+ when 201
55
+ logger.trace "IsItDeployed > New deploy created for #{application} to #{stage} with version: #{release_name}"
56
+ logger.trace "IsItDeployed > URL is #{Capistrano::Isitdeployed::ENDPOINT}/p/#{Capistrano::Isitdeployed::CONFIG['isitdeployed_pid']}"
57
+ set(:isitdeployed_did, response)
58
+ set(:isitdeployed_started, started)
59
+ set(:isitdeployed_created, 1)
60
+ when 401
61
+ logger.trace "IsItDeployed > ERROR: Invalid token. Check your 'isitdeployed.yml'"
62
+ set(:isitdeployed_created, 0)
63
+ else
64
+ logger.trace "IsItDeployed > ERROR: Can't create deploy, server returned code #{response.code}"
65
+ set(:isitdeployed_created, 0)
66
+ end
67
+ }
68
+ end
69
+
70
+ namespace :status do
71
+ desc "Set the deploy status to success locally"
72
+ task :success do
73
+ set(:isitdeployed_status, 2)
74
+ end
75
+
76
+ desc "Set the deploy status to rollback locally"
77
+ task :rollback do
78
+ set(:isitdeployed_status, 3)
79
+ end
80
+ end
81
+
82
+ desc "Updates deploy status using the API (succes or rollback)"
83
+ task :update do
84
+ if isitdeployed_created === 1
85
+ stopped = Capistrano::Isitdeployed.timestamp
86
+ duration = stopped.to_i - isitdeployed_started.to_i
87
+ RestClient.put(Capistrano::Isitdeployed::ENDPOINT + "/p/#{Capistrano::Isitdeployed::CONFIG['isitdeployed_pid']}/d/#{isitdeployed_did}", { :status => isitdeployed_status, :stopped => stopped, :duration => duration, :token => Capistrano::Isitdeployed::CONFIG['isitdeployed_token'] }.to_json, :content_type => :json, :accept => :json, :timeout => 5, :open_timeout => 5){ |response, request, result| response
88
+ case response.code
89
+ when 204
90
+ logger.trace "IsItDeployed > Deploy ##{isitdeployed_did} has been updated for #{application} to #{stage}."
91
+ when 401
92
+ logger.trace "IsItDeployed > ERROR: Invalid token. Check your 'isitdeployed.yml'"
93
+ else
94
+ logger.trace "IsItDeployed > ERROR: Can't create deploy, server returned #{response.code}"
95
+ end
96
+ }
97
+ end
98
+ end
99
+
100
+ end
101
+ end
102
+ end
103
+ end
104
+ end
105
+
106
+ Capistrano.plugin :cdm, Capistrano::Isitdeployed
107
+
108
+ if Capistrano::Configuration.instance
109
+ Capistrano::Isitdeployed.load_into(Capistrano::Configuration.instance(:must_exist))
110
+ end
metadata ADDED
@@ -0,0 +1,61 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: capistrano-isitdeployed
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Thomas VIAL
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2013-03-27 00:00:00 Z
13
+ dependencies: []
14
+
15
+ description: This is a pre-alpha build for test purpose.
16
+ email:
17
+ - rubygems@ifusio.com
18
+ executables: []
19
+
20
+ extensions: []
21
+
22
+ extra_rdoc_files: []
23
+
24
+ files:
25
+ - Manifest.yml
26
+ - README.md
27
+ - Rakefile
28
+ - LICENSE.txt
29
+ - lib/capistrano/isitdeployed.rb
30
+ - lib/capistrano/isitdeployed/version.rb
31
+ - lib/capistrano/isitdeployed/config.rb
32
+ - lib/capistrano/isitdeployed/debug.rb
33
+ - lib/capistrano/isitdeployed/template/isitdeployed.yml
34
+ homepage: http://tvi.al
35
+ licenses: []
36
+
37
+ metadata: {}
38
+
39
+ post_install_message:
40
+ rdoc_options: []
41
+
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - &id001
47
+ - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: "0"
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - *id001
53
+ requirements: []
54
+
55
+ rubyforge_project:
56
+ rubygems_version: 2.0.3
57
+ signing_key:
58
+ specification_version: 4
59
+ summary: This is a pre-alpha build for test purpose.
60
+ test_files: []
61
+