capistrano-blaze 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.rspec +2 -0
- data/.rvmrc +1 -0
- data/Gemfile +4 -0
- data/MIT-LICENSE +22 -0
- data/README.md +61 -0
- data/Rakefile +2 -0
- data/capistrano-blaze.gemspec +20 -0
- data/lib/capistrano/blaze/version.rb +5 -0
- data/lib/capistrano/blaze.rb +50 -0
- data/lib/capistrano/recipes.rb +23 -0
- data/spec/camp_spec.rb +49 -0
- metadata +80 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rvmrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rvm 1.9.3@capistrano-campfire2
|
data/Gemfile
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 iain
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Capistrano::Blaze
|
2
|
+
|
3
|
+
Because Capistrano::Campfire had to many dependencies and a hard setup, this is
|
4
|
+
my attempt at making it easier.
|
5
|
+
|
6
|
+
This gem has no runtime dependencies and should just work right out of the box.
|
7
|
+
All you need to do is to provide your Campfire credentials.
|
8
|
+
|
9
|
+
## Installation
|
10
|
+
|
11
|
+
Add this line to your application's Gemfile:
|
12
|
+
|
13
|
+
``` ruby
|
14
|
+
gem 'capistrano-blaze', :require => false
|
15
|
+
```
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
``` shell
|
20
|
+
$ bundle
|
21
|
+
```
|
22
|
+
|
23
|
+
Or install it yourself as:
|
24
|
+
|
25
|
+
``` shell
|
26
|
+
$ gem install capistrano-blaze
|
27
|
+
```
|
28
|
+
|
29
|
+
## Usage
|
30
|
+
|
31
|
+
Add to your `config/deploy.rb`:
|
32
|
+
|
33
|
+
``` ruby
|
34
|
+
require 'capistrano/blaze'
|
35
|
+
|
36
|
+
Capistrano::Blaze.configure do |config|
|
37
|
+
config.account = "your-subdomain"
|
38
|
+
config.room_id = 12345
|
39
|
+
config.token = "abcd"
|
40
|
+
config.ssl = true
|
41
|
+
end
|
42
|
+
```
|
43
|
+
|
44
|
+
To test your configuration, run:
|
45
|
+
|
46
|
+
``` shell
|
47
|
+
$ cap campfire:test
|
48
|
+
```
|
49
|
+
|
50
|
+
## Todo
|
51
|
+
|
52
|
+
* Configure what kinds of messages are displayed
|
53
|
+
* Don't depend on the multistage extension
|
54
|
+
|
55
|
+
## Contributing
|
56
|
+
|
57
|
+
1. Fork it
|
58
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
59
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
60
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
61
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/capistrano/blaze/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["iain"]
|
6
|
+
gem.email = ["iain@iain.nl"]
|
7
|
+
gem.description = %q{A simple campfire plugin for capistrano}
|
8
|
+
gem.summary = %q{A simple campfire plugin for capistrano}
|
9
|
+
gem.homepage = "https://github.com/iain/capistrano-blaze"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "capistrano-blaze"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Capistrano::Blaze::VERSION
|
17
|
+
|
18
|
+
gem.add_development_dependency "rspec", "~> 2.9"
|
19
|
+
gem.add_development_dependency "webmock", "~> 1.8.4"
|
20
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'json'
|
3
|
+
require 'ostruct'
|
4
|
+
require 'capistrano/blaze/version'
|
5
|
+
require 'capistrano/blaze/recipes' if defined?(Capistrano::Configuration)
|
6
|
+
|
7
|
+
module Capistrano
|
8
|
+
module Blaze
|
9
|
+
extend self
|
10
|
+
|
11
|
+
def configure(opts = {})
|
12
|
+
@config = OpenStruct.new(opts)
|
13
|
+
yield @config if block_given?
|
14
|
+
end
|
15
|
+
|
16
|
+
def speak(message)
|
17
|
+
port = @config.ssl ? 443 : 80
|
18
|
+
|
19
|
+
req = Net::HTTP::Post.new("/room/#{@config.room_id}/speak.json")
|
20
|
+
req.basic_auth @config.token, 'X'
|
21
|
+
req.body = { :message => { :body => message } }.to_json
|
22
|
+
req.content_type = "application/json"
|
23
|
+
|
24
|
+
res = Net::HTTP.start("#{@config.account}.campfirenow.com", port, :use_ssl => @config.ssl) do |http|
|
25
|
+
http.request(req)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def failure(context, exception)
|
30
|
+
speak ":warning: #{user} failed to deploy to the #{context.stage} stage of #{context.application}, via `#{command}`: #{exception.to_s} (#{exception.class.inspect})"
|
31
|
+
end
|
32
|
+
|
33
|
+
def success(context)
|
34
|
+
speak "#{user} succesfully deployed to the #{context.stage} stage of #{context.application}, via `#{command}`"
|
35
|
+
end
|
36
|
+
|
37
|
+
def user
|
38
|
+
`whoami`.strip
|
39
|
+
end
|
40
|
+
|
41
|
+
def test(context)
|
42
|
+
speak ":heart: #{context.application}!"
|
43
|
+
end
|
44
|
+
|
45
|
+
def command
|
46
|
+
[ 'cap', *$* ] * ' '
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
2
|
+
|
3
|
+
at_exit do
|
4
|
+
if exception = $!
|
5
|
+
Capistrano::Blaze.failure(self, exception)
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
namespace :campfire do
|
10
|
+
|
11
|
+
task :success do
|
12
|
+
Capistrano::Blaze.success(self)
|
13
|
+
end
|
14
|
+
|
15
|
+
task :test do
|
16
|
+
Capistrano::Blaze.test(self)
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
after "deploy:restart", "campfire:success"
|
22
|
+
|
23
|
+
end
|
data/spec/camp_spec.rb
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'capistrano/blaze'
|
2
|
+
require 'webmock'
|
3
|
+
|
4
|
+
describe Capistrano::Blaze do
|
5
|
+
include WebMock::API
|
6
|
+
|
7
|
+
it "can speak" do
|
8
|
+
token = "abc"
|
9
|
+
room_id = 1234
|
10
|
+
account = "abcd"
|
11
|
+
|
12
|
+
stub_request(:post, "https://#{token}:X@#{account}.campfirenow.com/room/#{room_id}/speak.json").
|
13
|
+
with(:body => "{\"message\":{\"body\":\"Ik ben een gem aan het maken\"}}",
|
14
|
+
:headers => {'Accept'=>'*/*', 'Content-Type'=>'application/json', 'User-Agent'=>'Ruby'}).
|
15
|
+
to_return(:status => 200, :body => "", :headers => {})
|
16
|
+
|
17
|
+
subject.configure do |config|
|
18
|
+
config.account = account
|
19
|
+
config.room_id = room_id
|
20
|
+
config.token = token
|
21
|
+
config.ssl = true
|
22
|
+
end
|
23
|
+
subject.speak "Ik ben een gem aan het maken"
|
24
|
+
end
|
25
|
+
|
26
|
+
before do
|
27
|
+
subject.stub(:user) { "iain" }
|
28
|
+
end
|
29
|
+
|
30
|
+
it "displays a failure message" do
|
31
|
+
subject.should_receive(:speak).with(":warning: iain failed to deploy to the production stage of basecamp, via `cap`: woops (RuntimeError)")
|
32
|
+
context = stub(:stage => "production", :application => "basecamp")
|
33
|
+
exception = RuntimeError.new("woops")
|
34
|
+
subject.failure(context, exception)
|
35
|
+
end
|
36
|
+
|
37
|
+
it "displays success message" do
|
38
|
+
subject.should_receive(:speak).with("iain succesfully deployed to the production stage of basecamp, via `cap`")
|
39
|
+
context = stub(:stage => "production", :application => "basecamp")
|
40
|
+
subject.success(context)
|
41
|
+
end
|
42
|
+
|
43
|
+
it "sends a test message" do
|
44
|
+
subject.should_receive(:speak).with(":heart: basecamp!")
|
45
|
+
context = stub(:application => "basecamp")
|
46
|
+
subject.test(context)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-blaze
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- iain
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-29 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &70295704471820 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '2.9'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70295704471820
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: webmock
|
27
|
+
requirement: &70295704471320 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.8.4
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70295704471320
|
36
|
+
description: A simple campfire plugin for capistrano
|
37
|
+
email:
|
38
|
+
- iain@iain.nl
|
39
|
+
executables: []
|
40
|
+
extensions: []
|
41
|
+
extra_rdoc_files: []
|
42
|
+
files:
|
43
|
+
- .gitignore
|
44
|
+
- .rspec
|
45
|
+
- .rvmrc
|
46
|
+
- Gemfile
|
47
|
+
- MIT-LICENSE
|
48
|
+
- README.md
|
49
|
+
- Rakefile
|
50
|
+
- capistrano-blaze.gemspec
|
51
|
+
- lib/capistrano/blaze.rb
|
52
|
+
- lib/capistrano/blaze/version.rb
|
53
|
+
- lib/capistrano/recipes.rb
|
54
|
+
- spec/camp_spec.rb
|
55
|
+
homepage: https://github.com/iain/capistrano-blaze
|
56
|
+
licenses: []
|
57
|
+
post_install_message:
|
58
|
+
rdoc_options: []
|
59
|
+
require_paths:
|
60
|
+
- lib
|
61
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
62
|
+
none: false
|
63
|
+
requirements:
|
64
|
+
- - ! '>='
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '0'
|
67
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 1.8.15
|
76
|
+
signing_key:
|
77
|
+
specification_version: 3
|
78
|
+
summary: A simple campfire plugin for capistrano
|
79
|
+
test_files:
|
80
|
+
- spec/camp_spec.rb
|