Class: PGit::Story

Inherits:
Object
  • Object
show all
Defined in:
lib/pgit/story.rb

Class Method Summary collapse

Class Method Details

.api_versionObject



26
27
28
# File 'lib/pgit/story.rb', line 26

def api_version
  "v5"
end

.define_methods(json) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/pgit/story.rb', line 18

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

.get(id, current_project) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/pgit/story.rb', line 8

def get(id, current_project)
  @id = id
  @project_id = current_project.id
  @api_token = current_project.api_token

  define_methods(get!)

  new
end

.get!Object



30
31
32
33
34
35
36
37
# File 'lib/pgit/story.rb', line 30

def get!
  request = `#{get_request}`
  if request.match(/error/)
    raise request
  else
    request
  end
end

.get_requestObject



43
44
45
# File 'lib/pgit/story.rb', line 43

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


39
40
41
# File 'lib/pgit/story.rb', line 39

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