diff options
| author | Zack Hobson | 2013-11-22 10:34:36 -0800 | 
|---|---|---|
| committer | Zack Hobson | 2013-11-22 10:34:36 -0800 | 
| commit | 8982e3bbb1606677092b4594919312517f8c9c98 (patch) | |
| tree | 03dc6dd91225ea054fcdba529de035288209440f | |
| parent | 0ce2ec981a0ee3e6a8b232445f1d29b10abe1763 (diff) | |
| download | hcl-8982e3bbb1606677092b4594919312517f8c9c98.tar.bz2 | |
Never mind, I am going to find a better way to refactor this stuff
This reverts commit 0ce2ec981a0ee3e6a8b232445f1d29b10abe1763.
| -rw-r--r-- | lib/hcl/day_entry.rb | 6 | ||||
| -rw-r--r-- | lib/hcl/task.rb | 4 | ||||
| -rw-r--r-- | lib/hcl/timesheet_resource.rb | 33 | 
3 files changed, 10 insertions, 33 deletions
| diff --git a/lib/hcl/day_entry.rb b/lib/hcl/day_entry.rb index 2279e12..c3fe254 100644 --- a/lib/hcl/day_entry.rb +++ b/lib/hcl/day_entry.rb @@ -26,7 +26,7 @@ module HCl      def cancel        begin -        delete("daily/delete/#{id}") +        DayEntry.delete("daily/delete/#{id}")        rescue TimesheetResource::Failure          return false        end @@ -42,7 +42,7 @@ module HCl        # If I don't include hours it gets reset.        # This doens't appear to be the case for task and project.        (self.notes << "\n#{new_notes}").lstrip! -      post "daily/update/#{id}", +      DayEntry.post "daily/update/#{id}",          %{<request><notes>#{notes}</notes><hours>#{hours}</hours></request>}      end @@ -69,7 +69,7 @@ module HCl      end      def toggle -      get("daily/timer/#{id}") +      DayEntry.get("daily/timer/#{id}")        self      end diff --git a/lib/hcl/task.rb b/lib/hcl/task.rb index 59dc26f..cf63514 100644 --- a/lib/hcl/task.rb +++ b/lib/hcl/task.rb @@ -59,7 +59,7 @@ module HCl      def add opts        notes = opts[:note]        starting_time = opts[:starting_time] || 0 -      days = DayEntry.from_xml post("daily/add", <<-EOT) +      days = DayEntry.from_xml Task.post("daily/add", <<-EOT)        <request>          <notes>#{notes}</notes>          <hours>#{starting_time}</hours> @@ -76,7 +76,7 @@ module HCl        if day.running?          day        else -        DayEntry.from_xml(get("daily/timer/#{day.id}")).first +        DayEntry.from_xml(Task.get("daily/timer/#{day.id}")).first        end      end    end diff --git a/lib/hcl/timesheet_resource.rb b/lib/hcl/timesheet_resource.rb index 82a2bcb..d4624ad 100644 --- a/lib/hcl/timesheet_resource.rb +++ b/lib/hcl/timesheet_resource.rb @@ -58,10 +58,6 @@ module HCl        http_do Net::HTTP::Post, action, data      end -    def self.put action, data -      http_do Net::HTTP::Put, action, data -    end -      def self.delete action        http_do Net::HTTP::Delete, action      end @@ -88,13 +84,6 @@ module HCl        end      end -    def self.xml_to_hash elem -      elem.elements.map { |e| e.name }.inject({}) do |a, f| -        a[f.to_sym] = CGI.unescape_html(elem.elements[f].text || '') if elem.elements[f] -        a -      end -    end -      def id        @data[:id]      end @@ -107,23 +96,11 @@ module HCl        end      end -    protected - -    def xml_to_hash elem -      self.class.xml_to_hash elem -    end -    def get *args -      self.class.get *args -    end -    def post *args -      self.class.post *args -    end -    def put *args -      self.class.put *args -    end -    def delete *args -      self.class.delete *args +    def self.xml_to_hash elem +      elem.elements.map { |e| e.name }.inject({}) do |a, f| +        a[f.to_sym] = CGI.unescape_html(elem.elements[f].text || '') if elem.elements[f] +        a +      end      end -    end  end | 
