Class: Assembly::ContentMetadata::FileSetBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/assembly-objectfile/content_metadata/file_set_builder.rb

Overview

Builds a groups of related Files, based on bundle

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bundle:, objects:, style:) ⇒ FileSetBuilder

Returns a new instance of FileSetBuilder.



11
12
13
14
15
# File 'lib/assembly-objectfile/content_metadata/file_set_builder.rb', line 11

def initialize(bundle:, objects:, style:)
  @bundle = bundle
  @objects = objects
  @style = style
end

Class Method Details

.build(bundle:, objects:, style:) ⇒ Object



7
8
9
# File 'lib/assembly-objectfile/content_metadata/file_set_builder.rb', line 7

def self.build(bundle:, objects:, style:)
  new(bundle: bundle, objects: objects, style: style).build
end

Instance Method Details

#buildArray<FileSet>

Returns a list of filesets in the object.

Returns:

  • (Array<FileSet>)

    a list of filesets in the object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/assembly-objectfile/content_metadata/file_set_builder.rb', line 18

def build
  case bundle
  when :default # one resource per object
    objects.collect { |obj| FileSet.new(resource_files: [obj], style: style) }
  when :filename # one resource per distinct filename (excluding extension)
    build_for_filename
  when :dpg # group by DPG filename
    build_for_dpg
  when :prebundled
    # if the user specifies this method, they will pass in an array of arrays, indicating resources, so we don't need to bundle in the gem
    objects.map { |inner| FileSet.new(resource_files: inner, style: style) }
  else
    raise 'Invalid bundle method'
  end
end