Class: FeaturesReport::Generator

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

Defined Under Namespace

Classes: Feature

Constant Summary collapse

FEATURE_TITLE_STYLE =
{:size => 24}
SCENARIO_TITLE_STYLE =
{:size => 16}
STEP_STYLE =
{}
{:size => 12}
DOC_TITLE_STYLE =
{:size => 32, :align => :center}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(reader, git, opts) ⇒ Generator

Returns a new instance of Generator.



4
5
6
7
8
9
10
# File 'lib/features_report/generator.rb', line 4

def initialize(reader, git, opts)
  @reader = reader
  @opts = opts
  @git = git
  @feature_pages ||= {}
  @features = reader.features.map{|f| Feature.new(f, @git)}
end

Instance Attribute Details

#optsObject (readonly)

Returns the value of attribute opts.



12
13
14
# File 'lib/features_report/generator.rb', line 12

def opts
  @opts
end

#pdfObject (readonly)

Returns the value of attribute pdf.



12
13
14
# File 'lib/features_report/generator.rb', line 12

def pdf
  @pdf
end

#readerObject (readonly)

Returns the value of attribute reader.



12
13
14
# File 'lib/features_report/generator.rb', line 12

def reader
  @reader
end

Instance Method Details

#generateObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/features_report/generator.rb', line 14

def generate
  @pdf = Prawn::Document.new :page_size => "A4", :top_margin => 60

  pdf.header [pdf.bounds.right, pdf.bounds.bottom + 10] do
    pdf.text pdf.page_count-1 unless pdf.page_count == 1
  end

  @original_bottom_left = [pdf.bounds.left, pdf.bounds.bottom - 10]

  generate_front_page
  
  sorted_features.each do |feature| 
    generate_feature(feature)
  end
  
  generate_contents_page
  pdf.render_file("features.pdf")
end