Class: JIRA::Resource::Sprint

Inherits:
Base
  • Object
show all
Defined in:
lib/jira/resource/sprint.rb

Constant Summary

Constants inherited from Base

Base::QUERY_PARAMS_FOR_SEARCH, Base::QUERY_PARAMS_FOR_SINGLE_FETCH

Instance Attribute Summary

Attributes inherited from Base

#attrs, #client, #deleted, #expanded

Instance Method Summary collapse

Methods inherited from Base

all, belongs_to, belongs_to_relationships, build, collection_attributes_are_nested, #collection_path, collection_path, #delete, endpoint_name, #fetch, find, #has_errors?, has_many, has_one, #id, #initialize, key_attribute, #key_value, #method_missing, nested_collections, #new_record?, parse_json, #path_component, populate, #respond_to?, #save, #save!, #set_attrs, #set_attrs_from_response, singular_path, #to_json, #to_s, #to_sym, #url

Constructor Details

This class inherits a constructor from JIRA::Base

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class JIRA::Base

Instance Method Details

#agileboard_idObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/jira/resource/sprint.rb', line 54

def agileboard_id
  if @attrs['agile_board_id']
    return @attrs['agile_board_id']
  end

  search_url = client.options[:site] + "/secure/GHGoToBoard.jspa?sprintId=" + id.to_s

  begin
    response = client.get(search_url)
  rescue JIRA::HTTPError => error
    unless error.response.instance_of? Net::HTTPFound
      return
    end

    rapid_view_match = /rapidView=(\d+)&/.match(error.response['location'])
    if rapid_view_match != nil
      @attrs['agileboard_id'] = rapid_view_match[1]
    end
  end
end

#end_dateObject



23
24
25
# File 'lib/jira/resource/sprint.rb', line 23

def end_date
  get_sprint_details_attribute("end_date")
end

#get_sprint_detailsObject



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/jira/resource/sprint.rb', line 37

def get_sprint_details
  search_url = client.options[:site] + "/rest/greenhopper/1.0/rapid/charts/sprintreport?rapidViewId=" + 
               agileboard_id.to_s + "&sprintId=" + id.to_s

  begin
    response = client.get(search_url)
  rescue
    return nil
  end

  json = self.class.parse_json(response.body)

  @start_date = Date.parse(json['sprint']['startDate'])
  @end_date = Date.parse(json['sprint']['endDate'])
  @sprint_report = client.SprintReport.build(json['contents'])
end

#get_sprint_details_attribute(attribute_name) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/jira/resource/sprint.rb', line 27

def get_sprint_details_attribute(attribute_name)
  attribute = self.instance_variable_get("@#{attribute_name}")
  if attribute
    return attribute
  end

  get_sprint_details
  self.instance_variable_get("@#{attribute_name}")
end

#issuesObject

get all issues of sprint



10
11
12
13
# File 'lib/jira/resource/sprint.rb', line 10

def issues
  jql = "sprint = " + id
  Issue.jql(client, jql)
end

#sprint_reportObject



15
16
17
# File 'lib/jira/resource/sprint.rb', line 15

def sprint_report
  get_sprint_details_attribute('sprint_report')
end

#start_dateObject



19
20
21
# File 'lib/jira/resource/sprint.rb', line 19

def start_date
  get_sprint_details_attribute("start_date")
end