capistrano-flowdock 1.0.0 → 2.0.0

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
2
  SHA1:
3
- metadata.gz: a2b7306c172d095b9da22a1ff3d9be80f7c592ba
4
- data.tar.gz: dc7f2564bed2291dabf139bc477ffd230b6c9a91
3
+ metadata.gz: 4cac34e546340767b69509127f8075a8de849527
4
+ data.tar.gz: ab7e1e5d550d99064053be02d97d36a0776875c5
5
5
  SHA512:
6
- metadata.gz: afb98c3c9fd0a3a098cd7f84d246b2624ac5282e3fb459982f6ba06ac46fc005119abf20d4d43e50b27ac73c64ed5f11d2d15d39556e2bf9677653ef8db0c262
7
- data.tar.gz: 46c870e673de5266cedaea449b5e1e6651518efe38a18ce463e5344d492e7cf21f721f846669bb589297399501ae45f7d71791d5b1ca226caeab5551e2aa7166
6
+ metadata.gz: 7250374f37415e2402cc69dc2176c52e04b9073952a5e3e5de558e7e124aae7c7aeee3e9f68ed6607132a21fd27ae4ac623eca4594fa29aa478a67790b2d600c
7
+ data.tar.gz: 5bb6992a382e64d680f3b47c5186318c312b3ae4e0235568875302f8e4e804fdd6ac1869a79e190a63b8b007ef56ffd1e886f3ea43557bed596590ae3278d577
data/README.md CHANGED
@@ -1,6 +1,7 @@
1
1
  # Capistrano::Flowdock
2
2
 
