Sha256: e32e5a724d7baf557ce30b605a5cb5f926138367884e483a3a1e982dddcd5972

Contents?: true

Size: 1.59 KB

Versions: 5

Compression:

Stored size: 1.59 KB

Contents

module TaskMapper::Provider
  module Pivotal
    # Project class for taskmapper-pivotal
    # 
    # 
    class Project < TaskMapper::Provider::Base::Project
      API = PivotalAPI::Project
      # The finder method
      # 
      # It accepts all the find functionalities defined by taskmapper
      #
      # + find() and find(:all) - Returns all projects on the account
      # + find(<project_id>) - Returns the project based on the id
      # + find(:first, :name => <project_name>) - Returns the first project based on the attribute
      # + find(:name => <project name>) - Returns all projects based on the attribute
      attr_accessor :prefix_options
      alias_method :stories, :tickets
      alias_method :story, :ticket

      # Save this project
      def save
        warn 'Warning: Pivotal does not allow editing of project attributes. This method does nothing.'
        true
      end

      def initialize(*options)
        super(*options)
        self.id = self.id.to_i
      end

      # Delete this project
      def destroy
        result = self.system_data[:client].destroy
        result.is_a?(Net::HTTPOK)
      end

      def ticket!(*options)
        options.first.merge!(:project_id => self.id)
        Ticket.create(options.first)
      end

      # copy from
      def copy(project)
        project.tickets.each do |ticket|
          copy_ticket = self.ticket!(:name => ticket.title, :description => ticket.description)
          ticket.comments.each do |comment|
            copy_ticket.comment!(:text => comment.body)
            sleep 1
          end
        end
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
taskmapper-pivotal-0.9.1 lib/provider/project.rb
taskmapper-pivotal-0.9.0 lib/provider/project.rb
taskmapper-pivotal-0.8.2 lib/provider/project.rb
taskmapper-pivotal-0.8.1 lib/provider/project.rb
taskmapper-pivotal-0.8.0 lib/provider/project.rb