Class: Torque::PivotalHTMLParser

Inherits:
Object
  • Object
show all
Defined in:
lib/torque/pivotal_html_parser.rb

Instance Method Summary collapse

Constructor Details

#initializePivotalHTMLParser

Returns a new instance of PivotalHTMLParser.



13
14
15
16
# File 'lib/torque/pivotal_html_parser.rb', line 13

def initialize
  @date_filter = false
  @field_filters = false
end

Instance Method Details

#add_date_filter(accept_from, accept_to) ⇒ Object

Adds a date filter to stories, excluding them if they lie outside the provided dates

Parameters:

  • accept_from

    A Date marking the lower bound for the date_accepted field of a story (inclusive)

  • accept_to

    A Date marking the upper bound for the date_accepted field of a story (inclusive)



23
24
25
26
27
# File 'lib/torque/pivotal_html_parser.rb', line 23

def add_date_filter(accept_from, accept_to)
  @date_filter = true
  @accept_from = accept_from
  @accept_to = accept_to
end

#add_field_filters(field_filter_list) ⇒ Object

Adds field filters to stories, excluding them if they do not pass all filters in field_filter_list

Parameters:

  • field_filter_list

    A list of FieldFilter objects to use



33
34
35
36
# File 'lib/torque/pivotal_html_parser.rb', line 33

def add_field_filters(field_filter_list)
  @field_filters = true
  @field_filter_list = field_filter_list
end

#process_project(project_html_string) ⇒ Object

Applies during processing any filters that have been added

Parameters:

  • project_html_string

    An html string containing the story data for a Pivotal Tracker project

Returns:

  • A list of all Story objects parsed from project_html_string (least recent to most recent date accepted)



44
45
46
47
48
# File 'lib/torque/pivotal_html_parser.rb', line 44

def process_project(project_html_string)

  project_element = Nokogiri::HTML(project_html_string)
  process_stories_element(project_element)
end

#process_project_iterations(project_html_string) ⇒ Object

Returns A list of Iteration objects parsed from project_html_string (least recent to most recent iteration).

Parameters:

  • project_html_string

    An html string containing iteration data for a Pivotal Tracker project

Returns:

  • A list of Iteration objects parsed from project_html_string (least recent to most recent iteration)



55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/torque/pivotal_html_parser.rb', line 55

def process_project_iterations(project_html_string)

  project_html = Nokogiri::HTML(project_html_string)
  iteration_html_array = project_html.search('iteration')
  iteration_list = []

  iteration_html_array.each do
    |iteration_element|
    iteration_list << process_iteration_element(iteration_element)
  end

  iteration_list
end