Class: FogBugz::BugzScout
- Inherits:
-
Object
- Object
- FogBugz::BugzScout
- Defined in:
- lib/bugzscout.rb
Overview
This is the core class that does all of the heavy lifting.
Instance Attribute Summary collapse
-
#area ⇒ Object
Returns the value of attribute area.
-
#body ⇒ Object
Returns the value of attribute body.
-
#email ⇒ Object
Returns the value of attribute email.
-
#new ⇒ Object
Returns the value of attribute new.
-
#project ⇒ Object
Returns the value of attribute project.
-
#title ⇒ Object
Returns the value of attribute title.
-
#url ⇒ Object
Returns the value of attribute url.
-
#user ⇒ Object
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(url) ⇒ BugzScout
constructor
provide BugzScout with the URL of your FogBugz instance, including the ‘scoutsubmit.asp’ entry point example: styledbits.fogbugz.com/scoutsubmit.asp.
-
#submit ⇒ Object
send the response to FogBugz return true if all goes well throw a BugzScoutError exception along with the error text if otherwise.
- #validate ⇒ Object
Constructor Details
#initialize(url) ⇒ BugzScout
provide BugzScout with the URL of your FogBugz instance, including the ‘scoutsubmit.asp’ entry point example: styledbits.fogbugz.com/scoutsubmit.asp
20 21 22 |
# File 'lib/bugzscout.rb', line 20 def initialize(url) self.url = url end |
Instance Attribute Details
#area ⇒ Object
Returns the value of attribute area.
16 17 18 |
# File 'lib/bugzscout.rb', line 16 def area @area end |
#body ⇒ Object
Returns the value of attribute body.
16 17 18 |
# File 'lib/bugzscout.rb', line 16 def body @body end |
#email ⇒ Object
Returns the value of attribute email.
16 17 18 |
# File 'lib/bugzscout.rb', line 16 def email @email end |
#new ⇒ Object
Returns the value of attribute new.
16 17 18 |
# File 'lib/bugzscout.rb', line 16 def new @new end |
#project ⇒ Object
Returns the value of attribute project.
16 17 18 |
# File 'lib/bugzscout.rb', line 16 def project @project end |
#title ⇒ Object
Returns the value of attribute title.
16 17 18 |
# File 'lib/bugzscout.rb', line 16 def title @title end |
#url ⇒ Object
Returns the value of attribute url.
16 17 18 |
# File 'lib/bugzscout.rb', line 16 def url @url end |
#user ⇒ Object
Returns the value of attribute user.
16 17 18 |
# File 'lib/bugzscout.rb', line 16 def user @user end |
Class Method Details
Instance Method Details
#submit ⇒ Object
send the response to FogBugz return true if all goes well throw a BugzScoutError exception along with the error text if otherwise.
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/bugzscout.rb', line 27 def submit # ensure that the required fields are included validate body = { :ScoutUserName => self.user, :ScoutProject => self.project, :ScoutArea => self.area, :Description => self.title, :ForceNewBug => self.new, :Extra => self.body, :Email => self.email, :ScoutDefaultMessage => "", :FriendlyResponse => 0 } client = HTTPClient.new response = client.post(url, body).content if response =~ /<Error>(.*)<\/Error>/ # if we see an error response, we know that we fudged some of our input values to BugzScout # the error message should contain where we went wrong. # We raise the exception so the user can catch it and log if necessary. No one likes things that fail silently! raise(BugzScoutError, $1) else # we'll return 'true' for the sake of clarity return true end end |
#validate ⇒ Object
56 57 58 59 60 |
# File 'lib/bugzscout.rb', line 56 def validate raise(BugzScoutError, "You have to provide a user name") if !self.user raise(BugzScoutError, "You must provide a FogBugz project") if !self.project raise(BugzScoutError, "You have to provide an area") if !self.area end |