Sha256: 30f15be555235b14a5eca669ba28580945118e4220aca1ee46cc1a294bef0f96

Contents?: true

Size: 862 Bytes

Versions: 1

Compression:

Stored size: 862 Bytes

Contents

#
#   Wrapper for a Pivotal Tracker story
#

module PGit
  class Story
    class << self
      def get(id, current_project)
        @id = id
        @project_id = current_project.id
        @api_token = current_project.api_token

        define_methods(get!)

        new
      end

      def define_methods(json)
        JSON.parse(json).each do |key, value|
          define_method key do
            value
          end
        end
      end

      def api_version
        "v5"
      end

      def get!
        validator = PGit::PivotalRequestValidator.new `#{get_request}`
        validator.request
      end

      def link
        "'https://www.pivotaltracker.com/services/#{api_version}/projects/#{@project_id}/stories/#{@id}'"
      end

      def get_request
        "curl -X GET -H 'X-TrackerToken: #{@api_token}' #{link}"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pgit-0.0.4 lib/pgit/story.rb