lib/hcl/day_entry.rb in zenhob-hcl-0.2.1 vs lib/hcl/day_entry.rb in zenhob-hcl-0.2.2
- old
+ new
@@ -1,9 +1,10 @@
-class HCl
+module HCl
class DayEntry < TimesheetResource
include Utility
+
# Get the time sheet entries for a given day. If no date is provided
# defaults to today.
def self.all date = nil
url = date.nil? ? 'daily' : "daily/#{date.strftime '%j/%Y'}"
from_xml get(url)
@@ -13,22 +14,28 @@
"#{client} #{project} #{task} (#{formatted_hours})"
end
def self.from_xml xml
doc = REXML::Document.new xml
+ raise Failure, "No root node in XML document: #{xml}" if doc.root.nil?
Task.cache_tasks doc
doc.root.elements.collect('//day_entry') do |day|
new xml_to_hash(day)
end
end
# Append a string to the notes for this task.
def append_note new_notes
# If I don't include hours it gets reset.
# This doens't appear to be the case for task and project.
+ if notes.nil?
+ notes = new_notes
+ else
+ notes << " #{new_notes}"
+ end
DayEntry.post("daily/update/#{id}", <<-EOD)
<request>
- <notes>#{notes << " #{new_notes}"}</notes>
+ <notes>#{notes}</notes>
<hours>#{hours}</hours>
</request>
EOD
end