graytoad 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +17 -0
- data/Rakefile +55 -0
- data/VERSION +1 -0
- data/graytoad.gemspec +61 -0
- data/lib/Graytoad.rb +24 -0
- data/test/graytoad.rb +19 -0
- data/test/helper.rb +11 -0
- metadata +141 -0
data/.document
ADDED
data/.gitignore
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Alexey Palazhchenko
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
= Graytoad
|
2
|
+
|
3
|
+
Notify both Graylog2 and Hoptoad with this wrapper.
|
4
|
+
|
5
|
+
== Note on Patches/Pull Requests
|
6
|
+
|
7
|
+
* Fork the project.
|
8
|
+
* Make your feature addition or bug fix.
|
9
|
+
* Add tests for it. This is important so I don't break it in a
|
10
|
+
future version unintentionally.
|
11
|
+
* Commit, do not mess with rakefile, version, or history.
|
12
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
13
|
+
* Send me a pull request. Bonus points for topic branches.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2010 Alexey Palazhchenko. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "graytoad"
|
8
|
+
gem.summary = "Graylog2 + Hoptoad"
|
9
|
+
gem.description = "Notify both Graylog2 and Hoptoad with this wrapper."
|
10
|
+
gem.homepage = "http://github.com/AlekSi/graytoad"
|
11
|
+
gem.authors = ["Alexey Palazhchenko"]
|
12
|
+
gem.add_dependency "hoptoad_notifier", "~> 2.3.0"
|
13
|
+
gem.add_dependency "gelf", "~> 0.9.2"
|
14
|
+
gem.add_development_dependency "shoulda", "~> 2.11.0"
|
15
|
+
gem.add_development_dependency "mocha", "~> 0.9.9"
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'rake/testtask'
|
23
|
+
Rake::TestTask.new(:test) do |test|
|
24
|
+
test.libs << 'lib' << 'test'
|
25
|
+
test.pattern = 'test/**/test_*.rb'
|
26
|
+
test.verbose = true
|
27
|
+
end
|
28
|
+
|
29
|
+
begin
|
30
|
+
require 'rcov/rcovtask'
|
31
|
+
Rcov::RcovTask.new do |test|
|
32
|
+
test.libs << 'test'
|
33
|
+
test.pattern = 'test/**/test_*.rb'
|
34
|
+
test.verbose = true
|
35
|
+
test.rcov_opts << '--exclude gem'
|
36
|
+
end
|
37
|
+
rescue LoadError
|
38
|
+
task :rcov do
|
39
|
+
abort "RCov is not available. In order to run rcov, you must: gem install rcov"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
task :test => :check_dependencies
|
44
|
+
|
45
|
+
task :default => :test
|
46
|
+
|
47
|
+
require 'rake/rdoctask'
|
48
|
+
Rake::RDocTask.new do |rdoc|
|
49
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
50
|
+
|
51
|
+
rdoc.rdoc_dir = 'rdoc'
|
52
|
+
rdoc.title = "Graytoad #{version}"
|
53
|
+
rdoc.rdoc_files.include('README*')
|
54
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
55
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.1
|
data/graytoad.gemspec
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{graytoad}
|
8
|
+
s.version = "0.0.1"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Alexey Palazhchenko"]
|
12
|
+
s.date = %q{2010-11-08}
|
13
|
+
s.description = %q{Notify both Graylog2 and Hoptoad with this wrapper.}
|
14
|
+
s.extra_rdoc_files = [
|
15
|
+
"LICENSE",
|
16
|
+
"README.rdoc"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".document",
|
20
|
+
".gitignore",
|
21
|
+
"LICENSE",
|
22
|
+
"README.rdoc",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"graytoad.gemspec",
|
26
|
+
"lib/Graytoad.rb",
|
27
|
+
"test/helper.rb"
|
28
|
+
]
|
29
|
+
s.homepage = %q{http://github.com/AlekSi/graytoad}
|
30
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
31
|
+
s.require_paths = ["lib"]
|
32
|
+
s.rubygems_version = %q{1.3.7}
|
33
|
+
s.summary = %q{Graylog2 + Hoptoad}
|
34
|
+
s.test_files = [
|
35
|
+
"test/graytoad.rb",
|
36
|
+
"test/helper.rb"
|
37
|
+
]
|
38
|
+
|
39
|
+
if s.respond_to? :specification_version then
|
40
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
41
|
+
s.specification_version = 3
|
42
|
+
|
43
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
44
|
+
s.add_runtime_dependency(%q<hoptoad_notifier>, ["~> 2.3.0"])
|
45
|
+
s.add_runtime_dependency(%q<gelf>, ["~> 0.9.2"])
|
46
|
+
s.add_development_dependency(%q<shoulda>, ["~> 2.11.0"])
|
47
|
+
s.add_development_dependency(%q<mocha>, ["~> 0.9.9"])
|
48
|
+
else
|
49
|
+
s.add_dependency(%q<hoptoad_notifier>, ["~> 2.3.0"])
|
50
|
+
s.add_dependency(%q<gelf>, ["~> 0.9.2"])
|
51
|
+
s.add_dependency(%q<shoulda>, ["~> 2.11.0"])
|
52
|
+
s.add_dependency(%q<mocha>, ["~> 0.9.9"])
|
53
|
+
end
|
54
|
+
else
|
55
|
+
s.add_dependency(%q<hoptoad_notifier>, ["~> 2.3.0"])
|
56
|
+
s.add_dependency(%q<gelf>, ["~> 0.9.2"])
|
57
|
+
s.add_dependency(%q<shoulda>, ["~> 2.11.0"])
|
58
|
+
s.add_dependency(%q<mocha>, ["~> 0.9.9"])
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
data/lib/Graytoad.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
require "gelf"
|
2
|
+
require "hoptoad_notifier"
|
3
|
+
|
4
|
+
class Graytoad
|
5
|
+
class << self
|
6
|
+
attr_accessor :gelf_host, :gelf_port, :this_host
|
7
|
+
|
8
|
+
def notify(e)
|
9
|
+
detect_this_host if this_host.nil?
|
10
|
+
|
11
|
+
HoptoadNotifier.notify(e)
|
12
|
+
|
13
|
+
g = Gelf.new(gelf_host, gelf_port)
|
14
|
+
g.short_message, g.full_message, g.host = e.message, e.backtrace, this_host
|
15
|
+
g.send
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
def detect_this_host
|
20
|
+
require 'socket'
|
21
|
+
self.this_host = Socket.gethostname
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/test/graytoad.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'helper'
|
2
|
+
require 'socket'
|
3
|
+
|
4
|
+
HOST = Socket.gethostname
|
5
|
+
|
6
|
+
class TestGraytoad < Test::Unit::TestCase
|
7
|
+
should "notify with standard excpetion" do
|
8
|
+
e = RuntimeError.new("Short message")
|
9
|
+
|
10
|
+
Gelf.any_instance.expects(:short_message=).with(e.message)
|
11
|
+
Gelf.any_instance.expects(:full_message=).with(e.backtrace)
|
12
|
+
Gelf.any_instance.expects(:host=).with(HOST)
|
13
|
+
Gelf.any_instance.expects(:send)
|
14
|
+
|
15
|
+
HoptoadNotifier.expects(:notify).with(e)
|
16
|
+
|
17
|
+
Graytoad.notify(e)
|
18
|
+
end
|
19
|
+
end
|
data/test/helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,141 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: graytoad
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 29
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 1
|
10
|
+
version: 0.0.1
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Alexey Palazhchenko
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-11-08 00:00:00 +03:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: hoptoad_notifier
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 2
|
32
|
+
- 3
|
33
|
+
- 0
|
34
|
+
version: 2.3.0
|
35
|
+
type: :runtime
|
36
|
+
version_requirements: *id001
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: gelf
|
39
|
+
prerelease: false
|
40
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
hash: 63
|
46
|
+
segments:
|
47
|
+
- 0
|
48
|
+
- 9
|
49
|
+
- 2
|
50
|
+
version: 0.9.2
|
51
|
+
type: :runtime
|
52
|
+
version_requirements: *id002
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: shoulda
|
55
|
+
prerelease: false
|
56
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
hash: 35
|
62
|
+
segments:
|
63
|
+
- 2
|
64
|
+
- 11
|
65
|
+
- 0
|
66
|
+
version: 2.11.0
|
67
|
+
type: :development
|
68
|
+
version_requirements: *id003
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: mocha
|
71
|
+
prerelease: false
|
72
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
hash: 41
|
78
|
+
segments:
|
79
|
+
- 0
|
80
|
+
- 9
|
81
|
+
- 9
|
82
|
+
version: 0.9.9
|
83
|
+
type: :development
|
84
|
+
version_requirements: *id004
|
85
|
+
description: Notify both Graylog2 and Hoptoad with this wrapper.
|
86
|
+
email:
|
87
|
+
executables: []
|
88
|
+
|
89
|
+
extensions: []
|
90
|
+
|
91
|
+
extra_rdoc_files:
|
92
|
+
- LICENSE
|
93
|
+
- README.rdoc
|
94
|
+
files:
|
95
|
+
- .document
|
96
|
+
- .gitignore
|
97
|
+
- LICENSE
|
98
|
+
- README.rdoc
|
99
|
+
- Rakefile
|
100
|
+
- VERSION
|
101
|
+
- graytoad.gemspec
|
102
|
+
- lib/Graytoad.rb
|
103
|
+
- test/helper.rb
|
104
|
+
- test/graytoad.rb
|
105
|
+
has_rdoc: true
|
106
|
+
homepage: http://github.com/AlekSi/graytoad
|
107
|
+
licenses: []
|
108
|
+
|
109
|
+
post_install_message:
|
110
|
+
rdoc_options:
|
111
|
+
- --charset=UTF-8
|
112
|
+
require_paths:
|
113
|
+
- lib
|
114
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
hash: 3
|
120
|
+
segments:
|
121
|
+
- 0
|
122
|
+
version: "0"
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
none: false
|
125
|
+
requirements:
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
hash: 3
|
129
|
+
segments:
|
130
|
+
- 0
|
131
|
+
version: "0"
|
132
|
+
requirements: []
|
133
|
+
|
134
|
+
rubyforge_project:
|
135
|
+
rubygems_version: 1.3.7
|
136
|
+
signing_key:
|
137
|
+
specification_version: 3
|
138
|
+
summary: Graylog2 + Hoptoad
|
139
|
+
test_files:
|
140
|
+
- test/graytoad.rb
|
141
|
+
- test/helper.rb
|