Class: Redmine::Client
Constant Summary collapse
- NAMESPACE =
{ "atom" => "http://www.w3.org/2005/Atom" }
Instance Attribute Summary collapse
-
#domain ⇒ Object
Returns the value of attribute domain.
-
#key ⇒ Object
Returns the value of attribute key.
-
#protocol ⇒ Object
Returns the value of attribute protocol.
Instance Method Summary collapse
- #doc ⇒ Object
-
#initialize(options = {}) ⇒ Client
constructor
A new instance of Client.
- #my_issues(limit = nil) ⇒ Object
- #reset ⇒ Object
Methods included from Debug
Constructor Details
#initialize(options = {}) ⇒ Client
Returns a new instance of Client.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/redmine/client.rb', line 11 def initialize( = {}) = { :key => nil, :domain => nil, :protocol => "http", :debug => true }.merge() @debug = [:debug] @key = [:key] @domain = [:domain] @protocol = [:protocol] debug "[CLIENT]" do puts end end |
Instance Attribute Details
#domain ⇒ Object
Returns the value of attribute domain.
9 10 11 |
# File 'lib/redmine/client.rb', line 9 def domain @domain end |
#key ⇒ Object
Returns the value of attribute key.
9 10 11 |
# File 'lib/redmine/client.rb', line 9 def key @key end |
#protocol ⇒ Object
Returns the value of attribute protocol.
9 10 11 |
# File 'lib/redmine/client.rb', line 9 def protocol @protocol end |
Instance Method Details
#doc ⇒ Object
55 56 57 |
# File 'lib/redmine/client.rb', line 55 def doc @doc ||= Nokogiri::XML(open(issues_url)) end |
#my_issues(limit = nil) ⇒ Object
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 |
# File 'lib/redmine/client.rb', line 29 def my_issues(limit = nil) projects = {} doc.xpath('//atom:entry', NAMESPACE ).each do |e| id = e.xpath('.//atom:id', NAMESPACE).first.content.split("/").last raw_title = e.xpath('.//atom:title', NAMESPACE).first.content regex = /([^-]*) - (.*)/ match = raw_title.match(regex) project = match[1] title = match[2] projects[project] ||= [] projects[project] << { :id => id, :title => title } end debug "[URL]" do puts issues_url end return projects end |
#reset ⇒ Object
59 60 61 |
# File 'lib/redmine/client.rb', line 59 def reset @doc = nil end |