From 55a278f4e8504e13784503e181e318a06d896e49 Mon Sep 17 00:00:00 2001 From: Kir Shatrov Date: Sat, 29 Sep 2012 13:02:45 +0300 Subject: [PATCH] Initial commit --- .gitignore | 2 ++ Gemfile | 8 ++++++++ LICENSE | 22 ++++++++++++++++++++++ README.md | 17 +++++++++++++++++ Rakefile | 8 ++++++++ capistrano-nc.gemspec | 17 +++++++++++++++++ lib/capistrano-nc.rb | 33 +++++++++++++++++++++++++++++++++ 7 files changed, 107 insertions(+) create mode 100644 .gitignore create mode 100644 Gemfile create mode 100644 LICENSE create mode 100644 README.md create mode 100644 Rakefile create mode 100644 capistrano-nc.gemspec create mode 100644 lib/capistrano-nc.rb diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..a3e145b --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +Gemfile.lock +pkg diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..b0a31c6 --- /dev/null +++ b/Gemfile @@ -0,0 +1,8 @@ +source :rubygems + +gemspec + +group :development, :test do + gem 'rake' + gem 'rspec' +end diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..b7a4c92 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +Copyright (c) 2012 Kir Shatrov + +MIT License + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..5220197 --- /dev/null +++ b/README.md @@ -0,0 +1,17 @@ +Capistrano + Notification Center +========================= + +capistrano-nc integrates Capistrano and Mountain Lion's Notification Center. + +![Screenshot](http://f.cl.ly/items/1k253H0o350m1F0L371j/Screen%20Shot%202012-09-29%20at%2012.57.34%20PM.png) + +Installation +------------ + +Just put it in your Gemfile (`gem 'capistrano-nc'`) and + +##Contributors + +- [Kir Shatrov](https://github.com/kirs/) (Evrone) + +##Feel free for pull requests! \ No newline at end of file diff --git a/Rakefile b/Rakefile new file mode 100644 index 0000000..38c7d6e --- /dev/null +++ b/Rakefile @@ -0,0 +1,8 @@ +#!/usr/bin/env rake + +require 'bundler/gem_tasks' +require 'rspec/core/rake_task' + +RSpec::Core::RakeTask.new(:spec) + +task :default => :spec diff --git a/capistrano-nc.gemspec b/capistrano-nc.gemspec new file mode 100644 index 0000000..e3cfd08 --- /dev/null +++ b/capistrano-nc.gemspec @@ -0,0 +1,17 @@ +# -*- encoding: utf-8 -*- +Gem::Specification.new do |gem| + gem.name = 'capistrano-nc' + gem.version = '0.0.1' + gem.authors = ['Kir Shatrov'] + gem.email = ['shatrov@me.com'] + gem.description = 'https://github.com/evrone/capistrano-nc' + gem.summary = "Capistrano integration with Mountain Lion's Notification Center" + gem.description = 'https://github.com/evrone/capistrano-nc' + + gem.add_dependency 'terminal-notifier', '~> 1.4.2' + + gem.files = `git ls-files`.split($\) + gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } + gem.test_files = gem.files.grep(%r{^(spec)/}) + gem.require_paths = ['lib'] +end diff --git a/lib/capistrano-nc.rb b/lib/capistrano-nc.rb new file mode 100644 index 0000000..cb39792 --- /dev/null +++ b/lib/capistrano-nc.rb @@ -0,0 +1,33 @@ +require 'capistrano' +require 'terminal-notifier' + +module CapistranoNc + module Capistrano + def self.load_into(configuration) + configuration.load do + + after 'deploy', 'nc:finished' + after 'deploy:migrations', 'nc:finished' + + namespace :nc do + task :finished do + announced_stage = fetch(:stage, 'production') + + announcement = "\u2705 Successfully deployed " + announcement += if fetch(:branch, nil) + "#{application}'s #{branch} to #{announced_stage}" + else + "#{application} to #{announced_stage}" + end + + TerminalNotifier.notify announcement, :title => "Capistrano" + end + end + end + end + end +end + +if Capistrano::Configuration.instance + CapistranoNc::Capistrano.load_into(Capistrano::Configuration.instance) +end \ No newline at end of file