3
- Notify Flowdock flows about Capistrano deployments
3
+ Notify Flowdock flows about Capistrano deployments. These instructions are for
4
+ Capistrano 3. Check out [capistrano-2](https://github.com/flowdock/capistrano-flowdock/tree/capistrano-2) branch for Capistrano 2.x support.
4
5
 
5
6
  ## Installation
6
7
 
@@ -18,12 +19,16 @@ Or install it yourself as:
18
19
 
19
20
  ## Usage
20
21
 
21
- Load `capistrano-flowdock` in Capistrano `deploy.rb` file and set Flowdock API
22
- tokens and project configuration.
22
+ Load this gem in Capfile:
23
23
 
24
24
  ```ruby
25
- require 'capistrano-flowdock'
25
+ # Capfile
26
+ require 'capistrano/flowdock'
27
+ ```
28
+
29
+ Setup your Flowdock credentials in `deploy.rb`
26
30
 
31
+ ```ruby
27
32
  set :flowdock_api_token, "_YOUR_API_TOKEN_HERE"
28
33
  set :flowdock_project_name, "My project" # Optional, defaults to application
29
34
  set :flowdock_deploy_tags, ["deploy"] # Optional, defaults to ["deploy"]
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.require_paths = ["lib"]
20
20
 
21
21
  spec.add_runtime_dependency "flowdock", "~> 0.3.1"
22
- spec.add_runtime_dependency "capistrano", "~> 2.0"
22
+ spec.add_runtime_dependency "capistrano", "~> 3.0"
23
23
  spec.add_runtime_dependency "grit", "~> 2.4"
24
24
  spec.add_development_dependency "bundler", "~> 1.3"
25
25
  spec.add_development_dependency "rake"
@@ -1 +1 @@
1
- require 'capistrano/flowdock'
1
+ require "capistrano/flowdock/version"
@@ -1,92 +1,5 @@
1
- require "capistrano/flowdock/version"
2
-
3
- require 'capistrano'
4
1
  require 'flowdock'
5
2
  require 'digest/md5'
6
3
  require 'cgi'
7
4
 
8
- Capistrano::Configuration.instance(:must_exist).load do
9
-
10
- namespace :flowdock do
11
- task :read_current_deployed_branch do
12
- current_branch = capture("cat #{current_path}/BRANCH").chomp rescue "master"
13
- set :current_branch, current_branch
14
- end
15
-
16
- task :save_deployed_branch do
17
- begin
18
- run "echo '#{source.head.to_s.chomp}' > #{current_path}/BRANCH"
19
- rescue => e
20
- puts "Flowdock: error in saving deployed branch information: #{e.to_s}"
21
- end
22
- end
23
-
24
- task :set_flowdock_api do
25
- set :flowdock_deploy_env, fetch(:stage, fetch(:rails_env, ENV["RAILS_ENV"] || "production"))
26
- begin
27
- require 'grit'
28
- set :repo, Grit::Repo.new(".")
29
- config = Grit::Config.new(repo)
30
- rescue LoadError => e
31
- puts "Flowdock: you need to have Grit gem installed: #{e.to_s}"
32
- rescue => e
33
- puts "Flowdock: error in fetching your git repository information: #{e.to_s}"
34
- end
35
-
36
- begin
37
- flows = Array(flowdock_api_token).map do |api_token|
38
- ::Flowdock::Flow.new(:api_token => api_token,
39
- :source => "Capistrano deployment", :project => flowdock_project_name,
40
- :from => {:name => config["user.name"], :address => config["user.email"]})
41
- end
42
- set :flowdock_api, flows
43
- rescue => e
44
- puts "Flowdock: error in configuring Flowdock API: #{e.to_s}"
45
- end
46
- end
47
-
48
- task :notify_deploy_finished do
49
- # send message to the flow
50
- begin
51
- flowdock_api.each do |flow|
52
- flow.push_to_team_inbox(:format => "html",
53
- :subject => "#{flowdock_project_name} deployed with branch #{branch} on ##{flowdock_deploy_env}",
54
- :content => notification_message,
55
- :tags => ["deploy", "#{flowdock_deploy_env}"] | flowdock_deploy_tags)
56
- end unless dry_run
57
- rescue => e
58
- puts "Flowdock: error in sending notification to your flow: #{e.to_s}"
59
- end
60
- end
61
-
62
- def notification_message
63
- if branch == current_branch
64
- message = "<p>The following changes were just deployed to #{flowdock_deploy_env}:</p>"
65
- commits = repo.commits_between(previous_revision, current_revision).reverse
66
-
67
- unless commits.empty?
68
- commits.each do |c|
69
- short, long = c.message.split(/\n+/, 2)
70
- message << "\n<div style=\"margin-bottom: 10px\"><div style=\"height:30px;width:30px;float:left;margin-right:5px;\"><img src=\"https://secure.gravatar.com/avatar/#{Digest::MD5::hexdigest(c.author.email.downcase)}?s=30\" /></div>"
71
- message << "<div style=\"padding-left: 35px;\">#{CGI.escapeHTML(short)}<br/>"
72
- if long
73
- long.gsub!(/\n/, '<br />')
74
- message << '<p style="margin:5px 0px; padding: 0 5px; border-left: 3px solid #ccc">' + long + '</p>'
75
- end
76
- message << "<span style=\"font-size: 90%; color: #333\"><code>#{c.id_abbrev}</code> <a href=\"mailto:#{CGI.escapeHTML(c.author.email)}\">#{CGI.escapeHTML(c.author.name)}</a> on #{c.authored_date.strftime("%b %d, %H:%M")}</span></div></div>"
77
- end
78
- end
79
- else
80
- message = "Branch #{source.head} was deployed to #{flowdock_deploy_env}. Previously deployed branch was #{current_branch}."
81
- end
82
- message
83
- end
84
- end
85
-
86
- before "deploy:update_code", "flowdock:read_current_deployed_branch"
87
- before "flowdock:notify_deploy_finished", "flowdock:set_flowdock_api"
88
- ["deploy", "deploy:migrations"].each do |task|
89
- after task, "flowdock:notify_deploy_finished"
90
- after task, "flowdock:save_deployed_branch"
91
- end
92
- end
5
+ load File.expand_path('../tasks/flowdock.cap', __FILE__)
@@ -1,5 +1,5 @@
1
1
  module Capistrano
2
2
  module Flowdock
3
- VERSION = "1.0.0"
3
+ VERSION = "2.0.0"
4
4
  end
5
5
  end
@@ -0,0 +1,93 @@
1
+ namespace :flowdock do
2
+ task :read_current_deployed_branch do
3
+ on roles(:all) do
4
+ begin
5
+ current_branch = capture(:cat, "#{current_path}/BRANCH").chomp
6
+ rescue
7
+ current_branch = "master"
8
+ end
9
+
10
+ set :current_branch, current_branch
11
+ end
12
+ end
13
+
14
+ task :save_deployed_branch do
15
+ on roles(:all) do
16
+ begin
17
+ execute("echo '#{fetch(:repo).head.name.chomp}' > #{current_path}/BRANCH")
18
+ rescue => e
19
+ puts "Flowdock: error in saving deployed branch information: #{e.to_s}"
20
+ end
21
+ end
22
+ end
23
+
24
+ task :set_flowdock_api do
25
+ set :flowdock_deploy_env, fetch(:stage, fetch(:rails_env, ENV["RAILS_ENV"] || "production"))
26
+ begin
27
+ require 'grit'
28
+ repo = Grit::Repo.new(".")
29
+ set :repo, repo
30
+ config = Grit::Config.new(repo)
31
+ rescue LoadError => e
32
+ puts "Flowdock: you need to have Grit gem installed: #{e.to_s}"
33
+ rescue => e
34
+ puts "Flowdock: error in fetching your git repository information: #{e.to_s}"
35
+ end
36
+
37
+ begin
38
+ flows = Array(fetch(:flowdock_api_token)).map do |api_token|
39
+ Flowdock::Flow.new(:api_token => api_token,
40
+ :source => "Capistrano deployment", :project => fetch(:flowdock_project_name),
41
+ :from => {:name => config["user.name"], :address => config["user.email"]})
42
+ end
43
+ set :flowdock_api, flows
44
+ rescue => e
45
+ puts "Flowdock: error in configuring Flowdock API: #{e.to_s}"
46
+ end
47
+ end
48
+
49
+ task :notify_deploy_finished do
50
+ # send message to the flow
51
+ begin
52
+ fetch(:flowdock_api).each do |flow|
53
+ flow.push_to_team_inbox(:format => "html",
54
+ :subject => "#{fetch(:flowdock_project_name)} deployed with branch #{fetch(:branch)} on ##{fetch(:flowdock_deploy_env)}",
55
+ :content => notification_message,
56
+ :tags => ["deploy", "#{fetch(:flowdock_deploy_env)}"] | fetch(:flowdock_deploy_tags))
57
+ end unless fetch('dry_run')
58
+ rescue => e
59
+ puts "Flowdock: error in sending notification to your flow: #{e.to_s}"
60
+ end
61
+ end
62
+
63
+ def notification_message
64
+ if fetch(:branch) == fetch(:current_branch)
65
+ message = "<p>The following changes were just deployed to #{fetch(:flowdock_deploy_env)}:</p>"
66
+ commits = fetch(:repo).commits_between(
67
+ fetch(:previous_revision), fetch(:current_revision)
68
+ ).reverse
69
+
70
+ unless commits.empty?
71
+ commits.each do |c|
72
+ short, long = c.message.split(/\n+/, 2)
73
+ message << "\n<div style=\"margin-bottom: 10px\"><div style=\"height:30px;width:30px;float:left;margin-right:5px;\"><img src=\"https://secure.gravatar.com/avatar/#{Digest::MD5::hexdigest(c.author.email.downcase)}?s=30\" /></div>"
74
+ message << "<div style=\"padding-left: 35px;\">#{CGI.escapeHTML(short)}<br/>"
75
+ if long
76
+ long.gsub!(/\n/, '<br />')
77
+ message << '<p style="margin:5px 0px; padding: 0 5px; border-left: 3px solid #ccc">' + long + '</p>'
78
+ end
79
+ message << "<span style=\"font-size: 90%; color: #333\"><code>#{c.id_abbrev}</code> <a href=\"mailto:#{CGI.escapeHTML(c.author.email)}\">#{CGI.escapeHTML(c.author.name)}</a> on #{c.authored_date.strftime("%b %d, %H:%M")}</span></div></div>"
80
+ end
81
+ end
82
+ else
83
+ message = "Branch #{fetch(:repo).head.name} was deployed to #{fetch(:flowdock_deploy_env)}. Previously deployed branch was #{fetch(:current_branch)}."
84
+ end
85
+ message
86
+ end
87
+ end
88
+
89
+ before "deploy:updated", "flowdock:read_current_deployed_branch"
90
+ before "flowdock:notify_deploy_finished", "flowdock:set_flowdock_api"
91
+
92
+ after "deploy", "flowdock:notify_deploy_finished"
93
+ after "deploy", "flowdock:save_deployed_branch"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: capistrano-flowdock
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ville Lautanala
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-21 00:00:00.000000000 Z
11
+ date: 2014-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: flowdock
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.0'
33
+ version: '3.0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '2.0'
40
+ version: '3.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: grit
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -96,6 +96,7 @@ files:
96
96
  - lib/capistrano-flowdock.rb
97
97
  - lib/capistrano/flowdock.rb
98
98
  - lib/capistrano/flowdock/version.rb
99
+ - lib/capistrano/tasks/flowdock.cap
99
100
  homepage: https://flowdock.com/help/capistrano
100
101
  licenses:
101
102
  - MIT