Document.options()   A
last analyzed

Complexity

Conditions 1

Size

Total Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
dl 0
loc 17
ccs 4
cts 4
cp 1
crap 1
rs 9.55
c 1
b 0
f 0
1 1
require_relative "manifest"
2
3 1
module Resume
4 1
  module PDF
5
    # Module representing the PDF document itself.
6
    #
7
    # @author Paul Fioravanti
8 1
    module Document
9 1
      module_function
10
11
      # Generates the PDF document.
12
      #
13
      # @param resume [Hash]
14
      #   Contains all content to be used in generating the resume.
15
      # @param title [String]
16
      #   The resume title to use in the document's metadata.
17
      # @param filename [String]
18
      #   The name of the filename to be generated.
19 1
      def generate(resume, title, filename)
20 1
        require "prawn"
21 1
        require "prawn/table"
22 1
        Prawn::Document.generate(filename, options(title, resume)) do |pdf|
23 1
          pdf.instance_exec(resume) do |document|
24 1
            Manifest.process(self, document)
25
          end
26
        end
27
      end
28
29 1
      def options(title, resume)
30 1
        options = resume[:options]
31 1
        author = options[:author]
32
        {
33 1
          margin_top: options[:margin_top],
34
          margin_bottom: options[:margin_bottom],
35
          margin_left: options[:margin_left],
36
          margin_right: options[:margin_right],
37
          repeat: options[:repeat],
38
          info: {
39
            Title: title,
40
            Author: author,
41
            Creator: options[:repo_link],
42
            CreationDate: Time.now
43
          }
44
        }
45
      end
46 1
      private_class_method :options
47
    end
48
  end
49
end
50