abrt 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2012 Vít Ondruch
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,19 @@
1
+ = abrt
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to abrt
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2012 Vít Ondruch. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'rake'
5
+
6
+ require 'rspec/core'
7
+ require 'rspec/core/rake_task'
8
+ RSpec::Core::RakeTask.new(:spec) do |spec|
9
+ spec.pattern = FileList['spec/**/*_spec.rb']
10
+ end
11
+
12
+ task :default => :spec
data/lib/abrt.rb ADDED
@@ -0,0 +1,11 @@
1
+ at_exit do
2
+ if $!
3
+ require 'abrt/handler'
4
+ ABRT.handle_exception($!)
5
+ end
6
+ end
7
+
8
+ # Test drive the gem.
9
+ if File.identical?(__FILE__, $0)
10
+ [1, 2, 3].freeze << 4
11
+ end
@@ -0,0 +1,9 @@
1
+ module ABRT
2
+ module Exception
3
+ def format
4
+ backtrace = self.backtrace.dup
5
+ backtrace[0] += ": #{self.message} (#{self.class.name})"
6
+ backtrace.join "\n\tfrom "
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,65 @@
1
+ module ABRT
2
+
3
+ def self.handle_exception(exception)
4
+ last_exception = $!
5
+
6
+ syslog.notice "detected unhandled Ruby exception in '#{$0}'"
7
+
8
+ require 'abrt/exception.rb'
9
+ last_exception.extend(ABRT::Exception)
10
+
11
+ # TODO: Report only scripts with absolute path.
12
+
13
+ write_dump last_exception.format
14
+ end
15
+
16
+ private
17
+
18
+ def self.syslog
19
+ return @syslog if @syslog
20
+
21
+ require 'syslog'
22
+ @syslog = Syslog.open 'abrt'
23
+ end
24
+
25
+ def self.write_dump(backtrace)
26
+ begin
27
+ require 'socket'
28
+
29
+ # TODO: Get var_run from ABRT configuration.
30
+ var_run = "/var/run"
31
+ socket = UNIXSocket.new "#{var_run}/abrt/abrt.socket"
32
+
33
+ socket.write "PUT / HTTP/1.1\r\n\r\n"
34
+ socket.write "PID=#{Process.pid}\0"
35
+ socket.write "EXECUTABLE=#{$PROGRAM_NAME}\0"
36
+ # TODO: Do we need specialized Ruby analyzer?
37
+ # socket.write "ANALYZER=Ruby\0"
38
+ socket.write "ANALYZER=Python\0"
39
+ socket.write "BASENAME=rbhook\0"
40
+ socket.write "REASON=#{backtrace.first}\0"
41
+ socket.write "BACKTRACE=#{backtrace}\0"
42
+ socket.close_write
43
+
44
+ response = socket.read
45
+
46
+ socket.close
47
+
48
+ parts = response.split
49
+ code = Integer(parts[1]) rescue false
50
+ if (parts.size < 2) or
51
+ (not parts[0] =~ %r{^HTTP/}) or
52
+ (not code) or
53
+ (code >= 400)
54
+ then
55
+ if response.empty?
56
+ syslog.err "error sending data to ABRT daemon. Empty response received"
57
+ else
58
+ syslog.err "error sending data to ABRT daemon: #{response}"
59
+ end
60
+ end
61
+ rescue StandardError => e
62
+ syslog.err "can't communicate with ABRT daemon, is it running? #{e.message}"
63
+ end
64
+ end
65
+ end
metadata ADDED
@@ -0,0 +1,86 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: abrt
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - "V\xC3\xADt Ondruch"
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2012-04-16 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ name: rspec
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ~>
27
+ - !ruby/object:Gem::Version
28
+ hash: 47
29
+ segments:
30
+ - 2
31
+ - 8
32
+ - 0
33
+ version: 2.8.0
34
+ type: :development
35
+ version_requirements: *id001
36
+ description: Provides ABRT reporting support for applications written using Ruby.
37
+ email: v.ondruch@tiscali.cz
38
+ executables: []
39
+
40
+ extensions: []
41
+
42
+ extra_rdoc_files:
43
+ - LICENSE.txt
44
+ - README.rdoc
45
+ files:
46
+ - LICENSE.txt
47
+ - README.rdoc
48
+ - Rakefile
49
+ - lib/abrt/exception.rb
50
+ - lib/abrt/handler.rb
51
+ - lib/abrt.rb
52
+ homepage: http://github.com/voxik/abrt-ruby
53
+ licenses:
54
+ - MIT
55
+ post_install_message:
56
+ rdoc_options: []
57
+
58
+ require_paths:
59
+ - lib
60
+ required_ruby_version: !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ">="
64
+ - !ruby/object:Gem::Version
65
+ hash: 3
66
+ segments:
67
+ - 0
68
+ version: "0"
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ none: false
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ hash: 3
75
+ segments:
76
+ - 0
77
+ version: "0"
78
+ requirements: []
79
+
80
+ rubyforge_project:
81
+ rubygems_version: 1.8.11
82
+ signing_key:
83
+ specification_version: 3
84
+ summary: ABRT support for Ruby MRI.
85
+ test_files: []
86
+