graytoad 0.0.5 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -10,40 +10,13 @@ begin
10
10
  gem.homepage = "http://github.com/AlekSi/graytoad"
11
11
  gem.authors = ["Alexey Palazhchenko"]
12
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"
13
+ gem.add_dependency "aleksi-gelf", "~> 0.9.780"
16
14
  end
17
15
  Jeweler::GemcutterTasks.new
18
16
  rescue LoadError
19
17
  puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
18
  end
21
19
 
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
20
  require 'rake/rdoctask'
48
21
  Rake::RDocTask.new do |rdoc|
49
22
  version = File.exist?('VERSION') ? File.read('VERSION') : ""
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.5
1
+ 0.0.7
data/graytoad.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{graytoad}
8
- s.version = "0.0.5"
8
+ s.version = "0.0.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Alexey Palazhchenko"]
@@ -23,19 +23,13 @@ Gem::Specification.new do |s|
23
23
  "Rakefile",
24
24
  "VERSION",
25
25
  "graytoad.gemspec",
26
- "lib/graytoad.rb",
27
- "test/helper.rb",
28
- "test/test_graytoad.rb"
26
+ "lib/graytoad.rb"
29
27
  ]
30
28
  s.homepage = %q{http://github.com/AlekSi/graytoad}
31
29
  s.rdoc_options = ["--charset=UTF-8"]
32
30
  s.require_paths = ["lib"]
33
31
  s.rubygems_version = %q{1.3.7}
34
32
  s.summary = %q{Graylog2 + Hoptoad}
35
- s.test_files = [
36
- "test/helper.rb",
37
- "test/test_graytoad.rb"
38
- ]
39
33
 
40
34
  if s.respond_to? :specification_version then
41
35
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
@@ -43,20 +37,14 @@ Gem::Specification.new do |s|
43
37
 
44
38
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
45
39
  s.add_runtime_dependency(%q<hoptoad_notifier>, ["~> 2.3.0"])
46
- s.add_runtime_dependency(%q<gelf>, ["~> 0.9.2"])
47
- s.add_development_dependency(%q<shoulda>, ["~> 2.11.0"])
48
- s.add_development_dependency(%q<mocha>, ["~> 0.9.9"])
40
+ s.add_runtime_dependency(%q<aleksi-gelf>, ["~> 0.9.780"])
49
41
  else
50
42
  s.add_dependency(%q<hoptoad_notifier>, ["~> 2.3.0"])
51
- s.add_dependency(%q<gelf>, ["~> 0.9.2"])
52
- s.add_dependency(%q<shoulda>, ["~> 2.11.0"])
53
- s.add_dependency(%q<mocha>, ["~> 0.9.9"])
43
+ s.add_dependency(%q<aleksi-gelf>, ["~> 0.9.780"])
54
44
  end
55
45
  else
56
46
  s.add_dependency(%q<hoptoad_notifier>, ["~> 2.3.0"])
57
- s.add_dependency(%q<gelf>, ["~> 0.9.2"])
58
- s.add_dependency(%q<shoulda>, ["~> 2.11.0"])
59
- s.add_dependency(%q<mocha>, ["~> 0.9.9"])
47
+ s.add_dependency(%q<aleksi-gelf>, ["~> 0.9.780"])
60
48
  end
61
49
  end
62
50
 
data/lib/graytoad.rb CHANGED
@@ -3,42 +3,13 @@ require "hoptoad_notifier"
3
3
 
4
4
  class Graytoad
5
5
  class << self
6
- attr_accessor :gelf_host, :gelf_port, :this_host
6
+ attr_accessor :gelf_host, :gelf_port
7
7
 
8
- def notify(e, opts={})
9
- detect_this_host if this_host.nil?
8
+ def notify(*args)
9
+ HoptoadNotifier.notify(args)
10
10
 
11
- if e.is_a?(Hash)
12
- opts, e = e, nil
13
- end
14
-
15
- g = Gelf.new(gelf_host, gelf_port)
16
- g.host = this_host
17
-
18
- if e.nil?
19
- g.short_message, g.full_message = "#{opts[:error_class]}: #{opts[:error_message]}", backtrace_to_message(caller)
20
- opts.each_pair { |key, value| g.add_additional(key.to_s, value) }
21
- HoptoadNotifier.notify(opts)
22
- else
23
- g.short_message, g.full_message = e.message, "Backtrace:\n" + backtrace_to_message(e.backtrace)
24
- HoptoadNotifier.notify(e, opts)
25
- end
26
-
27
- g.send
28
- end
29
-
30
- private
31
- def backtrace_to_message(bt)
32
- if bt.nil?
33
- "No backtrace."
34
- else
35
- "Backtrace:\n" + bt.join("\n")
36
- end
37
- end
38
-
39
- def detect_this_host
40
- require 'socket'
41
- self.this_host = Socket.gethostname
11
+ @notifier ||= GELF::Notifier.new(@gelf_host, @gelf_port)
12
+ @notifier.notify(args)
42
13
  end
43
14
  end
44
15
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graytoad
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 7
10
+ version: 0.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alexey Palazhchenko
@@ -35,53 +35,21 @@ dependencies:
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
38
- name: gelf
38
+ name: aleksi-gelf
39
39
  prerelease: false
40
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- hash: 63
45
+ hash: 1571
46
46
  segments:
47
47
  - 0
48
48
  - 9
49
- - 2
50
- version: 0.9.2
49
+ - 780
50
+ version: 0.9.780
51
51
  type: :runtime
52
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
53
  description: Notify both Graylog2 and Hoptoad with this wrapper.
86
54
  email:
87
55
  executables: []
@@ -100,8 +68,6 @@ files:
100
68
  - VERSION
101
69
  - graytoad.gemspec
102
70
  - lib/graytoad.rb
103
- - test/helper.rb
104
- - test/test_graytoad.rb
105
71
  has_rdoc: true
106
72
  homepage: http://github.com/AlekSi/graytoad
107
73
  licenses: []
@@ -136,6 +102,5 @@ rubygems_version: 1.3.7
136
102
  signing_key:
137
103
  specification_version: 3
138
104
  summary: Graylog2 + Hoptoad
139
- test_files:
140
- - test/helper.rb
141
- - test/test_graytoad.rb
105
+ test_files: []
106
+
data/test/helper.rb DELETED
@@ -1,11 +0,0 @@
1
- require 'rubygems'
2
- require 'test/unit'
3
- require 'shoulda'
4
- require 'mocha'
5
-
6
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
7
- $LOAD_PATH.unshift(File.dirname(__FILE__))
8
- require 'graytoad'
9
-
10
- class Test::Unit::TestCase
11
- end
@@ -1,39 +0,0 @@
1
- require 'helper'
2
- require 'socket'
3
-
4
- HOST = Socket.gethostname
5
-
6
- class TestGraytoad < Test::Unit::TestCase
7
- context "with exception" do
8
- setup do
9
- @e = RuntimeError.new("Short message")
10
- Gelf.any_instance.expects(:short_message=)
11
- Gelf.any_instance.expects(:full_message=)
12
- Gelf.any_instance.expects(:host=).with(HOST)
13
- end
14
-
15
- should "notify with exception" do
16
- Gelf.any_instance.expects(:send)
17
-
18
- HoptoadNotifier.expects(:notify).with(@e, {})
19
-
20
- Graytoad.notify(@e)
21
- end
22
-
23
- should "notify with exception and params" do
24
- Gelf.any_instance.expects(:send)
25
-
26
- HoptoadNotifier.expects(:notify).with(@e, :user => 'user')
27
-
28
- Graytoad.notify(@e, :user => 'user')
29
- end
30
-
31
- should "notify with params" do
32
- Gelf.any_instance.expects(:send)
33
-
34
- HoptoadNotifier.expects(:notify).with(:error_class => @e.class.to_s, :error_message => @e.message.to_s, :other_param => 'Param')
35
-
36
- Graytoad.notify(:error_class => @e.class.to_s, :error_message => @e.message.to_s, :other_param => 'Param')
37
- end
38
- end
39
- end