toadhopper 1.0.6 → 1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +0 -1
- data/Gemfile +3 -11
- data/Gemfile.lock +8 -12
- data/README.md +16 -1
- data/Rakefile +4 -16
- data/lib/toadhopper.rb +28 -4
- data/lib/toadhopper/capistrano.rb +19 -0
- data/test/helper.rb +5 -4
- data/test/test_deploy_tracking.rb +15 -0
- data/toadhopper.gemspec +29 -0
- metadata +57 -13
data/.gitignore
CHANGED
data/Gemfile
CHANGED
@@ -1,12 +1,4 @@
|
|
1
|
-
source :
|
1
|
+
source :rubygems
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
gem 'jeweler'
|
6
|
-
gem 'rake'
|
7
|
-
end
|
8
|
-
|
9
|
-
group :test do
|
10
|
-
gem 'rake'
|
11
|
-
gem 'test-unit', :require => nil
|
12
|
-
end
|
3
|
+
# Specify your gem's dependencies in toadhopper.gemspec
|
4
|
+
gemspec
|
data/Gemfile.lock
CHANGED
@@ -1,24 +1,20 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
toadhopper (1.1)
|
5
|
+
|
1
6
|
GEM
|
2
7
|
remote: http://rubygems.org/
|
3
8
|
specs:
|
4
|
-
|
5
|
-
git (1.2.5)
|
6
|
-
jeweler (1.4.0)
|
7
|
-
gemcutter (>= 0.1.0)
|
8
|
-
git (>= 1.2.5)
|
9
|
-
rubyforge (>= 2.0.0)
|
10
|
-
json_pure (1.4.6)
|
9
|
+
fakeweb (1.3.0)
|
11
10
|
rake (0.8.7)
|
12
|
-
rubyforge (2.0.4)
|
13
|
-
json_pure (>= 1.1.7)
|
14
11
|
test-unit (2.1.1)
|
15
|
-
yard (0.6.1)
|
16
12
|
|
17
13
|
PLATFORMS
|
18
14
|
ruby
|
19
15
|
|
20
16
|
DEPENDENCIES
|
21
|
-
|
17
|
+
fakeweb
|
22
18
|
rake
|
23
19
|
test-unit
|
24
|
-
|
20
|
+
toadhopper!
|
data/README.md
CHANGED
@@ -13,6 +13,20 @@ You can install it via rubygems:
|
|
13
13
|
|
14
14
|
gem install toadhopper
|
15
15
|
|
16
|
+
## Deploy tracking
|
17
|
+
|
18
|
+
You can use Toadhopper to notify Hoptoad of deployments:
|
19
|
+
|
20
|
+
Toadhopper('YOURAPIKEY').deploy!
|
21
|
+
|
22
|
+
The method accepts options to set the environment, SCM revision, etc.
|
23
|
+
|
24
|
+
There is Capistrano support for deploy tracking. Simply require `toadhopper/capistrano` in your deploy config and set the variable `hoptoad_api_key`:
|
25
|
+
|
26
|
+
require 'toadhopper/capistrano'
|
27
|
+
|
28
|
+
set :hoptoad_api_key, 'YOURAPIKEY'
|
29
|
+
|
16
30
|
## Development
|
17
31
|
|
18
32
|
Install Bundler 0.9.x, then:
|
@@ -40,4 +54,5 @@ To build the gem:
|
|
40
54
|
* [Samuel Tesla](http://github.com/stesla)
|
41
55
|
* [Corey Donohoe](http://github.com/atmos)
|
42
56
|
* [Andre Arko](http://github.com/indirect)
|
43
|
-
* [Loren Segal](http://github.com/lsegal)
|
57
|
+
* [Loren Segal](http://github.com/lsegal)
|
58
|
+
* [Theo Hultberg](http://github.com/iconara)
|
data/Rakefile
CHANGED
@@ -1,23 +1,11 @@
|
|
1
|
-
|
2
|
-
Bundler.require(:development, :test)
|
3
|
-
|
1
|
+
require 'bundler/setup'
|
4
2
|
require 'rake/testtask'
|
5
3
|
|
4
|
+
Bundler::GemHelper.install_tasks
|
5
|
+
|
6
|
+
|
6
7
|
Rake::TestTask.new do |t|
|
7
8
|
t.libs << "test"
|
8
9
|
t.test_files = FileList['test/test*.rb']
|
9
10
|
t.verbose = true
|
10
11
|
end
|
11
|
-
|
12
|
-
Jeweler::Tasks.new do |s|
|
13
|
-
s.name = "toadhopper"
|
14
|
-
s.summary = "Post error notifications to Hoptoad"
|
15
|
-
s.email = "t.lucas@toolmantim.com"
|
16
|
-
s.homepage = "http://github.com/toolmantim/toadhopper"
|
17
|
-
s.authors = ["Tim Lucas", "Samuel Tesla", "Corey Donohoe", "Andre Arko"]
|
18
|
-
s.extra_rdoc_files = ["README.md", "LICENSE"]
|
19
|
-
s.executables = nil # stops jeweler automatically adding bin/*
|
20
|
-
|
21
|
-
require File.join(File.dirname(__FILE__), 'lib', 'toadhopper')
|
22
|
-
s.version = Toadhopper::VERSION
|
23
|
-
end
|
data/lib/toadhopper.rb
CHANGED
@@ -4,7 +4,7 @@ require 'ostruct'
|
|
4
4
|
|
5
5
|
# Posts errors to the Hoptoad API
|
6
6
|
class Toadhopper
|
7
|
-
VERSION = "1.
|
7
|
+
VERSION = "1.1"
|
8
8
|
FILTER_REPLACEMENT = "[FILTERED]"
|
9
9
|
|
10
10
|
# Hoptoad API response
|
@@ -52,6 +52,26 @@ class Toadhopper
|
|
52
52
|
post_document(document_for(error, options), {'X-Hoptoad-Client-Name' => options[:notifier_name]})
|
53
53
|
end
|
54
54
|
|
55
|
+
# Posts a deployment notification
|
56
|
+
#
|
57
|
+
# @param [Hash] options
|
58
|
+
# @option options [String] framework_env The framework environment your app is running under, defaults to development
|
59
|
+
# @option options [String] scm_repository The repository URL
|
60
|
+
# @option options [String] scm_revision The current repository revision
|
61
|
+
# @option options [String] username Your name, defaults to `whoami`
|
62
|
+
#
|
63
|
+
# @return [Response]
|
64
|
+
def deploy!(options={})
|
65
|
+
params = {}
|
66
|
+
params['api_key'] = @api_key
|
67
|
+
params['deploy[rails_env]'] = options[:framework_env] || 'development'
|
68
|
+
params['deploy[local_username]'] = options[:username] || %x(whoami).strip
|
69
|
+
params['deploy[scm_repository]'] = options[:scm_repository]
|
70
|
+
params['deploy[scm_revision]'] = options[:scm_revision]
|
71
|
+
response = Net::HTTP.post_form(URI.parse('http://hoptoadapp.com/deploys.txt'), params)
|
72
|
+
parse_response(response)
|
73
|
+
end
|
74
|
+
|
55
75
|
private
|
56
76
|
|
57
77
|
def document_defaults(error)
|
@@ -92,14 +112,18 @@ class Toadhopper
|
|
92
112
|
response = http.post uri.path,
|
93
113
|
document,
|
94
114
|
{'Content-type' => 'text/xml', 'Accept' => 'text/xml, application/xml'}.merge(headers)
|
95
|
-
|
96
|
-
response.body,
|
97
|
-
response.body.scan(%r{<error>(.+)<\/error>}).flatten
|
115
|
+
parse_response(response)
|
98
116
|
rescue TimeoutError => e
|
99
117
|
Response.new(500, '', ['Timeout error'])
|
100
118
|
end
|
101
119
|
end
|
102
120
|
end
|
121
|
+
|
122
|
+
def parse_response(response)
|
123
|
+
Response.new(response.code.to_i,
|
124
|
+
response.body,
|
125
|
+
response.body.scan(%r{<error>(.+)<\/error>}).flatten)
|
126
|
+
end
|
103
127
|
|
104
128
|
def document_for(exception, options={})
|
105
129
|
data = document_data(exception, options)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'toadhopper'
|
2
|
+
|
3
|
+
|
4
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
5
|
+
after 'deploy', 'deploy:notify_hoptoad'
|
6
|
+
after 'deploy:migrations', 'deploy:notify_hoptoad'
|
7
|
+
|
8
|
+
namespace :deploy do
|
9
|
+
desc 'Notify Hoptoad of the deployment'
|
10
|
+
task :notify_hoptoad, :except => {:no_release => true} do
|
11
|
+
framework_env = fetch(:rails_env, fetch(:hoptoad_env, 'production'))
|
12
|
+
api_key = fetch(:hoptoad_api_key)
|
13
|
+
puts 'Notifying Hoptoad of deploy'
|
14
|
+
options = {:framework_env => framework_env, :scm_revision => current_revision, :scm_repository => repository}
|
15
|
+
Toadhopper(api_key).deploy!(options)
|
16
|
+
puts 'Hoptoad notification complete'
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/test/helper.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
|
2
|
-
Bundler.require(:test)
|
3
|
-
|
1
|
+
require 'bundler/setup'
|
4
2
|
require 'test/unit'
|
5
|
-
require
|
3
|
+
require 'fakeweb'
|
4
|
+
require 'toadhopper'
|
5
|
+
|
6
|
+
FakeWeb.allow_net_connect = true
|
6
7
|
|
7
8
|
def toadhopper
|
8
9
|
@toadhopper ||= Toadhopper.new(ENV['HOPTOAD_API_KEY'] || "test api key")
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'cgi'
|
3
|
+
require 'fakeweb'
|
4
|
+
|
5
|
+
class Toadhopper::TestDeployTracking < Test::Unit::TestCase
|
6
|
+
def test_deploy
|
7
|
+
FakeWeb.register_uri(:post, 'http://hoptoadapp.com/deploys.txt', :status => ['200', 'Ok'])
|
8
|
+
options = {:framework_env => 'test', :scm_revision => 3, :scm_repository => 'some/where', :username => 'phil'}
|
9
|
+
response = Toadhopper('bogus key').deploy!(options)
|
10
|
+
request = FakeWeb.last_request
|
11
|
+
expected_parameters = {'api_key' => 'bogus key', 'deploy[rails_env]' => 'test', 'deploy[scm_revision]' => '3', 'deploy[scm_repository]' => 'some/where', 'deploy[local_username]' => 'phil'}
|
12
|
+
assert_equal 200, response.status
|
13
|
+
assert_equal expected_parameters, Hash[CGI.unescape(FakeWeb.last_request.body).split('&').map { |x| x.split('=') }]
|
14
|
+
end
|
15
|
+
end
|
data/toadhopper.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
$: << File.expand_path('../lib', __FILE__)
|
4
|
+
|
5
|
+
require 'toadhopper'
|
6
|
+
|
7
|
+
|
8
|
+
Gem::Specification.new do |s|
|
9
|
+
s.name = 'toadhopper'
|
10
|
+
s.version = Toadhopper::VERSION
|
11
|
+
s.platform = Gem::Platform::RUBY
|
12
|
+
s.authors = ['Tim Lucas', 'Samuel Tesla', 'Corey Donohoe', 'Andre Arko', 'Theo Hultberg']
|
13
|
+
s.email = ['t.lucas@toolmantim.com']
|
14
|
+
s.homepage = 'http://github.com/toolmantim/toadhopper'
|
15
|
+
s.summary = %q{Post error notifications to Hoptoad}
|
16
|
+
s.description = %q{A base library for Hoptoad error reporting}
|
17
|
+
|
18
|
+
s.rubyforge_project = 'toadhopper'
|
19
|
+
|
20
|
+
s.files = `git ls-files`.split("\n")
|
21
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
22
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
23
|
+
s.require_paths = ['lib']
|
24
|
+
s.extra_rdoc_files = ['README.md', 'LICENSE']
|
25
|
+
|
26
|
+
s.add_development_dependency 'rake'
|
27
|
+
s.add_development_dependency 'test-unit'
|
28
|
+
s.add_development_dependency 'fakeweb'
|
29
|
+
end
|
metadata
CHANGED
@@ -4,32 +4,71 @@ version: !ruby/object:Gem::Version
|
|
4
4
|
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 1
|
7
|
-
-
|
8
|
-
|
9
|
-
version: 1.0.6
|
7
|
+
- 1
|
8
|
+
version: "1.1"
|
10
9
|
platform: ruby
|
11
10
|
authors:
|
12
11
|
- Tim Lucas
|
13
12
|
- Samuel Tesla
|
14
13
|
- Corey Donohoe
|
15
14
|
- Andre Arko
|
15
|
+
- Theo Hultberg
|
16
16
|
autorequire:
|
17
17
|
bindir: bin
|
18
18
|
cert_chain: []
|
19
19
|
|
20
|
-
date:
|
20
|
+
date: 2011-01-31 00:00:00 +11:00
|
21
21
|
default_executable:
|
22
|
-
dependencies:
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
dependencies:
|
23
|
+
- !ruby/object:Gem::Dependency
|
24
|
+
name: rake
|
25
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ">="
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *id001
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: test-unit
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
46
|
+
type: :development
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
name: fakeweb
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
segments:
|
57
|
+
- 0
|
58
|
+
version: "0"
|
59
|
+
type: :development
|
60
|
+
prerelease: false
|
61
|
+
version_requirements: *id003
|
62
|
+
description: A base library for Hoptoad error reporting
|
63
|
+
email:
|
64
|
+
- t.lucas@toolmantim.com
|
26
65
|
executables: []
|
27
66
|
|
28
67
|
extensions: []
|
29
68
|
|
30
69
|
extra_rdoc_files:
|
31
|
-
- LICENSE
|
32
70
|
- README.md
|
71
|
+
- LICENSE
|
33
72
|
files:
|
34
73
|
- .gitignore
|
35
74
|
- .yardopts
|
@@ -40,17 +79,20 @@ files:
|
|
40
79
|
- Rakefile
|
41
80
|
- lib/notice.erb
|
42
81
|
- lib/toadhopper.rb
|
82
|
+
- lib/toadhopper/capistrano.rb
|
43
83
|
- test/helper.rb
|
44
84
|
- test/test_convenience_constructor.rb
|
85
|
+
- test/test_deploy_tracking.rb
|
45
86
|
- test/test_filtering.rb
|
46
87
|
- test/test_posting.rb
|
88
|
+
- toadhopper.gemspec
|
47
89
|
has_rdoc: true
|
48
90
|
homepage: http://github.com/toolmantim/toadhopper
|
49
91
|
licenses: []
|
50
92
|
|
51
93
|
post_install_message:
|
52
|
-
rdoc_options:
|
53
|
-
|
94
|
+
rdoc_options: []
|
95
|
+
|
54
96
|
require_paths:
|
55
97
|
- lib
|
56
98
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -58,7 +100,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
58
100
|
requirements:
|
59
101
|
- - ">="
|
60
102
|
- !ruby/object:Gem::Version
|
61
|
-
hash:
|
103
|
+
hash: 3677881866856613108
|
62
104
|
segments:
|
63
105
|
- 0
|
64
106
|
version: "0"
|
@@ -67,12 +109,13 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
67
109
|
requirements:
|
68
110
|
- - ">="
|
69
111
|
- !ruby/object:Gem::Version
|
112
|
+
hash: 3677881866856613108
|
70
113
|
segments:
|
71
114
|
- 0
|
72
115
|
version: "0"
|
73
116
|
requirements: []
|
74
117
|
|
75
|
-
rubyforge_project:
|
118
|
+
rubyforge_project: toadhopper
|
76
119
|
rubygems_version: 1.3.7
|
77
120
|
signing_key:
|
78
121
|
specification_version: 3
|
@@ -80,5 +123,6 @@ summary: Post error notifications to Hoptoad
|
|
80
123
|
test_files:
|
81
124
|
- test/helper.rb
|
82
125
|
- test/test_convenience_constructor.rb
|
126
|
+
- test/test_deploy_tracking.rb
|
83
127
|
- test/test_filtering.rb
|
84
128
|
- test/test_posting.rb
|