Class: Bookwatch::Preprocessing::LinkToSiteGenDir

Inherits:
Object
  • Object
show all
Defined in:
lib/bookwatch/preprocessing/link_to_site_gen_dir.rb

Instance Method Summary collapse

Constructor Details

#initialize(filesystem, subnav_generator_factory) ⇒ LinkToSiteGenDir

Returns a new instance of LinkToSiteGenDir.



7
8
9
10
# File 'lib/bookwatch/preprocessing/link_to_site_gen_dir.rb', line 7

def initialize(filesystem, subnav_generator_factory)
  @filesystem = filesystem
  @subnav_generator_factory = subnav_generator_factory
end

Instance Method Details

#applicable_to?(section) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/bookwatch/preprocessing/link_to_site_gen_dir.rb', line 12

def applicable_to?(section)
  filesystem.file_exist?(section.path_to_repo_dir)
end

#preprocess(sections, output_locations, config: nil, options: {}, **_) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/bookwatch/preprocessing/link_to_site_gen_dir.rb', line 16

def preprocess(sections, output_locations, config: nil, options: {}, **_)
  sections.each do |section|
    filesystem.link_creating_intermediate_dirs(
      section.path_to_repo_dir,
      output_locations.source_for_site_generator.join(section.destination_directory)
    )
  end

  generator = subnav_generator(options[:require_valid_subnav_links])
  config.products.each do |product|
    generator.generate(product)
  end
end