Class: Bookwatch::Ingest::SectionRepository

Inherits:
Object
  • Object
show all
Defined in:
lib/bookwatch/ingest/section_repository.rb

Instance Method Summary collapse

Instance Method Details

#fetch(configured_sections: [], destination_dir: nil, ref_override: nil, cloner: nil, streams: nil) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/bookwatch/ingest/section_repository.rb', line 7

def fetch(configured_sections: [],
          destination_dir: nil,
          ref_override: nil,
          cloner: nil,
          streams: nil)
  configured_sections.map do |section_config|
    streams[:success].puts("Gathering #{section_config.repo_name}")

    working_copy = cloner.call(source_repo_name: section_config.repo_name,
                               source_ref: ref_override || section_config.repo_ref,
                               destination_parent_dir: destination_dir,
                               destination_dir_name: section_config.desired_directory_name)

    if section_config.dependent_sections.any?
      section_config.dependent_sections.map do |dependent_config|
        unless dependent_config.no_docs?
          streams[:success].puts("Gathering #{dependent_config.repo_name}")
          cloner.call(source_repo_name: dependent_config.repo_name,
                      source_ref: ref_override || dependent_config.repo_ref,
                      destination_parent_dir: "#{destination_dir}/#{section_config.desired_directory_name}",
                      destination_dir_name: dependent_config.desired_directory_name)
        end
      end
    end

    Section.new(
      working_copy.path,
      working_copy.full_name,
      section_config.desired_directory_name,
      section_config.subnav_template,
      section_config.subnav_name,
      section_config.preprocessor_config,
      section_config.at_repo_path,
      section_config.repo_name,
      working_copy.ref,
      section_config.pdf_output_filename,
      section_config.product_info
    )
  end
end