Sha256: 5879d513c2f99481aff3ee954e0af0acb7dca5d1db8de8a6edca7292802ba35f

Contents?: true

Size: 1.37 KB

Versions: 7

Compression:

Stored size: 1.37 KB

Contents

module PivotalTracker
  class Task
    include HappyMapper

    class << self
      def all(story, options={})
        tasks = parse(Client.connection["/projects/#{story.project_id}/stories/#{story.id}/tasks"].get)
        tasks.each { |t| t.project_id, t.story_id = story.project_id, story.id }
        return tasks
      end
    end

    attr_accessor :project_id, :story_id

    element :id, Integer
    element :description, String
    element :position, Integer
    element :complete, Boolean
    element :created_at, DateTime

    def create
      response = Client.connection["/projects/#{project_id}/stories/#{story_id}/tasks"].post(self.to_xml, :content_type => 'application/xml')
      return Task.parse(response)
    end

    def update
      response = Client.connection["/projects/#{project_id}/stories/#{story_id}/tasks/#{id}"].put(self.to_xml, :content_type => 'application/xml')
      return Task.parse(response)
    end

    def delete
      Client.connection["/projects/#{project_id}/stories/#{story_id}/tasks/#{id}"].delete
    end

    protected

      def to_xml
        builder = Nokogiri::XML::Builder.new do |xml|
          xml.task {
            xml.description "#{description}"
            # xml.position "#{position}"
            xml.complete "#{complete}"
          }
        end
        return builder.to_xml
      end

  end

  class Task
    include Validation
  end
end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
pivotal-tracker-0.4.1 lib/pivotal-tracker/task.rb
pivotal-tracker-0.4.0 lib/pivotal-tracker/task.rb
tsenart-pivotal-tracker-0.5.0 lib/pivotal-tracker/task.rb
tsenart-pivotal-tracker-0.4.0 lib/pivotal-tracker/task.rb
topprospect-pivotal-tracker-0.1.1 lib/pivotal-tracker/task.rb
topprospect-pivotal-tracker-0.0.1 lib/pivotal-tracker/task.rb
pivotal-tracker-0.3.1 lib/pivotal-tracker/task.rb