bugzscout 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/bugzscout.rb +70 -0
  2. metadata +64 -0
@@ -0,0 +1,70 @@
1
+ # This library that gives you easy access to the excellent BugzScout feature of FogBugz (http://fogcreek.com/fogbugz).
2
+ # For those that don't know, BugzScout allows bug data (exceptions, user input, etc) to be reported back to your FogBugz install
3
+ # for further diagnosis.
4
+ #
5
+ # Author:: Michael Gorsuch (mailto:michael@styledbits.com)
6
+ # Copyright:: Copyright (c) 2009 Michael Gorsuch
7
+ # License:: Distributed under the same terms as Ruby
8
+
9
+ require 'rubygems'
10
+ require 'httpclient'
11
+ require 'uri'
12
+
13
+ # This is the core class that does all of the heavy lifting.
14
+ class BugzScout
15
+ attr_accessor :url, :user, :project, :area, :title, :new, :body, :email
16
+
17
+ # provide BugzScout with the URL of your FogBugz instance, including the 'scoutsubmit.asp' entry point
18
+ # example: https://styledbits.fogbugz.com/scoutsubmit.asp
19
+ def initialize(url)
20
+ self.url = url
21
+ end
22
+
23
+ # send the response to FogBugz
24
+ # return true if all goes well
25
+ # throw a BugzScoutError exception along with the error text if otherwise.
26
+ def submit
27
+ # ensure that the required fields are included
28
+ validate
29
+
30
+ body = {
31
+ :ScoutUserName => self.user,
32
+ :ScoutProject => self.project,
33
+ :ScoutArea => self.area,
34
+ :Description => self.title,
35
+ :ForceNewBug => self.new,
36
+ :Extra => self.body,
37
+ :Email => self.email,
38
+ :ScoutDefaultMessage => "",
39
+ :FriendlyResponse => 0
40
+ }
41
+ client = HTTPClient.new
42
+ response = client.post(url, body).content
43
+
44
+ if response =~ /<Error>(.*)<\/Error>/
45
+ # if we see an error response, we know that we fudged some of our input values to BugzScout
46
+ # the error message should contain where we went wrong.
47
+ # We raise the exception so the user can catch it and log if necessary. No one likes things that fail silently!
48
+ raise(BugzScoutError, $1)
49
+ else
50
+ # we'll return 'true' for the sake of clarity
51
+ return true
52
+ end
53
+ end
54
+
55
+ def validate
56
+ raise(BugzScoutError, "You have to provide a user name") if !self.user
57
+ raise(BugzScoutError, "You must provide a FogBugz project") if !self.project
58
+ raise(BugzScoutError, "You have to provide an area") if !self.area
59
+ end
60
+
61
+ def self.submit(url)
62
+ scout = BugzScout.new(url)
63
+ yield scout
64
+ scout.submit
65
+ end
66
+
67
+ end
68
+
69
+ # just a simple custom exception
70
+ class BugzScoutError < RuntimeError ; end
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bugzscout
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.3
5
+ platform: ruby
6
+ authors:
7
+ - Michael Gorsuch
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2009-10-26 00:00:00 -04:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: httpclient
17
+ type: :runtime
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ description:
26
+ email: michael@styledbits.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files: []
32
+
33
+ files:
34
+ - lib/bugzscout.rb
35
+ has_rdoc: true
36
+ homepage: http://bitbucket.org/mgorsuch/rb-bugzscout
37
+ licenses: []
38
+
39
+ post_install_message:
40
+ rdoc_options: []
41
+
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: "0"
49
+ version:
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: "0"
55
+ version:
56
+ requirements: []
57
+
58
+ rubyforge_project:
59
+ rubygems_version: 1.3.4
60
+ signing_key:
61
+ specification_version: 3
62
+ summary: A package for using Fog Creek Software's FogBugz BugzScout bug reporting system.
63
+ test_files: []
64
+