Class: Badge::IconCatalog
- Inherits:
-
Object
- Object
- Badge::IconCatalog
- Defined in:
- lib/badge/icon_catalog.rb
Constant Summary collapse
- FORMAT_LEGACY =
:legacy- FORMAT_SINGLE_SIZE =
:single_size- FORMAT_LAYERED =
:layered
Instance Attribute Summary collapse
-
#format_type ⇒ Object
readonly
Returns the value of attribute format_type.
-
#icon_files ⇒ Object
readonly
Returns the value of attribute icon_files.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
-
#badgeable_icons ⇒ Object
Returns list of icon file paths that should be badged.
-
#initialize(appiconset_path) ⇒ IconCatalog
constructor
A new instance of IconCatalog.
Constructor Details
#initialize(appiconset_path) ⇒ IconCatalog
Returns a new instance of IconCatalog.
12 13 14 15 16 17 18 19 |
# File 'lib/badge/icon_catalog.rb', line 12 def initialize(appiconset_path) @path = Pathname.new(appiconset_path) @contents_json_path = @path.join('Contents.json') @icon_files = [] @format_type = nil detect_format end |
Instance Attribute Details
#format_type ⇒ Object (readonly)
Returns the value of attribute format_type.
6 7 8 |
# File 'lib/badge/icon_catalog.rb', line 6 def format_type @format_type end |
#icon_files ⇒ Object (readonly)
Returns the value of attribute icon_files.
6 7 8 |
# File 'lib/badge/icon_catalog.rb', line 6 def icon_files @icon_files end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
6 7 8 |
# File 'lib/badge/icon_catalog.rb', line 6 def path @path end |
Class Method Details
.find_catalogs(search_path, glob_pattern = nil) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/badge/icon_catalog.rb', line 39 def self.find_catalogs(search_path, glob_pattern = nil) if glob_pattern # Use custom glob if provided (backward compatibility) UI.verbose "Using custom glob pattern: #{glob_pattern}".blue return glob_pattern end # Find all .appiconset directories appiconset_dirs = Dir.glob("#{search_path}/**/*.appiconset") catalogs = appiconset_dirs.map { |dir| new(dir) } UI.verbose "Found #{catalogs.count} app icon catalog(s)".blue catalogs.each do |catalog| UI.verbose " - #{catalog.path.basename} (#{catalog.format_type})".blue end catalogs end |
Instance Method Details
#badgeable_icons ⇒ Object
Returns list of icon file paths that should be badged
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/badge/icon_catalog.rb', line 22 def badgeable_icons case @format_type when FORMAT_LAYERED # For layered icons, badge all variants (all.png, dark.png, tint.png) @icon_files when FORMAT_SINGLE_SIZE # Single size format - badge the single icon @icon_files when FORMAT_LEGACY # Legacy format - badge all size variants @icon_files else # Fallback to glob if format detection failed glob_fallback end end |