forked from itavia/capistrano-telegram
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2c5f805
commit cb606dc
Showing
9 changed files
with
98 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,4 @@ | ||
source 'https://rubygems.org' | ||
|
||
# Specify your gem's dependencies in capistrano-telegram.gemspec | ||
gemspec | ||
|
||
gem 'pry' | ||
gem 'awesome_print' | ||
gem 'telegram-bot-ruby' | ||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,25 @@ | ||
# coding: utf-8 | ||
# -*- encoding: utf-8 -*- | ||
lib = File.expand_path('../lib', __FILE__) | ||
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) | ||
require 'capistrano/telegram/version' | ||
|
||
Gem::Specification.new do |spec| | ||
spec.name = "capistrano-telegram" | ||
spec.version = Capistrano::Telegram::VERSION | ||
spec.version = '1.0.2' | ||
spec.authors = ["Mattia Malonni"] | ||
spec.email = ["[email protected]"] | ||
spec.summary = %q{Notify Capistrano deployment to Telegram.} | ||
spec.description = %q{Notify Capistrano deployment to Telegram.} | ||
spec.homepage = "https://github.com/MattiaMalonni/capistrano-telegram" | ||
spec.license = "MIT" | ||
|
||
spec.files = `git ls-files -z`.split("\x0") | ||
spec.files = `git ls-files`.split($/) | ||
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } | ||
spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) | ||
spec.require_paths = ["lib"] | ||
|
||
spec.add_dependency "telegram-bot-ruby", "~> 0.8" | ||
spec.add_dependency 'capistrano', '>= 3.8.1' | ||
spec.add_dependency 'telegram-bot-ruby', "~> 0.8" | ||
|
||
spec.add_development_dependency "bundler", "~> 1.7" | ||
spec.add_development_dependency "rake", "~> 10.0" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module Capistrano | ||
module Messaging | ||
module Helpers | ||
|
||
def icon_emoji | ||
options.fetch(:icon_emoji, nil) | ||
end | ||
|
||
def deployer | ||
default = ENV['USER'] || ENV['USERNAME'] | ||
fetch(:local_user, default) | ||
end | ||
|
||
def branch | ||
fetch(:branch) | ||
end | ||
|
||
def application | ||
fetch(:application) | ||
end | ||
|
||
def stage(default = 'an unknown stage') | ||
fetch(:stage, default) | ||
end | ||
|
||
# | ||
# Return the elapsed running time as a string. | ||
# | ||
# Examples: 21-18:26:30, 15:28:37, 01:14 | ||
# | ||
def elapsed_time | ||
`ps -p #{$$} -o etime=`.strip | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
require_relative 'helpers' | ||
|
||
module Capistrano | ||
module Messaging | ||
class Telegram | ||
include Helpers | ||
|
||
extend Forwardable | ||
def_delegators :env, :fetch | ||
|
||
def payload_for_updating | ||
{ | ||
text: "#{deployer} has started deploying branch #{branch} of #{application} to #{stage}" | ||
} | ||
end | ||
|
||
def payload_for_reverting | ||
{ | ||
text: "#{deployer} has started rolling back branch #{branch} of #{application} to #{stage}" | ||
} | ||
end | ||
|
||
def payload_for_updated | ||
{ | ||
text: "#{deployer} has finished deploying branch #{branch} of #{application} to #{stage}" | ||
} | ||
end | ||
|
||
def payload_for_reverted | ||
{ | ||
text: "#{deployer} has finished rolling back branch of #{application} to #{stage}" | ||
} | ||
end | ||
|
||
def payload_for_failed | ||
{ | ||
text: "#{deployer} has failed to #{deploying? ? 'deploy' : 'rollback'} branch #{branch} of #{application} to #{stage}" | ||
} | ||
end | ||
|
||
def payload_for(action) | ||
method = "payload_for_#{action}" | ||
respond_to?(method) && send(method) | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Binary file not shown.