Class: ConfluencePage

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

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ ConfluencePage

Returns a new instance of ConfluencePage.



5
6
7
# File 'lib/confluence_page.rb', line 5

def initialize(response)
  @doc = Nokogiri(response)
end

Instance Method Details

#contentObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/confluence_page.rb', line 13

def content
  content = CGI.unescapeHTML @doc.css('#markupTextarea').text
  
  content.gsub!(' ', ' ')
  
  # remove the double pipes used for table headers in Confluence
  content.gsub!('||', '|')

  # remove other noise
  content.gsub!("\r\n", "\n")
  content.gsub!("\\\\\n", '')
  content.gsub!('\\', '')

  # remove any unwanted headers
  content.gsub!(/h\d\. (Scenario: .*)/, '\1')
  content.gsub!(/h\d\. (Scenario Outline: .*)/, '\1')
  content.gsub!(/h\d\. (Background: .*)/, '\1')
  
  #Remove fancy quotes
  content.gsub!('', "'")
  content.gsub!('', "'")
  content.gsub!('', '"')
  content.gsub!('', '"')
  
  content.gsub!(/^#(.*)/, '-' + '\1')    
  content
end

#titleObject



9
10
11
# File 'lib/confluence_page.rb', line 9

def title
  @doc.at('#content-title')[:value]
end