Class: XCRes::ResourcesAnalyzer::BundleResourcesAnalyzer

Inherits:
BaseResourcesAnalyzer show all
Defined in:
lib/xcres/analyzer/resources_analyzer/bundle_resources_analyzer.rb

Overview

A BundleResourcesAnalyzer scans the project for bundles, whose resources should be included in the output file.

Constant Summary

Constants inherited from BaseResourcesAnalyzer

XCRes::ResourcesAnalyzer::BaseResourcesAnalyzer::FILTER_WORDS

Instance Attribute Summary

Attributes inherited from Analyzer

#exclude_file_patterns, #logger, #options, #sections, #target

Instance Method Summary collapse

Methods inherited from BaseResourcesAnalyzer

#build_images_section_data, #build_section_data, #filter_device_specific_image_paths, #find_files_in_dir, #find_image_files, #key_from_path

Methods inherited from Analyzer

#filter_exclusions, #find_file_refs_by_extname, #initialize, #is_file_ref_included_in_application_target?, #new_section, #project, #resources_files

Methods included from FileHelper

#basename_without_ext

Constructor Details

This class inherits a constructor from XCRes::Analyzer

Instance Method Details

#analyzeObject



11
12
13
14
# File 'lib/xcres/analyzer/resources_analyzer/bundle_resources_analyzer.rb', line 11

def analyze
  @sections = build_sections_for_bundles
  super
end

#build_section_for_bundle(bundle_file_ref) ⇒ Section

Build a section for a resources bundle

Parameters:

  • bundle_file_ref (PBXFileReference)

    the file reference to the resources bundle file

Returns:



49
50
51
52
53
54
55
56
57
58
# File 'lib/xcres/analyzer/resources_analyzer/bundle_resources_analyzer.rb', line 49

def build_section_for_bundle bundle_file_ref
  bundle_files = find_files_in_dir(bundle_file_ref.real_path)
  image_files = find_image_files(bundle_files)

  log "Found bundle %s with #%s image files of #%s total files.", bundle_file_ref.path, image_files.count, bundle_files.count

  section_name = basename_without_ext(bundle_file_ref.path)
  section_data = build_images_section_data(image_files)
  new_section(section_name, section_data)
end

#build_sections_for_bundlesArray<Section>

Build a section for each bundle if it contains any resources

Returns:

  • (Array<Section>)

    the built sections



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/xcres/analyzer/resources_analyzer/bundle_resources_analyzer.rb', line 21

def build_sections_for_bundles
  bundle_file_refs = find_bundle_file_refs

  log "Found #%s resource bundles in project.", bundle_file_refs.count

  bundle_file_refs.map do |file_ref|
    section = build_section_for_bundle(file_ref)
    log 'Add section for %s with %s elements', section.name, section.items.count unless section.nil?
    section
  end.compact
end

#find_bundle_file_refsArray<PBXFileReference>

Discover all references to resources bundles in project

Returns:

  • (Array<PBXFileReference>)


37
38
39
# File 'lib/xcres/analyzer/resources_analyzer/bundle_resources_analyzer.rb', line 37

def find_bundle_file_refs
  find_file_refs_by_extname '.bundle'
end