class Omgcnb::UnreleasedMarkdown

Public Class Methods

new(markdown_text) click to toggle source
# File lib/omgcnb/unreleased_markdown.rb, line 5
def initialize(markdown_text)
  @markdown_text = markdown_text
end

Public Instance Methods

changed_list() click to toggle source
# File lib/omgcnb/unreleased_markdown.rb, line 21
def changed_list
  return [] unless unreleased_ul
  unreleased_ul.xpath("li").map {|li| "- #{li.content}" }
end
html() click to toggle source
# File lib/omgcnb/unreleased_markdown.rb, line 13
def html
  @html ||= Kramdown::Document.new(@markdown_text).to_html
end
needs_release?() click to toggle source
# File lib/omgcnb/unreleased_markdown.rb, line 9
def needs_release?
  unreleased_ul
end
nokogiri() click to toggle source
# File lib/omgcnb/unreleased_markdown.rb, line 17
def nokogiri
  @nokogiri ||= Nokogiri::HTML(html)
end
search_ul() click to toggle source
# File lib/omgcnb/unreleased_markdown.rb, line 31
def search_ul
  # Find h2 header with "unreleased"
  # search to see if the next element is an "h2" (no unreleased changes)
  # or it is "ul" (has unreleased changes)
  node = unreleased_h2&.next_sibling
  while node
    node = node.next_sibling
    case node&.name
    when "h2"
      return nil
    when "ul"
      return node
    end
  end
end
unreleased_h2() click to toggle source
# File lib/omgcnb/unreleased_markdown.rb, line 47
def unreleased_h2
  nokogiri.xpath("//h2[@id='unreleased']").first
end
unreleased_ul() click to toggle source
# File lib/omgcnb/unreleased_markdown.rb, line 26
def unreleased_ul
  return @unreleased_ul if defined?(@unreleased_ul)
  @unreleased_ul = search_ul
end