Class: Bookwatch::Subnav::NavigationEntriesFromMarkdownRoot

Inherits:
Object
  • Object
show all
Defined in:
lib/bookwatch/subnav/navigation_entries_from_markdown_root.rb

Constant Summary collapse

Class.new(RuntimeError)
Class.new(RuntimeError)
Class.new(RuntimeError)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(fs, require_valid_subnav_links) ⇒ NavigationEntriesFromMarkdownRoot

Returns a new instance of NavigationEntriesFromMarkdownRoot.



12
13
14
15
16
# File 'lib/bookwatch/subnav/navigation_entries_from_markdown_root.rb', line 12

def initialize(fs, require_valid_subnav_links)
  @fs = fs
  @require_valid_subnav_links = require_valid_subnav_links
  @renderer = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new)
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



37
38
39
# File 'lib/bookwatch/subnav/navigation_entries_from_markdown_root.rb', line 37

def config
  @config
end

#fsObject (readonly)

Returns the value of attribute fs.



37
38
39
# File 'lib/bookwatch/subnav/navigation_entries_from_markdown_root.rb', line 37

def fs
  @fs
end

#rendererObject (readonly)

Returns the value of attribute renderer.



37
38
39
# File 'lib/bookwatch/subnav/navigation_entries_from_markdown_root.rb', line 37

def renderer
  @renderer
end

#source_for_site_genObject (readonly)

Returns the value of attribute source_for_site_gen.



37
38
39
# File 'lib/bookwatch/subnav/navigation_entries_from_markdown_root.rb', line 37

def source_for_site_gen
  @source_for_site_gen
end

Instance Method Details



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/bookwatch/subnav/navigation_entries_from_markdown_root.rb', line 18

def get_links(product_config, output_locations)
  @source_for_site_gen = output_locations.source_for_site_generator
  @config = product_config

  root = absolute_source_from_path(Pathname(config.subnav_root))

  if root.nil?
    if @require_valid_subnav_links
      raise SubnavRootMissingError.new('Subnav root not found at: ' + config.subnav_root)
    else
      return []
    end
  end

  @parsed_files = {Pathname(root) => '(root)'}

  gather_urls_and_texts(root)
end