capistrano-isitdeployed 0.0.4 → 0.0.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 2471b60d8c1a097e0925f3d20ac2f5c5244b9a5d
4
- data.tar.gz: 2fb69acafb514ac5643b4df3e64bd8666e4c8e29
5
2
  SHA512:
6
- metadata.gz: f0cc676f781843e51009cbdee245ab8e035e66c85ce4d5728b123bf9bd84261088c54178d214d77a85afd8dbc7ccabf54d759d873cc61b5118e7384c42bf057c
7
- data.tar.gz: 4b321c1a11524ca9f0649603cc2f84eb0203f5ad3e3e78c247a9e4ac47ea3cdaf8e6a497e19aa2e061567eef82618e4d11914eb5de64a85a3d71f06cee2ea2f3
3
+ metadata.gz: 8228be5bb77d78ccd4cfe36ba02c2f74ebf6686c67fef258e41c4b193bdf00b623b4cf91be85473667d48be0403ea7d80210d2509e0cdbc8d4b9a42970493189
4
+ data.tar.gz: 5b340d8c407ac08fcd6459928e9ad9c3e3bb254ef0773f9007f83dfe6f573eec510f8ff71e248ea4289b6a97f23db3cd4aacfe15aa748ceb1b881394ad397eda
5
+ SHA1:
6
+ metadata.gz: cbff4dfd443b38406ea5e65bc6ab9c1c0977f26e
7
+ data.tar.gz: f6647ecdfcb4feef608aaaae17417a9aedb0f6d9
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Isitdeployed
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
@@ -11,12 +11,8 @@ module Capistrano
11
11
  return Time.now.utc.strftime("%Y%m%d%H%M%S")
12
12
  end
13
13
 
14
- def self.get_config
15
- if File.exists?(CONFIG_DEST)
16
- return YAML.load_file(CONFIG_DEST)
17
- else
18
- logger.trace "IsItDeployed > WARNING: No configuration file found, please run cap 'isit:setup'"
19
- end
14
+ def self.load_user_config
15
+ return YAML.load_file(CONFIG_DEST)
20
16
  end
21
17
 
22
18
  def self.load_into(configuration)
@@ -50,27 +46,32 @@ module Capistrano
50
46
 
51
47
  desc "Creates a new deploy using the API"
52
48
  task :deploy do
53
- config = Capistrano::Isitdeployed.get_config
54
- started = Capistrano::Isitdeployed.timestamp
55
- RestClient.post(ENDPOINT + "/p/#{config['project_id']}/d", { :status => 1, :platform => "#{stage}", :release => "#{release_name}", :started => started, :token => config['api_secret'] }.to_json, :content_type => :json, :accept => :json, :timeout => 5, :open_timeout => 5){ |response, request, result| response
56
- case response.code
57
- when 201
58
- logger.trace "IsItDeployed > New deploy created for #{application} to #{stage} with version: #{release_name}"
59
- logger.trace "IsItDeployed > URL is #{ENDPOINT}/p/#{config['project_id']}"
60
- set(:isitdeployed_did, response.gsub(/\s+/, ""))
61
- set(:isitdeployed_started, started)
62
- set(:isitdeployed_created, 1)
63
- when 401
64
- logger.trace "IsItDeployed > ERROR: Invalid 'api_secret'. Check your 'isitdeployed.yml'"
65
- set(:isitdeployed_created, 0)
66
- when 404
67
- logger.trace "IsItDeployed > ERROR: Invalid 'project_id'. Check your 'isitdeployed.yml'"
68
- set(:isitdeployed_created, 0)
69
- else
70
- logger.trace "IsItDeployed > ERROR: Can't create deploy, server returned code #{response.code}"
71
- set(:isitdeployed_created, 0)
72
- end
73
- }
49
+ if File.exists?(CONFIG_DEST)
50
+ config = Capistrano::Isitdeployed.load_user_config
51
+ started = Capistrano::Isitdeployed.timestamp
52
+ RestClient.post(ENDPOINT + "/p/#{config['project_id']}/d", { :status => 1, :platform => "#{stage}", :release => "#{release_name}", :started => started, :token => config['api_secret'] }.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 #{ENDPOINT}/p/#{config['project_id']}"
57
+ set(:isitdeployed_did, response.gsub(/\s+/, ""))
58
+ set(:isitdeployed_started, started)
59
+ set(:isitdeployed_created, 1)
60
+ when 401
61
+ logger.trace "IsItDeployed > ERROR: Invalid 'api_secret'. Check your 'isitdeployed.yml'"
62
+ set(:isitdeployed_created, 0)
63
+ when 404
64
+ logger.trace "IsItDeployed > ERROR: Invalid 'project_id'. Check your 'isitdeployed.yml'"
65
+ set(:isitdeployed_created, 0)
66
+ else
67
+ logger.trace "IsItDeployed > ERROR: Can't create deploy, server returned code #{response.code}"
68
+ set(:isitdeployed_created, 0)
69
+ end
70
+ }
71
+ else
72
+ logger.trace "IsItDeployed > WARNING: No configuration file found, please run cap 'isit:setup'"
73
+ set(:isitdeployed_created, 0)
74
+ end
74
75
  end
75
76
 
76
77
  namespace :status do
@@ -86,9 +87,9 @@ module Capistrano
86
87
  end
87
88
 
88
89
  desc "Updates deploy status using the API (succes or rollback)"
89
- config = Capistrano::Isitdeployed.get_config
90
90
  task :update do
91
91
  if isitdeployed_created === 1
92
+ config = Capistrano::Isitdeployed.load_user_config
92
93
  stopped = Capistrano::Isitdeployed.timestamp
93
94
  duration = stopped.to_i - isitdeployed_started.to_i
94
95
  RestClient.put(ENDPOINT + "/p/#{config['project_id']}/d/#{isitdeployed_did}", { :status => isitdeployed_status, :stopped => stopped, :duration => duration, :token => config['api_secret'] }.to_json, :content_type => :json, :accept => :json, :timeout => 5, :open_timeout => 5){ |response, request, result| response
@@ -105,7 +106,6 @@ module Capistrano
105
106
  }
106
107
  end
107
108
  end
108
-
109
109
  end
110
110
  end
111
111
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-isitdeployed
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas VIAL