Class: XCRes::ResourcesAnalyzer::BundleResourcesAnalyzer
- Inherits:
-
BaseResourcesAnalyzer
- Object
- Analyzer
- BaseResourcesAnalyzer
- XCRes::ResourcesAnalyzer::BundleResourcesAnalyzer
- 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
- #analyze ⇒ Object
-
#build_section_for_bundle(bundle_file_ref) ⇒ Section
Build a section for a resources bundle.
-
#build_sections_for_bundles ⇒ Array<Section>
Build a section for each bundle if it contains any resources.
-
#find_bundle_file_refs ⇒ Array<PBXFileReference>
Discover all references to resources bundles in project.
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
Constructor Details
This class inherits a constructor from XCRes::Analyzer
Instance Method Details
#analyze ⇒ Object
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
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_bundles ⇒ Array<Section>
Build a section for each bundle if it contains any resources
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_refs ⇒ Array<PBXFileReference>
Discover all references to resources bundles in project
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 |