-
Notifications
You must be signed in to change notification settings - Fork 1
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
0 parents
commit 0981d17
Showing
12 changed files
with
256 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
*.gem | ||
*.rbc | ||
.bundle | ||
.config | ||
.yardoc | ||
Gemfile.lock | ||
InstalledFiles | ||
_yardoc | ||
coverage | ||
doc/ | ||
lib/bundler/man | ||
pkg | ||
rdoc | ||
spec/reports | ||
test/tmp | ||
test/version_tmp | ||
tmp |
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,2 @@ | ||
--color | ||
--format documentation |
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 @@ | ||
rvm 1.9.3@capistrano-campfire2 |
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,4 @@ | ||
source 'https://rubygems.org' | ||
|
||
# Specify your gem's dependencies in capistrano-blaze.gemspec | ||
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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Copyright (c) 2012 iain | ||
|
||
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. |
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,61 @@ | ||
# Capistrano::Blaze | ||
|
||
Because Capistrano::Campfire had to many dependencies and a hard setup, this is | ||
my attempt at making it easier. | ||
|
||
This gem has no runtime dependencies and should just work right out of the box. | ||
All you need to do is to provide your Campfire credentials. | ||
|
||
## Installation | ||
|
||
Add this line to your application's Gemfile: | ||
|
||
``` ruby | ||
gem 'capistrano-blaze', :require => false | ||
``` | ||
|
||
And then execute: | ||
|
||
``` shell | ||
$ bundle | ||
``` | ||
|
||
Or install it yourself as: | ||
|
||
``` shell | ||
$ gem install capistrano-blaze | ||
``` | ||
|
||
## Usage | ||
|
||
Add to your `config/deploy.rb`: | ||
|
||
``` ruby | ||
require 'capistrano/blaze' | ||
|
||
Capistrano::Blaze.configure do |config| | ||
config.account = "your-subdomain" | ||
config.room_id = 12345 | ||
config.token = "abcd" | ||
config.ssl = true | ||
end | ||
``` | ||
|
||
To test your configuration, run: | ||
|
||
``` shell | ||
$ cap campfire:test | ||
``` | ||
|
||
## Todo | ||
|
||
* Configure what kinds of messages are displayed | ||
* Don't depend on the multistage extension | ||
|
||
## Contributing | ||
|
||
1. Fork it | ||
2. Create your feature branch (`git checkout -b my-new-feature`) | ||
3. Commit your changes (`git commit -am 'Added some feature'`) | ||
4. Push to the branch (`git push origin my-new-feature`) | ||
5. Create new Pull Request |
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,2 @@ | ||
#!/usr/bin/env rake | ||
require "bundler/gem_tasks" |
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,20 @@ | ||
# -*- encoding: utf-8 -*- | ||
require File.expand_path('../lib/capistrano/blaze/version', __FILE__) | ||
|
||
Gem::Specification.new do |gem| | ||
gem.authors = ["iain"] | ||
gem.email = ["iain@iain.nl"] | ||
gem.description = %q{A simple campfire plugin for capistrano} | ||
gem.summary = %q{A simple campfire plugin for capistrano} | ||
gem.homepage = "https://github.com/iain/capistrano-blaze" | ||
|
||
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{^(test|spec|features)/}) | ||
gem.name = "capistrano-blaze" | ||
gem.require_paths = ["lib"] | ||
gem.version = Capistrano::Blaze::VERSION | ||
|
||
gem.add_development_dependency "rspec", "~> 2.9" | ||
gem.add_development_dependency "webmock", "~> 1.8.4" | ||
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,50 @@ | ||
require 'net/http' | ||
require 'json' | ||
require 'ostruct' | ||
require 'capistrano/blaze/version' | ||
require 'capistrano/blaze/recipes' if defined?(Capistrano::Configuration) | ||
|
||
module Capistrano | ||
module Blaze | ||
extend self | ||
|
||
def configure(opts = {}) | ||
@config = OpenStruct.new(opts) | ||
yield @config if block_given? | ||
end | ||
|
||
def speak(message) | ||
port = @config.ssl ? 443 : 80 | ||
|
||
req = Net::HTTP::Post.new("/room/#{@config.room_id}/speak.json") | ||
req.basic_auth @config.token, 'X' | ||
req.body = { :message => { :body => message } }.to_json | ||
req.content_type = "application/json" | ||
|
||
res = Net::HTTP.start("#{@config.account}.campfirenow.com", port, :use_ssl => @config.ssl) do |http| | ||
http.request(req) | ||
end | ||
end | ||
|
||
def failure(context, exception) | ||
speak ":warning: #{user} failed to deploy to the #{context.stage} stage of #{context.application}, via `#{command}`: #{exception.to_s} (#{exception.class.inspect})" | ||
end | ||
|
||
def success(context) | ||
speak "#{user} succesfully deployed to the #{context.stage} stage of #{context.application}, via `#{command}`" | ||
end | ||
|
||
def user | ||
`whoami`.strip | ||
end | ||
|
||
def test(context) | ||
speak ":heart: #{context.application}!" | ||
end | ||
|
||
def command | ||
[ 'cap', *$* ] * ' ' | ||
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,5 @@ | ||
module Capistrano | ||
module Blaze | ||
VERSION = '0.0.1' | ||
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,23 @@ | ||
Capistrano::Configuration.instance(:must_exist).load do | ||
|
||
at_exit do | ||
if exception = $! | ||
Capistrano::Blaze.failure(self, exception) | ||
end | ||
end | ||
|
||
namespace :campfire do | ||
|
||
task :success do | ||
Capistrano::Blaze.success(self) | ||
end | ||
|
||
task :test do | ||
Capistrano::Blaze.test(self) | ||
end | ||
|
||
end | ||
|
||
after "deploy:restart", "campfire:success" | ||
|
||
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,49 @@ | ||
require 'capistrano/blaze' | ||
require 'webmock' | ||
|
||
describe Capistrano::Blaze do | ||
include WebMock::API | ||
|
||
it "can speak" do | ||
token = "abc" | ||
room_id = 1234 | ||
account = "abcd" | ||
|
||
stub_request(:post, "https://#{token}:X@#{account}.campfirenow.com/room/#{room_id}/speak.json"). | ||
with(:body => "{\"message\":{\"body\":\"Ik ben een gem aan het maken\"}}", | ||
:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}). | ||
to_return(:status => 200, :body => "", :headers => {}) | ||
|
||
subject.configure do |config| | ||
config.account = account | ||
config.room_id = room_id | ||
config.token = token | ||
config.ssl = true | ||
end | ||
subject.speak "Ik ben een gem aan het maken" | ||
end | ||
|
||
before do | ||
subject.stub(:user) { "iain" } | ||
end | ||
|
||
it "displays a failure message" do | ||
subject.should_receive(:speak).with(":warning: iain failed to deploy to the production stage of basecamp, via `cap`: woops (RuntimeError)") | ||
context = stub(:stage => "production", :application => "basecamp") | ||
exception = RuntimeError.new("woops") | ||
subject.failure(context, exception) | ||
end | ||
|
||
it "displays success message" do | ||
subject.should_receive(:speak).with("iain succesfully deployed to the production stage of basecamp, via `cap`") | ||
context = stub(:stage => "production", :application => "basecamp") | ||
subject.success(context) | ||
end | ||
|
||
it "sends a test message" do | ||
subject.should_receive(:speak).with(":heart: basecamp!") | ||
context = stub(:application => "basecamp") | ||
subject.test(context) | ||
end | ||
|
||
end |