Class: BreezyPDF::HTML::Publicize

Inherits:
Object
  • Object
show all
Defined in:
lib/breezy_pdf/html/publicize.rb

Overview

Replace assets with uploaded URL’s

Instance Method Summary collapse

Constructor Details

#initialize(base_url, html_fragment) ⇒ Publicize

Returns a new instance of Publicize.



6
7
8
9
10
11
12
# File 'lib/breezy_pdf/html/publicize.rb', line 6

def initialize(base_url, html_fragment)
  @base_url      = base_url
  @html_fragment = html_fragment
  @log_queue     = []
  @upload_ids    = []
  @start_time = Process.clock_gettime(Process::CLOCK_MONOTONIC)
end

Instance Method Details

#public_fragmentObject



14
15
16
17
18
19
# File 'lib/breezy_pdf/html/publicize.rb', line 14

def public_fragment
  @public_fragment ||= parsed_document.tap do
    publicize!
    BreezyPDF.logger.info("[BreezyPDF] Replaced assets in #{timing} seconds")
  end.to_html
end

#timingObject



27
28
29
# File 'lib/breezy_pdf/html/publicize.rb', line 27

def timing
  @timing ||= Process.clock_gettime(Process::CLOCK_MONOTONIC) - @start_time
end

#upload_idsObject



21
22
23
24
25
# File 'lib/breezy_pdf/html/publicize.rb', line 21

def upload_ids
  public_fragment

  @upload_ids
end