capistrano-lingr 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/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +37 -0
- data/Rakefile +2 -0
- data/capistrano-lingr.gemspec +22 -0
- data/lib/capistrano/lingr.rb +61 -0
- data/lib/capistrano/lingr/version.rb +5 -0
- data/spec/capistrano/lingr_spec.rb +48 -0
- metadata +104 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Hiroshi Yoshida
|
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,37 @@
|
|
1
|
+
# Capistrano::Lingr
|
2
|
+
|
3
|
+
Notify to Lingr after deploy by Capistrano
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```rb
|
10
|
+
gem 'capistrano-lingr'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute: `bundle install`
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
In `config/deploy.rb`
|
18
|
+
|
19
|
+
```rb
|
20
|
+
require 'capistrano/lingr'
|
21
|
+
|
22
|
+
set :lingr_config, {
|
23
|
+
:room_id => "hoge",
|
24
|
+
:bot_id => "huga",
|
25
|
+
:secret => "piyo"
|
26
|
+
}
|
27
|
+
|
28
|
+
after :deploy, 'notify:lingr'
|
29
|
+
```
|
30
|
+
|
31
|
+
## Contributing
|
32
|
+
|
33
|
+
1. Fork it
|
34
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
35
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
36
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
37
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/capistrano/lingr/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Hiroshi Yoshida"]
|
6
|
+
gem.email = ["hrysd22@gmail.com"]
|
7
|
+
gem.description = %q{notify to Lingr after deploy by Capistrano}
|
8
|
+
gem.summary = %q{Capistrano Lingr}
|
9
|
+
gem.homepage = "https://github.com/hrysd/capistrano-lingr"
|
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-lingr"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Capistrano::Lingr::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency 'capistrano', '>= 2'
|
19
|
+
|
20
|
+
gem.add_development_dependency 'rspec'
|
21
|
+
gem.add_development_dependency 'webmock'
|
22
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
require 'net/http'
|
2
|
+
require 'digest/sha1'
|
3
|
+
require 'capistrano'
|
4
|
+
require 'capistrano/lingr/version'
|
5
|
+
|
6
|
+
class Capistrano::Lingr
|
7
|
+
|
8
|
+
def self.load_into(configuration)
|
9
|
+
configuration.load do
|
10
|
+
namespace :notify do
|
11
|
+
desc 'Send a notification of deploy to Lingr'
|
12
|
+
task :lingr do
|
13
|
+
Capistrano::Lingr.new(configuration).notification
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
HOST = 'lingr.com'
|
20
|
+
|
21
|
+
def initialize(capistrano)
|
22
|
+
@cap = capistrano
|
23
|
+
end
|
24
|
+
|
25
|
+
def notification
|
26
|
+
Net::HTTP.start(HOST, 80) do |http|
|
27
|
+
http.get("/api/room/say?bot=#{bot_id}&bot_verifier=#{verifier}&room=#{room_id}&text=#{URI.escape(text)}")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def application
|
34
|
+
@cap.application
|
35
|
+
end
|
36
|
+
|
37
|
+
def room_id
|
38
|
+
@cap.lingr_config[:room_id]
|
39
|
+
end
|
40
|
+
|
41
|
+
def bot_id
|
42
|
+
@cap.lingr_config[:bot_id]
|
43
|
+
end
|
44
|
+
|
45
|
+
def verifier
|
46
|
+
Digest::SHA1.hexdigest(@cap.lingr_config[:bot_id] + @cap.lingr_config[:secret])
|
47
|
+
end
|
48
|
+
|
49
|
+
def text
|
50
|
+
"#{application} is deployed by #{git_user}"
|
51
|
+
end
|
52
|
+
|
53
|
+
def git_user
|
54
|
+
`git config --get user.name`.strip
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
if Capistrano::Configuration.instance
|
60
|
+
Capistrano::Lingr.load_into(Capistrano::Configuration.instance)
|
61
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'webmock/rspec'
|
2
|
+
require 'capistrano/lingr'
|
3
|
+
|
4
|
+
describe Capistrano::Lingr do
|
5
|
+
let(:configuration) { Capistrano::Configuration.new }
|
6
|
+
subject { described_class.new configuration }
|
7
|
+
|
8
|
+
before :each do
|
9
|
+
configuration.load do |configuration|
|
10
|
+
set :lingr_config, {
|
11
|
+
:room_id => 'room_id',
|
12
|
+
:bot_id => 'bot_id',
|
13
|
+
:secret => 'secret'
|
14
|
+
}
|
15
|
+
|
16
|
+
set :application, 'test'
|
17
|
+
end
|
18
|
+
|
19
|
+
subject.stub(:git_user).and_return 'Hiroshi Yoshida'
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#notification' do
|
23
|
+
before do
|
24
|
+
@cap = Capistrano::Lingr.new(configuration)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'succeed to post' do
|
28
|
+
#url = %r|.*lingr.com/api/room/say\?room=.*&bot=.*&text=.*&bot_verifier=.*|
|
29
|
+
url = {
|
30
|
+
:room => 'room_id',
|
31
|
+
:bot => 'bot_id',
|
32
|
+
:text => 'test is deployed by Hiroshi Yoshida',
|
33
|
+
:bot_verifier => 'e6681220943d0d1303b905dba26a7eecff2aeb58'
|
34
|
+
}
|
35
|
+
stub_request(:get, 'lingr.com/api/room/say?').with(:query => url).to_return(:body => /^\{\"status\":\"ok\"/)
|
36
|
+
@cap.notification
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
it { subject.send(:application).should == 'test'}
|
42
|
+
it { subject.send(:room_id).should == 'room_id'}
|
43
|
+
it { subject.send(:bot_id).should == 'bot_id'}
|
44
|
+
it { subject.send(:verifier).should == 'e6681220943d0d1303b905dba26a7eecff2aeb58' }
|
45
|
+
it { subject.send(:git_user).should == 'Hiroshi Yoshida'}
|
46
|
+
it { subject.send(:text).should == 'test is deployed by Hiroshi Yoshida' }
|
47
|
+
#http://lingr.com/api/room/say?room=room_id&bot=bot_id&text=test%20is%20deployed%20by%20Hiroshi%20Yoshida&bot_verifier=e6681220943d0d1303b905dba26a7eecff2aeb58
|
48
|
+
end
|
metadata
ADDED
@@ -0,0 +1,104 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: capistrano-lingr
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Hiroshi Yoshida
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-09-03 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: capistrano
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '2'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '2'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rspec
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: webmock
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: notify to Lingr after deploy by Capistrano
|
63
|
+
email:
|
64
|
+
- hrysd22@gmail.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- Gemfile
|
71
|
+
- LICENSE
|
72
|
+
- README.md
|
73
|
+
- Rakefile
|
74
|
+
- capistrano-lingr.gemspec
|
75
|
+
- lib/capistrano/lingr.rb
|
76
|
+
- lib/capistrano/lingr/version.rb
|
77
|
+
- spec/capistrano/lingr_spec.rb
|
78
|
+
homepage: https://github.com/hrysd/capistrano-lingr
|
79
|
+
licenses: []
|
80
|
+
post_install_message:
|
81
|
+
rdoc_options: []
|
82
|
+
require_paths:
|
83
|
+
- lib
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
85
|
+
none: false
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ! '>='
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '0'
|
96
|
+
requirements: []
|
97
|
+
rubyforge_project:
|
98
|
+
rubygems_version: 1.8.24
|
99
|
+
signing_key:
|
100
|
+
specification_version: 3
|
101
|
+
summary: Capistrano Lingr
|
102
|
+
test_files:
|
103
|
+
- spec/capistrano/lingr_spec.rb
|
104
|
+
has_rdoc:
|