trac4r 1.0.0 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/trac4r/query.rb CHANGED
@@ -51,8 +51,7 @@ module Trac
51
51
  return @connection.call(command,*args)
52
52
  rescue => e
53
53
  if e.message =~ /HTTP-Error/
54
- errorcode = e.message.sub 'HTTP-Error: ',''
55
- raise TracException.new(errorcode,@host,@port,@path,command,args)
54
+ raise TracException.new(e.message,@host,@port,@path,command,args)
56
55
  else
57
56
  raise
58
57
  end
data/lib/trac4r/ticket.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  module Trac
2
2
  # This class represents a ticket as it is retrieved from the database
3
+ # Custom fields are detected and available via runtime-dispatched methods.
4
+ # See +method_missing+
3
5
  class Ticket
4
6
  attr_accessor(:id, # Integer
5
7
  :severity, # String
@@ -29,6 +31,19 @@ module Trac
29
31
  end
30
32
  return true
31
33
  end
34
+
35
+ # If a method call has no args and matches an instance variable,
36
+ # we return its value. e.g. if our tickets have a custom field
37
+ # called +work_units+, then +some_ticket.work_units+ will
38
+ # retrieve that value. This currently only allows retrieval and
39
+ # not updating the value.
40
+ def method_missing(sym,*args)
41
+ if args.size == 0 && instance_variables.include?("@" + sym.to_s)
42
+ instance_eval("@" + sym.to_s)
43
+ else
44
+ super.method_missing(sym,args)
45
+ end
46
+ end
32
47
 
33
48
  # loads a ticket from the XMLRPC response
34
49
  def self.load params
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trac4r
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Niklas Cathro