bugzscout 0.0.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/bugzscout.rb +51 -49
- metadata +3 -3
data/lib/bugzscout.rb
CHANGED
@@ -10,61 +10,63 @@ require 'rubygems'
|
|
10
10
|
require 'httpclient'
|
11
11
|
require 'uri'
|
12
12
|
|
13
|
-
|
14
|
-
class
|
15
|
-
|
13
|
+
module FogBugz
|
14
|
+
# This is the core class that does all of the heavy lifting.
|
15
|
+
class BugzScout
|
16
|
+
attr_accessor :url, :user, :project, :area, :title, :new, :body, :email
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
18
|
+
# provide BugzScout with the URL of your FogBugz instance, including the 'scoutsubmit.asp' entry point
|
19
|
+
# example: https://styledbits.fogbugz.com/scoutsubmit.asp
|
20
|
+
def initialize(url)
|
21
|
+
self.url = url
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
# send the response to FogBugz
|
25
|
+
# return true if all goes well
|
26
|
+
# throw a BugzScoutError exception along with the error text if otherwise.
|
27
|
+
def submit
|
28
|
+
# ensure that the required fields are included
|
29
|
+
validate
|
29
30
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
31
|
+
body = {
|
32
|
+
:ScoutUserName => self.user,
|
33
|
+
:ScoutProject => self.project,
|
34
|
+
:ScoutArea => self.area,
|
35
|
+
:Description => self.title,
|
36
|
+
:ForceNewBug => self.new,
|
37
|
+
:Extra => self.body,
|
38
|
+
:Email => self.email,
|
39
|
+
:ScoutDefaultMessage => "",
|
40
|
+
:FriendlyResponse => 0
|
41
|
+
}
|
42
|
+
client = HTTPClient.new
|
43
|
+
response = client.post(url, body).content
|
43
44
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
45
|
+
if response =~ /<Error>(.*)<\/Error>/
|
46
|
+
# if we see an error response, we know that we fudged some of our input values to BugzScout
|
47
|
+
# the error message should contain where we went wrong.
|
48
|
+
# We raise the exception so the user can catch it and log if necessary. No one likes things that fail silently!
|
49
|
+
raise(BugzScoutError, $1)
|
50
|
+
else
|
51
|
+
# we'll return 'true' for the sake of clarity
|
52
|
+
return true
|
53
|
+
end
|
52
54
|
end
|
53
|
-
end
|
54
55
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
56
|
+
def validate
|
57
|
+
raise(BugzScoutError, "You have to provide a user name") if !self.user
|
58
|
+
raise(BugzScoutError, "You must provide a FogBugz project") if !self.project
|
59
|
+
raise(BugzScoutError, "You have to provide an area") if !self.area
|
60
|
+
end
|
60
61
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
def self.submit(url)
|
63
|
+
scout = BugzScout.new(url)
|
64
|
+
yield scout
|
65
|
+
scout.submit
|
66
|
+
end
|
66
67
|
|
67
|
-
end
|
68
|
+
end
|
68
69
|
|
69
|
-
# just a simple custom exception
|
70
|
-
class BugzScoutError < RuntimeError ; end
|
70
|
+
# just a simple custom exception
|
71
|
+
class BugzScoutError < RuntimeError ; end
|
72
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bugzscout
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Gorsuch
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-11-
|
12
|
+
date: 2009-11-07 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -33,7 +33,7 @@ extra_rdoc_files: []
|
|
33
33
|
files:
|
34
34
|
- lib/bugzscout.rb
|
35
35
|
has_rdoc: true
|
36
|
-
homepage: http://github.com/mgorsuch/
|
36
|
+
homepage: http://github.com/mgorsuch/bugzscout
|
37
37
|
licenses: []
|
38
38
|
|
39
39
|
post_install_message:
|