icon-banner 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/icon_banner.rb +6 -1
- data/lib/icon_banner/appiconset.rb +10 -0
- data/lib/icon_banner/ic_launcher.rb +9 -0
- data/lib/icon_banner/process.rb +29 -16
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b283b9c99b5cb468b6896e612534c0558f0ff9a
|
4
|
+
data.tar.gz: 630b469925fa01b7dd4bffd14e459681fe5a5209
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da778a5e555e0f6bbcb2eb2730ba50a6a46496165485e3647676d00e7b0ee5db7e4ba523d1a52149895841a7ff2a86781c2c460e774cf6996f4156c09eda1abb
|
7
|
+
data.tar.gz: 256e2e38d73b7a32fe6ab4a48e5138a91cc778f7130a44b5a8705d1aa5b02a128b934158affa545bc045636178359c206dbe36ebe4caff36bda2ffa270fad608
|
data/lib/icon_banner.rb
CHANGED
@@ -3,7 +3,7 @@ require 'icon_banner/ic_launcher'
|
|
3
3
|
require 'commander'
|
4
4
|
|
5
5
|
module IconBanner
|
6
|
-
VERSION = '0.
|
6
|
+
VERSION = '0.2.0'
|
7
7
|
DESCRIPTION = 'IconBanner adds custom nice-looking banners over your mobile app icons'
|
8
8
|
|
9
9
|
UI = FastlaneCore::UI
|
@@ -76,6 +76,11 @@ module IconBanner
|
|
76
76
|
description: 'Creates a backup of icons before applying banners (only set to `false` if you are under source-control)',
|
77
77
|
is_string: false,
|
78
78
|
default_value: true,
|
79
|
+
optional: true),
|
80
|
+
|
81
|
+
FastlaneCore::ConfigItem.new(key: :platform,
|
82
|
+
description: 'Selects the platform to process (`ios`, `android` or `all`). Auto-inferred by lane if available',
|
83
|
+
default_value: 'all',
|
79
84
|
optional: true)
|
80
85
|
]
|
81
86
|
end
|
@@ -7,6 +7,7 @@ module IconBanner
|
|
7
7
|
class AppIconSet < Process
|
8
8
|
BASE_ICON_PATH = '/**/*.appiconset/*.png'
|
9
9
|
PLATFORM = 'iOS'
|
10
|
+
PLATFORM_CODE = 'ios'
|
10
11
|
|
11
12
|
def generate_banner(path, label, color, font)
|
12
13
|
MiniMagick::Tool::Convert.new do |convert|
|
@@ -36,5 +37,14 @@ module IconBanner
|
|
36
37
|
combine.draw "affine 0.5,-0.5,0.5,0.5,-286,-286 text 0,0 \"#{label}\""
|
37
38
|
end
|
38
39
|
end
|
40
|
+
|
41
|
+
def backup_path(path)
|
42
|
+
ext = File.extname path
|
43
|
+
path.gsub(ext, BACKUP_EXTENSION + ext)
|
44
|
+
end
|
45
|
+
|
46
|
+
def should_ignore_icon(icon)
|
47
|
+
icon[/\/Carthage\//] || icon[/\/Pods\//] || icon[/\/Releases\//]
|
48
|
+
end
|
39
49
|
end
|
40
50
|
end
|
@@ -7,6 +7,7 @@ module IconBanner
|
|
7
7
|
class IcLauncher < Process
|
8
8
|
BASE_ICON_PATH = '/**/ic_launcher*.png'
|
9
9
|
PLATFORM = 'Android (Legacy)'
|
10
|
+
PLATFORM_CODE = 'android'
|
10
11
|
|
11
12
|
def generate_banner(path, label, color, font)
|
12
13
|
size = 1024
|
@@ -72,5 +73,13 @@ module IconBanner
|
|
72
73
|
combine.draw "text #{x_middle - size / 2},#{y_middle - size / 2} \"#{label}\""
|
73
74
|
end
|
74
75
|
end
|
76
|
+
|
77
|
+
def backup_path(path)
|
78
|
+
path.gsub('/src/', "/src#{BACKUP_EXTENSION}/")
|
79
|
+
end
|
80
|
+
|
81
|
+
def should_ignore_icon(icon)
|
82
|
+
icon[/\/build\//] || icon[/\/generated\//] || icon[/#{BACKUP_EXTENSION}/]
|
83
|
+
end
|
75
84
|
end
|
76
85
|
end
|
data/lib/icon_banner/process.rb
CHANGED
@@ -5,11 +5,15 @@ module IconBanner
|
|
5
5
|
class Process
|
6
6
|
BASE_ICON_PATH = '__TO OVERRIDE__'
|
7
7
|
PLATFORM = '__TO OVERRIDE__'
|
8
|
+
PLATFORM_CODE = '__TO OVERRIDE__'
|
8
9
|
|
9
10
|
BACKUP_EXTENSION = '.bak'
|
10
11
|
|
11
12
|
def generate(path, options)
|
12
13
|
IconBanner.validate_libs!
|
14
|
+
return unless validate_platform(options)
|
15
|
+
|
16
|
+
UI.message "Generating #{self.class::PLATFORM} banners..."
|
13
17
|
|
14
18
|
restore(path) # restore in case it was already run before
|
15
19
|
|
@@ -19,8 +23,6 @@ module IconBanner
|
|
19
23
|
font = options[:font] || IconBanner.font_path
|
20
24
|
|
21
25
|
if app_icons.count > 0
|
22
|
-
UI.message "Generating #{self.class::PLATFORM} banners..."
|
23
|
-
|
24
26
|
app_icons.each do |icon_path|
|
25
27
|
UI.verbose "Processing #{icon_path}"
|
26
28
|
create_backup icon_path if options[:backup]
|
@@ -42,29 +44,30 @@ module IconBanner
|
|
42
44
|
|
43
45
|
UI.message "Completed #{self.class::PLATFORM} generation."
|
44
46
|
else
|
45
|
-
UI.
|
46
|
-
UI.message self.class::BASE_ICON_PATH
|
47
|
+
UI.message "No #{self.class::PLATFORM} icons found."
|
47
48
|
end
|
48
49
|
end
|
49
50
|
|
50
51
|
def restore(path)
|
52
|
+
return unless validate_platform({})
|
53
|
+
|
54
|
+
UI.message "Restoring #{self.class::PLATFORM} icons..."
|
55
|
+
|
51
56
|
app_icons = get_app_icons(path)
|
52
57
|
|
53
58
|
if app_icons.count > 0
|
54
|
-
UI.message "Restoring #{self.class::PLATFORM} icons..."
|
55
|
-
|
56
59
|
app_icons.each do |icon_path|
|
57
60
|
UI.verbose "Restoring #{icon_path}"
|
58
61
|
restore_backup icon_path
|
59
62
|
end
|
60
|
-
|
61
|
-
UI.message "Completed #{self.class::PLATFORM} restore."
|
62
63
|
end
|
64
|
+
|
65
|
+
UI.message "Completed #{self.class::PLATFORM} restore."
|
63
66
|
end
|
64
67
|
|
65
68
|
def get_app_icons(path)
|
66
69
|
app_icons = Dir.glob("#{path}#{self.class::BASE_ICON_PATH}")
|
67
|
-
app_icons.reject { |
|
70
|
+
app_icons.reject { |icon| should_ignore_icon(icon) }
|
68
71
|
end
|
69
72
|
|
70
73
|
def find_base_color(path)
|
@@ -81,10 +84,6 @@ module IconBanner
|
|
81
84
|
color[/rgba?\([^)]*\)/]
|
82
85
|
end
|
83
86
|
|
84
|
-
def generate_banner(path, label, color, font)
|
85
|
-
UI.error 'Should not be run on base class'
|
86
|
-
end
|
87
|
-
|
88
87
|
def process_icon(icon_path, banner_path)
|
89
88
|
icon = MiniMagick::Image.open(icon_path)
|
90
89
|
banner = MiniMagick::Image.open(banner_path)
|
@@ -93,7 +92,9 @@ module IconBanner
|
|
93
92
|
end
|
94
93
|
|
95
94
|
def create_backup(icon_path)
|
96
|
-
|
95
|
+
backup_path = backup_path(icon_path)
|
96
|
+
FileUtils.mkdir_p(File.dirname(backup_path))
|
97
|
+
FileUtils.cp(icon_path, backup_path)
|
97
98
|
end
|
98
99
|
|
99
100
|
def restore_backup(icon_path)
|
@@ -104,9 +105,21 @@ module IconBanner
|
|
104
105
|
end
|
105
106
|
end
|
106
107
|
|
108
|
+
def validate_platform(options)
|
109
|
+
platform = ENV['FASTLANE_PLATFORM_NAME'] || options[:platform]
|
110
|
+
platform.nil? || platform[/#{self.class::PLATFORM_CODE}/i] || platform == 'all'
|
111
|
+
end
|
112
|
+
|
113
|
+
def generate_banner(path, label, color, font)
|
114
|
+
UI.error '`generate_banner` should not be run on base class'
|
115
|
+
end
|
116
|
+
|
107
117
|
def backup_path(path)
|
108
|
-
|
109
|
-
|
118
|
+
UI.error '`backup_path` should not be run on base class'
|
119
|
+
end
|
120
|
+
|
121
|
+
def should_ignore_icon(icon)
|
122
|
+
UI.error '`should_ignore_icon` should not be run on base class'
|
110
123
|
end
|
111
124
|
end
|
112
125
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: icon-banner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Émile Bélair
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-11-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fastlane
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 4.9.4
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 4.9.4
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|