roart 0.1.6 → 0.1.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,6 @@
1
+ ==0.1.7 / 2010-30-11
2
+ Added some new error classes, add removed any extraneous raise 'text' (via jrbingham)
3
+
1
4
  ==0.1.6 / 2010-03-09
2
5
  Updated the search feature to pull all the ticket information at the same time, instead of only loading the id and subject.
3
6
  Fixed tests that were failing because of out-of-order strings.
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  module Roart
3
3
 
4
4
  # :stopdoc:
5
- VERSION = '0.1.6'
5
+ VERSION = '0.1.7'
6
6
  LIBPATH = ::File.expand_path(::File.dirname(__FILE__)) + ::File::SEPARATOR
7
7
  PATH = ::File.dirname(LIBPATH) + ::File::SEPARATOR
8
8
  # :startdoc:
@@ -16,7 +16,7 @@ module Roart
16
16
 
17
17
  def initialize(conf)
18
18
  if conf.is_a?(String)
19
- raise "Loading Config File not yet implemented"
19
+ raise RoartError, "Loading Config File not yet implemented"
20
20
  elsif conf.class.name == Hash.name #TODO: Figure out why conf.is_a?(Hash) doesn't work
21
21
  @conf = conf
22
22
  end
@@ -25,7 +25,7 @@ module Roart
25
25
  add_methods!
26
26
  @connection = ConnectionAdapter.new(@conf)
27
27
  else
28
- raise "Configuration Error"
28
+ raise RoartError, "Configuration Error"
29
29
  end
30
30
  end
31
31
 
@@ -8,4 +8,6 @@ module Roart
8
8
 
9
9
  class TicketSystemInterfaceError < RoartError; end
10
10
 
11
+ class TicketNotFoundError < RoartError; end
12
+
11
13
  end
@@ -65,16 +65,12 @@ module Roart
65
65
  payload.delete("text")
66
66
  payload.delete("id") # Can't have text in an update, only create, use comment for updateing
67
67
  payload = payload.to_content_format
68
- puts payload
69
68
  resp = self.class.connection.post(uri, :content => payload)
70
- puts resp
71
69
  resp = resp.split("\n")
72
- raise "Ticket Update Failed" unless resp.first.include?("200")
70
+ raise TicketSystemError, "Ticket Update Failed" unless resp.first.include?("200")
73
71
  resp.each do |line|
74
- puts "line"
75
72
  if line.match(/^# Ticket (\d+) updated./)
76
73
  self.after_update
77
- puts "FOUND"
78
74
  return true
79
75
  else
80
76
  #TODO: Add warnign to ticket
@@ -95,14 +91,14 @@ module Roart
95
91
  payload = comment.to_content_format
96
92
  resp = self.class.connection.post(uri, :content => payload)
97
93
  resp = resp.split("\n")
98
- raise "Ticket Comment Failed" unless resp.first.include?("200")
94
+ raise TicketSystemError, "Ticket Comment Failed" unless resp.first.include?("200")
99
95
  !!resp[2].match(/^# Message recorded/)
100
96
  end
101
97
 
102
98
  # works just like save, but if the save fails, it raises an exception instead of silently returning false
103
99
  #
104
100
  def save!
105
- raise "Ticket Create Failed" unless self.save
101
+ raise TicketSystemError, "Ticket Create Failed" unless self.save
106
102
  true
107
103
  end
108
104
 
@@ -118,7 +114,7 @@ module Roart
118
114
  payload = @attributes.to_content_format
119
115
  resp = self.class.connection.post(uri, :content => payload)
120
116
  resp = resp.split("\n")
121
- raise "Ticket Create Failed" unless resp.first.include?("200")
117
+ raise TicketSystemError, "Ticket Create Failed" unless resp.first.include?("200")
122
118
  resp.each do |line|
123
119
  if tid = line.match(/^# Ticket (\d+) created./)
124
120
  @attributes[:id] = tid[1].to_i
@@ -133,7 +129,7 @@ module Roart
133
129
  end
134
130
 
135
131
  def create! #:nodoc:
136
- raise "Ticket Create Failed" unless self.create
132
+ raise TicketSystemError, "Ticket Create Failed" unless self.create
137
133
  true
138
134
  end
139
135
 
@@ -273,7 +269,7 @@ module Roart
273
269
  end
274
270
 
275
271
  def find_by_ids(args, options) #:nodoc:
276
- raise "First argument must be :all or :first, or an ID with no hash options" unless args.first.is_a?(Fixnum) || args.first.is_a?(String)
272
+ raise ArgumentError, "First argument must be :all or :first, or an ID with no hash options" unless args.first.is_a?(Fixnum) || args.first.is_a?(String)
277
273
  get_ticket_by_id(args.first)
278
274
  end
279
275
 
@@ -292,7 +288,7 @@ module Roart
292
288
 
293
289
  def page_list_array(uri) #:nodoc:
294
290
  page = self.connection.get(uri)
295
- raise TicketSystemError, "Can't get ticket." unless page
291
+ raise TicketSystemInterfaceError, "Can't get ticket." unless page
296
292
  page = page.split("\n")
297
293
  status = page.delete_at(0)
298
294
  if status.include?("200")
@@ -7,6 +7,7 @@ module Roart
7
7
  def to_hash
8
8
  hash = HashWithIndifferentAccess.new
9
9
  self.delete_if{|x| !x.include?(":")}
10
+ raise TicketNotFoundError, "No tickets matching search criteria found." if self.size == 0
10
11
  self.each do |ln|
11
12
  ln = ln.split(":")
12
13
  key = nil
@@ -35,6 +36,7 @@ module Roart
35
36
  def to_search_array
36
37
  array = Array.new
37
38
  self.delete_if{|x| !x.include?(":")}
39
+ raise TicketNotFoundError, "No tickets matching search criteria found." if self.size == 0
38
40
  self.each do |ln|
39
41
  hash = Hash.new
40
42
  ln = ln.split(":")
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{roart}
5
- s.version = "0.1.6"
5
+ s.version = "0.1.7"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["PJ Davis"]
9
- s.date = %q{2010-03-09}
9
+ s.date = %q{2010-03-11}
10
10
  s.description = %q{Interface for working with Request Tracker (RT) tickets inspired by ActiveRecord.}
11
11
  s.email = %q{pj.davis@gmail.com}
12
12
  s.extra_rdoc_files = ["History.txt", "README.rdoc", "spec/test_data/full_history.txt", "spec/test_data/search_ticket.txt", "spec/test_data/single_history.txt", "spec/test_data/ticket.txt"]
@@ -405,7 +405,7 @@ describe "Ticket" do
405
405
  @mock_connection.should_receive(:post).with('uri/REST/1.0/ticket/1/edit', {:content => @post_data}).and_return("RT/3.6.6 400 Not OK\n\n# U's A SUKKA, FOO!.")
406
406
  ticket = Roart::Ticket.send(:instantiate, @payload.update(:id => 1))
407
407
  ticket.subject = 'An Old Ticket'
408
- lambda {ticket.save}.should raise_error
408
+ lambda {ticket.save}.should raise_error(Roart::TicketSystemError)
409
409
  end
410
410
 
411
411
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roart
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - PJ Davis
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-03-09 00:00:00 -06:00
12
+ date: 2010-03-11 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency