yamg 0.3.8 → 0.5.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/.gitignore +2 -1
- data/Gemfile +2 -2
- data/Guardfile +8 -13
- data/README.md +59 -4
- data/lib/yamg.rb +1 -2
- data/lib/yamg/assets/browserconfig.xml +12 -0
- data/lib/yamg/assets/manifest.json +41 -0
- data/lib/yamg/cli.rb +17 -5
- data/lib/yamg/icon.rb +43 -7
- data/lib/yamg/templates.yaml +32 -15
- data/lib/yamg/version.rb +1 -1
- data/lib/yamg/yamg.yml +4 -6
- data/spec/icons/icon16.png +0 -0
- data/spec/icons/icon32.png +0 -0
- data/spec/icons/icon512.svg +153 -0
- data/spec/yamg/icon_spec.rb +105 -0
- data/spec/yamg/yamg_spec.rb +1 -13
- metadata +13 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6743270b3eaa2c9f6478a9ffa7381bdccca5e14
|
4
|
+
data.tar.gz: 9c27945f52c829257bc94bbd9e99a61f0accdc29
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0cd6a739d428e7df15103b25bcca73a82bb26dfb1a5488f19ba38ff931d8997d8f386bc85f6d649e940fc5d925618cb5daf010cd237eb0115629bbcc0cab6dfa
|
7
|
+
data.tar.gz: ad674a6bc6c39cad82150234b4555a3aee31d97f1a9d792c287a86be23f634ca01527b49cfefd02b55998522b65ef5a91cf289fe5f15397a79a42c4c7027b0df
|
data/.gitignore
CHANGED
data/Gemfile
CHANGED
data/Guardfile
CHANGED
@@ -7,20 +7,15 @@
|
|
7
7
|
## Uncomment to clear the screen before every task
|
8
8
|
# clearing :on
|
9
9
|
|
10
|
-
guard :minitest do
|
11
|
-
# with Minitest::Unit
|
12
|
-
# watch(%r{^test/(.*)\/?test_(.*)\.rb$})
|
13
|
-
# watch(%r{^lib/(.*/)?([^/]+)\.rb$}) { |m| "test/#{m[1]}test_#{m[2]}.rb" }
|
14
|
-
# watch(%r{^test/test_helper\.rb$}) { 'test' }
|
15
|
-
|
16
|
-
# with Minitest::Spec
|
17
|
-
watch(%r{^spec/(.*)_spec\.rb$})
|
18
|
-
watch(%r{^lib/(.+)\.rb$}) { 'spec' }
|
19
|
-
# watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
20
|
-
watch(%r{^spec/spec_helper\.rb$}) { 'spec' }
|
21
|
-
end
|
22
|
-
|
23
10
|
guard :rubocop do
|
24
11
|
watch(/.+\.rb$/)
|
25
12
|
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
26
13
|
end
|
14
|
+
|
15
|
+
guard :rspec, cmd: 'bundle exec rspec' do
|
16
|
+
watch(%r{^spec/.+_spec\.rb$})
|
17
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
18
|
+
watch(%r{^generators/(.+)\.rb$/}) { |_m| 'spec/schemaless/worker_spec' }
|
19
|
+
|
20
|
+
watch('spec/spec_helper.rb') { 'spec' }
|
21
|
+
end
|
data/README.md
CHANGED
@@ -107,6 +107,12 @@ You may still use best size match: Just have you folder:
|
|
107
107
|
'16-icon.svg', '256-icon.svg', and problably not many other sizes:
|
108
108
|
The SVG will be rasterized in the correct size needed.
|
109
109
|
|
110
|
+
### ICO
|
111
|
+
|
112
|
+
YAMG will automatically find the best version and combine:
|
113
|
+
16px, 32px and 48px into a .ico for the web.
|
114
|
+
Also check out #HTML to meta tags for all this.
|
115
|
+
|
110
116
|
|
111
117
|
## Splash
|
112
118
|
|
@@ -192,15 +198,64 @@ compile:
|
|
192
198
|
* Play Store
|
193
199
|
* Facebook
|
194
200
|
* Twitter
|
195
|
-
*
|
196
|
-
* Web
|
201
|
+
* Web (Any framework: rails, sinatra, js...)
|
197
202
|
* Write your own (really easy, fork and change yml)
|
198
203
|
|
199
|
-
## Notes
|
200
204
|
|
201
|
-
|
205
|
+
## HTML
|
206
|
+
|
207
|
+
Meta tags in HTML:
|
208
|
+
|
209
|
+
```html
|
210
|
+
<link rel="apple-touch-icon" sizes="57x57" href="/apple-touch-icon-57x57.png">
|
211
|
+
<link rel="apple-touch-icon" sizes="60x60" href="/apple-touch-icon-60x60.png">
|
212
|
+
<link rel="apple-touch-icon" sizes="72x72" href="/apple-touch-icon-72x72.png">
|
213
|
+
<link rel="apple-touch-icon" sizes="76x76" href="/apple-touch-icon-76x76.png">
|
214
|
+
<link rel="apple-touch-icon" sizes="114x114" href="/apple-touch-icon-114x114.png">
|
215
|
+
<link rel="apple-touch-icon" sizes="120x120" href="/apple-touch-icon-120x120.png">
|
216
|
+
<link rel="apple-touch-icon" sizes="144x144" href="/apple-touch-icon-144x144.png">
|
217
|
+
<link rel="apple-touch-icon" sizes="152x152" href="/apple-touch-icon-152x152.png">
|
218
|
+
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon-180x180.png">
|
219
|
+
<link rel="icon" type="image/png" href="/favicon-32x32.png" sizes="32x32">
|
220
|
+
<link rel="icon" type="image/png" href="/android-chrome-192x192.png" sizes="192x192">
|
221
|
+
<link rel="icon" type="image/png" href="/favicon-96x96.png" sizes="96x96">
|
222
|
+
<link rel="icon" type="image/png" href="/favicon-16x16.png" sizes="16x16">
|
223
|
+
<link rel="manifest" href="/manifest.json">
|
224
|
+
<meta name="msapplication-TileColor" content="#da532c">
|
225
|
+
<meta name="msapplication-TileImage" content="/mstile-144x144.png">
|
226
|
+
<meta name="theme-color" content="#ffffff">
|
227
|
+
```
|
228
|
+
|
229
|
+
Meta tags in HAML:
|
230
|
+
|
231
|
+
```haml
|
232
|
+
%link{:href => "/apple-touch-icon-57x57.png", :rel => "apple-touch-icon", :sizes => "57x57"}/
|
233
|
+
%link{:href => "/apple-touch-icon-60x60.png", :rel => "apple-touch-icon", :sizes => "60x60"}/
|
234
|
+
%link{:href => "/apple-touch-icon-72x72.png", :rel => "apple-touch-icon", :sizes => "72x72"}/
|
235
|
+
%link{:href => "/apple-touch-icon-76x76.png", :rel => "apple-touch-icon", :sizes => "76x76"}/
|
236
|
+
%link{:href => "/apple-touch-icon-114x114.png", :rel => "apple-touch-icon", :sizes => "114x114"}/
|
237
|
+
%link{:href => "/apple-touch-icon-120x120.png", :rel => "apple-touch-icon", :sizes => "120x120"}/
|
238
|
+
%link{:href => "/apple-touch-icon-144x144.png", :rel => "apple-touch-icon", :sizes => "144x144"}/
|
239
|
+
%link{:href => "/apple-touch-icon-152x152.png", :rel => "apple-touch-icon", :sizes => "152x152"}/
|
240
|
+
%link{:href => "/apple-touch-icon-180x180.png", :rel => "apple-touch-icon", :sizes => "180x180"}/
|
241
|
+
%link{:href => "/favicon-32x32.png", :rel => "icon", :sizes => "32x32", :type => "image/png"}/
|
242
|
+
%link{:href => "/android-chrome-192x192.png", :rel => "icon", :sizes => "192x192", :type => "image/png"}/
|
243
|
+
%link{:href => "/favicon-96x96.png", :rel => "icon", :sizes => "96x96", :type => "image/png"}/
|
244
|
+
%link{:href => "/favicon-16x16.png", :rel => "icon", :sizes => "16x16", :type => "image/png"}/
|
245
|
+
%link{:href => "/manifest.json", :rel => "manifest"}/
|
246
|
+
%meta{:content => "#da532c", :name => "msapplication-TileColor"}/
|
247
|
+
%meta{:content => "/mstile-144x144.png", :name => "msapplication-TileImage"}/
|
248
|
+
%meta{:content => "#ffffff", :name => "theme-color"}/
|
249
|
+
```
|
250
|
+
|
251
|
+
## Notes & Thanks
|
252
|
+
|
253
|
+
RSVG - Impossible without
|
202
254
|
https://github.com/svg/svgo
|
203
255
|
|
256
|
+
Real Favicon Generator - Perfect, but I wanted make it automated.
|
257
|
+
http://realfavicongenerator.net
|
258
|
+
|
204
259
|
|
205
260
|
### Media
|
206
261
|
|
data/lib/yamg.rb
CHANGED
@@ -56,12 +56,11 @@ module YAMG
|
|
56
56
|
run "rsvg-convert #{args} #{src} > #{out}"
|
57
57
|
end
|
58
58
|
|
59
|
-
|
60
59
|
def run_ffmpeg
|
61
60
|
end
|
62
61
|
|
63
62
|
def run_imagemagick(comm)
|
64
|
-
shell = MiniMagick::Shell.new #(whiny)
|
63
|
+
shell = MiniMagick::Shell.new # (whiny)
|
65
64
|
shell.run(comm).strip
|
66
65
|
end
|
67
66
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
2
|
+
<browserconfig>
|
3
|
+
<msapplication>
|
4
|
+
<tile>
|
5
|
+
<square70x70logo src="/mstile-70x70.png"/>
|
6
|
+
<square150x150logo src="/mstile-150x150.png"/>
|
7
|
+
<square310x310logo src="/mstile-310x310.png"/>
|
8
|
+
<wide310x150logo src="/mstile-310x150.png"/>
|
9
|
+
<TileColor>#da532c</TileColor>
|
10
|
+
</tile>
|
11
|
+
</msapplication>
|
12
|
+
</browserconfig>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
{
|
2
|
+
"name": "My app",
|
3
|
+
"icons": [
|
4
|
+
{
|
5
|
+
"src": "\/android-chrome-36x36.png",
|
6
|
+
"sizes": "36x36",
|
7
|
+
"type": "image\/png",
|
8
|
+
"density": "0.75"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"src": "\/android-chrome-48x48.png",
|
12
|
+
"sizes": "48x48",
|
13
|
+
"type": "image\/png",
|
14
|
+
"density": "1.0"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"src": "\/android-chrome-72x72.png",
|
18
|
+
"sizes": "72x72",
|
19
|
+
"type": "image\/png",
|
20
|
+
"density": "1.5"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"src": "\/android-chrome-96x96.png",
|
24
|
+
"sizes": "96x96",
|
25
|
+
"type": "image\/png",
|
26
|
+
"density": "2.0"
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"src": "\/android-chrome-144x144.png",
|
30
|
+
"sizes": "144x144",
|
31
|
+
"type": "image\/png",
|
32
|
+
"density": "3.0"
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"src": "\/android-chrome-192x192.png",
|
36
|
+
"sizes": "192x192",
|
37
|
+
"type": "image\/png",
|
38
|
+
"density": "4.0"
|
39
|
+
}
|
40
|
+
]
|
41
|
+
}
|
data/lib/yamg/cli.rb
CHANGED
@@ -3,7 +3,7 @@ module YAMG
|
|
3
3
|
class CLI
|
4
4
|
attr_accessor :works, :scope
|
5
5
|
|
6
|
-
def initialize(argv)
|
6
|
+
def initialize(argv = {})
|
7
7
|
puts
|
8
8
|
puts Rainbow(' Y A M G').red
|
9
9
|
puts
|
@@ -35,8 +35,8 @@ module YAMG
|
|
35
35
|
|
36
36
|
def compile_screenshots(ss, size, setup)
|
37
37
|
return unless YAMG.config['screenshot'].respond_to?(:[])
|
38
|
-
fail 'No url provided' unless url = YAMG.config['screenshot']['url']
|
39
|
-
Screenshot.new(ss,
|
38
|
+
fail 'No url provided' unless (url = YAMG.config['screenshot']['url'])
|
39
|
+
Screenshot.new(ss, 'size' => size, 'url' => url).work(setup['path'])
|
40
40
|
puts Rainbow("[o]SS #{ss}").black
|
41
41
|
end
|
42
42
|
|
@@ -46,9 +46,11 @@ module YAMG
|
|
46
46
|
def compile_icon(i, size, setup)
|
47
47
|
folder = setup['icon'] || YAMG.config['icon']['path']
|
48
48
|
# Don' use || here, we are after false
|
49
|
+
bg = setup['bg'] || setup['background']
|
49
50
|
round = setup['rounded']
|
50
51
|
round = YAMG.config['icon']['rounded'] if round.nil?
|
51
|
-
|
52
|
+
radius = setup['radius']
|
53
|
+
Icon.new(folder, size, bg, round, radius).image(home_for(i, setup))
|
52
54
|
print Rainbow(round ? '(i)' : '[i]').black
|
53
55
|
YAMG.info("Icon #{size}px -> #{setup['path']}#{i} ", :black)
|
54
56
|
end
|
@@ -61,6 +63,15 @@ module YAMG
|
|
61
63
|
YAMG.info("Splash #{size.join('x')}px #{setup['path']}#{s}", :black)
|
62
64
|
end
|
63
65
|
|
66
|
+
def compile_docs(opts)
|
67
|
+
out = opts['path']
|
68
|
+
%w( manifest.json browserconfig.xml ).each do |doc|
|
69
|
+
puts Rainbow("{DOCS} #{out}/#{doc} created. Please review.").red
|
70
|
+
src = File.expand_path("assets/#{doc}", File.dirname(__FILE__))
|
71
|
+
FileUtils.cp(src, out)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
64
75
|
def compile_work(job, opts)
|
65
76
|
task = YAMG::TEMPLATES[job] || (works[job] && works[job]['export'])
|
66
77
|
%w(icon logo splash media screenshots).each do |subtask|
|
@@ -72,10 +83,11 @@ module YAMG
|
|
72
83
|
end
|
73
84
|
end
|
74
85
|
end
|
86
|
+
compile_docs(opts) if task['docs']
|
75
87
|
end
|
76
88
|
|
77
89
|
def compile
|
78
|
-
works.select! { |k,_v| k =~ /#{scope}/ } if scope
|
90
|
+
works.select! { |k, _v| k =~ /#{scope}/ } if scope
|
79
91
|
puts Rainbow("Tasks: #{works.keys.join(', ')}").yellow
|
80
92
|
works.each { |out, opts| compile_work(out, opts) }
|
81
93
|
end
|
data/lib/yamg/icon.rb
CHANGED
@@ -14,24 +14,27 @@ module YAMG
|
|
14
14
|
# Icon.new(src, size, rounded).image('.path.ext')
|
15
15
|
# Export image
|
16
16
|
#
|
17
|
-
|
18
|
-
|
17
|
+
# ICO: 16/32/48
|
18
|
+
#
|
19
|
+
def initialize(src, size, bg = nil, rounded = false, radius = 9)
|
20
|
+
fail 'No source' if src.nil? || src.empty?
|
19
21
|
@src = src
|
20
22
|
@size = size
|
21
23
|
@rounded = rounded
|
22
24
|
@icons = YAMG.load_images(src)
|
23
25
|
YAMG.puts_and_exit("No sources in '#{src}'") if icons.empty?
|
24
26
|
@choosen = File.join(src, find_closest_gte_icon)
|
25
|
-
@radius = radius
|
27
|
+
@radius = radius || 9
|
26
28
|
@dpi = 90
|
29
|
+
@bg = bg
|
27
30
|
end
|
28
31
|
alias_method :rounded?, :rounded
|
29
32
|
|
30
33
|
def find_closest_gte_icon
|
31
|
-
|
34
|
+
proc = ->(x) { x.tr('^0-9', '').to_i }
|
35
|
+
return icons.max_by(&proc) if icons.map(&proc).max < size
|
32
36
|
icons.min_by do |f|
|
33
|
-
|
34
|
-
n = f.to_i
|
37
|
+
n = proc.call(f)
|
35
38
|
size > n ? Float::INFINITY : n
|
36
39
|
end
|
37
40
|
end
|
@@ -84,19 +87,51 @@ module YAMG
|
|
84
87
|
masked
|
85
88
|
end
|
86
89
|
|
90
|
+
def apply_background
|
91
|
+
clone = ::MiniMagick::Image.open img.path
|
92
|
+
clone.combine_options do |o|
|
93
|
+
o.draw 'color 0,0 reset'
|
94
|
+
o.fill @bg
|
95
|
+
end
|
96
|
+
clone.composite(img) { |i| i.compose 'Over' }
|
97
|
+
end
|
98
|
+
|
99
|
+
# Just copy the svg, never resize
|
100
|
+
def svg!
|
101
|
+
fail unless @icons.find { |i| File.extname(i) == 'svg' }
|
102
|
+
end
|
103
|
+
|
104
|
+
# ICO!
|
105
|
+
def ico!(out)
|
106
|
+
temp = ->(s) { "/tmp/#{s}-#{Thread.current.object_id}.png" }
|
107
|
+
MiniMagick::Tool::Convert.new do |o|
|
108
|
+
o << Icon.new(@src, 16).image(temp.call(16))
|
109
|
+
o << Icon.new(@src, 32).image(temp.call(32))
|
110
|
+
o << Icon.new(@src, 48).image(temp.call(48))
|
111
|
+
o.colors 256
|
112
|
+
o << out
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
87
116
|
def image(out = nil)
|
117
|
+
return svg! if out =~ /svg$/
|
118
|
+
return ico!(out) if out =~ /ico$/
|
88
119
|
temp = out || "/tmp/#{@choosen.object_id}.png"
|
89
120
|
if File.extname(@choosen) =~ /svg/
|
90
121
|
pixels = dpi ? "-d #{dpi} -p #{dpi}" : nil
|
91
122
|
args = "#{pixels} -w #{size} -h #{size} -f png"
|
92
123
|
YAMG.run_rsvg(@choosen, temp, args)
|
93
124
|
@img = MiniMagick::Image.open(temp)
|
125
|
+
@img.format File.extname(out) if out
|
126
|
+
|
94
127
|
else
|
95
128
|
@img = MiniMagick::Image.open(@choosen)
|
129
|
+
@img.format File.extname(out) if out
|
96
130
|
@img.resize size # "NxN"
|
97
131
|
end
|
132
|
+
@img = apply_background if @bg
|
98
133
|
@img = round if rounded?
|
99
|
-
write_out(out)
|
134
|
+
out ? write_out(out) : img
|
100
135
|
end
|
101
136
|
|
102
137
|
#
|
@@ -106,6 +141,7 @@ module YAMG
|
|
106
141
|
return img unless path
|
107
142
|
FileUtils.mkdir_p File.dirname(path)
|
108
143
|
img.write(path)
|
144
|
+
path
|
109
145
|
rescue Errno::ENOENT
|
110
146
|
puts_and_exit("Path not found '#{path}'")
|
111
147
|
end
|
data/lib/yamg/templates.yaml
CHANGED
@@ -175,25 +175,42 @@ phonegap:
|
|
175
175
|
'screen/ios/screen-iDefault-Landscape-736h.png': [2208, 1242]
|
176
176
|
'screen/windows-phone/screen-portrait.jpg': [720, 1280]
|
177
177
|
|
178
|
-
|
179
178
|
web:
|
180
179
|
icon:
|
181
|
-
'
|
180
|
+
'favicon.ico': 48
|
181
|
+
'icon.png': 512
|
182
|
+
'icon-xs.png': 64
|
183
|
+
'icon-sm.png': 128
|
184
|
+
'icon-md.png': 256
|
185
|
+
'favicon-16x16.png': 16
|
186
|
+
'favicon-32x32.png': 32
|
187
|
+
'favicon-96x96.png': 96
|
188
|
+
'android-chrome-36x36.png': 36
|
189
|
+
'android-chrome-48x48.png': 48
|
190
|
+
'android-chrome-72x72.png': 72
|
191
|
+
'android-chrome-96x96.png': 96
|
192
|
+
'android-chrome-144x144.png': 144
|
193
|
+
'android-chrome-192x192.png': 192
|
194
|
+
'apple-touch-icon.png': 180
|
195
|
+
'apple-touch-icon-57x57.png': 57
|
196
|
+
'apple-touch-icon-60x60.png': 60
|
197
|
+
'apple-touch-icon-72x72.png': 72
|
198
|
+
'apple-touch-icon-76x76.png': 76
|
199
|
+
'apple-touch-icon-114x114.png': 114
|
200
|
+
'apple-touch-icon-120x120.png': 120
|
201
|
+
'apple-touch-icon-144x144.png': 144
|
202
|
+
'apple-touch-icon-152x152.png': 152
|
203
|
+
'apple-touch-icon-180x180.png': 180
|
204
|
+
'apple-touch-icon-precomposed.png': 180 # non round?
|
205
|
+
'mstile-70x70.png': 128
|
206
|
+
'mstile-144x144.png': 144
|
207
|
+
'mstile-150x150.png': 270
|
208
|
+
'mstile-310x310.png': 558
|
209
|
+
splash:
|
210
|
+
'mstile-310x150.png': [558, 270]
|
182
211
|
media:
|
183
212
|
'media.png': 256
|
184
|
-
|
185
|
-
|
186
|
-
rails:
|
187
|
-
icon:
|
188
|
-
'public/favicon.png': 16
|
189
|
-
'public/favicon.ico': 16
|
190
|
-
'public/icon.png': 512
|
191
|
-
'app/assets/images/icon.png': 512
|
192
|
-
'app/assets/images/favicon.png': 16
|
193
|
-
media:
|
194
|
-
'app/assets/images/logo.png': 512
|
195
|
-
'public/logo.png': 512
|
196
|
-
|
213
|
+
docs: true
|
197
214
|
|
198
215
|
#
|
199
216
|
#
|
data/lib/yamg/version.rb
CHANGED
data/lib/yamg/yamg.yml
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
icon:
|
7
7
|
path: 'icons' # path to icons folder
|
8
8
|
rounded: true # defaults to false
|
9
|
-
background: false # nil or color
|
9
|
+
background: false # nil or color #RGB or rgba()
|
10
10
|
|
11
11
|
# Splash screen
|
12
12
|
splash:
|
@@ -33,11 +33,9 @@ compile:
|
|
33
33
|
|
34
34
|
# Web projects
|
35
35
|
#
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
# path: '/path/to/rails/proj'
|
40
|
-
# icon: './alpha' # Using another icon src folder
|
36
|
+
# Any framework, included: Favicons,iOS/Android/MStiles platforms
|
37
|
+
web:
|
38
|
+
path: '../my/web/app'
|
41
39
|
|
42
40
|
# Mobile
|
43
41
|
#
|
Binary file
|
Binary file
|
@@ -0,0 +1,153 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
+
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
3
|
+
|
4
|
+
<svg
|
5
|
+
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
6
|
+
xmlns:cc="http://creativecommons.org/ns#"
|
7
|
+
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
8
|
+
xmlns:svg="http://www.w3.org/2000/svg"
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
10
|
+
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
11
|
+
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
12
|
+
width="48.074291mm"
|
13
|
+
height="48.074287mm"
|
14
|
+
viewBox="0 0 170.34198 170.34196"
|
15
|
+
id="svg2"
|
16
|
+
version="1.1"
|
17
|
+
inkscape:version="0.91 r13725"
|
18
|
+
sodipodi:docname="icon512.svg">
|
19
|
+
<defs
|
20
|
+
id="defs4" />
|
21
|
+
<sodipodi:namedview
|
22
|
+
id="base"
|
23
|
+
pagecolor="#ffffff"
|
24
|
+
bordercolor="#666666"
|
25
|
+
borderopacity="1.0"
|
26
|
+
inkscape:pageopacity="0.0"
|
27
|
+
inkscape:pageshadow="2"
|
28
|
+
inkscape:zoom="2.9260476"
|
29
|
+
inkscape:cx="-178.80292"
|
30
|
+
inkscape:cy="-11.631311"
|
31
|
+
inkscape:document-units="px"
|
32
|
+
inkscape:current-layer="layer1"
|
33
|
+
showgrid="false"
|
34
|
+
inkscape:window-width="3840"
|
35
|
+
inkscape:window-height="2037"
|
36
|
+
inkscape:window-x="0"
|
37
|
+
inkscape:window-y="49"
|
38
|
+
inkscape:window-maximized="1"
|
39
|
+
fit-margin-top="0"
|
40
|
+
fit-margin-left="0"
|
41
|
+
fit-margin-right="0"
|
42
|
+
fit-margin-bottom="0" />
|
43
|
+
<metadata
|
44
|
+
id="metadata7">
|
45
|
+
<rdf:RDF>
|
46
|
+
<cc:Work
|
47
|
+
rdf:about="">
|
48
|
+
<dc:format>image/svg+xml</dc:format>
|
49
|
+
<dc:type
|
50
|
+
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
51
|
+
<dc:title></dc:title>
|
52
|
+
</cc:Work>
|
53
|
+
</rdf:RDF>
|
54
|
+
</metadata>
|
55
|
+
<g
|
56
|
+
inkscape:label="Layer 1"
|
57
|
+
inkscape:groupmode="layer"
|
58
|
+
id="layer1"
|
59
|
+
transform="translate(-297.47522,-430.40631)">
|
60
|
+
<g
|
61
|
+
id="g4145"
|
62
|
+
transform="translate(0.47540151,-0.4753817)">
|
63
|
+
<rect
|
64
|
+
inkscape:export-ydpi="8.4535837"
|
65
|
+
inkscape:export-xdpi="8.4535837"
|
66
|
+
y="446.05267"
|
67
|
+
x="312.17081"
|
68
|
+
height="140"
|
69
|
+
width="140"
|
70
|
+
id="rect4152"
|
71
|
+
style="fill:#ff0000;fill-opacity:1;stroke:none;stroke-width:0.2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
72
|
+
<text
|
73
|
+
inkscape:export-ydpi="8.4535837"
|
74
|
+
inkscape:export-xdpi="8.4535837"
|
75
|
+
sodipodi:linespacing="125%"
|
76
|
+
id="text4144"
|
77
|
+
y="566.58929"
|
78
|
+
x="325.96481"
|
79
|
+
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:42.55854416px;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
80
|
+
xml:space="preserve"><tspan
|
81
|
+
y="566.58929"
|
82
|
+
x="325.96481"
|
83
|
+
id="tspan4146"
|
84
|
+
sodipodi:role="line">M</tspan></text>
|
85
|
+
<rect
|
86
|
+
inkscape:export-ydpi="8.4535837"
|
87
|
+
inkscape:export-xdpi="8.4535837"
|
88
|
+
style="fill:#ffcc00;fill-opacity:1;stroke:none;stroke-width:0.2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
89
|
+
id="rect4154"
|
90
|
+
width="70"
|
91
|
+
height="70"
|
92
|
+
x="312.17081"
|
93
|
+
y="446.05267" />
|
94
|
+
<text
|
95
|
+
inkscape:export-ydpi="8.4535837"
|
96
|
+
inkscape:export-xdpi="8.4535837"
|
97
|
+
sodipodi:linespacing="125%"
|
98
|
+
id="text4136"
|
99
|
+
y="496.24783"
|
100
|
+
x="330.30042"
|
101
|
+
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:45.99017334px;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';letter-spacing:0px;word-spacing:0px;fill:#000000;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
102
|
+
xml:space="preserve"><tspan
|
103
|
+
y="496.24783"
|
104
|
+
x="330.30042"
|
105
|
+
id="tspan4138"
|
106
|
+
sodipodi:role="line">Y</tspan></text>
|
107
|
+
<rect
|
108
|
+
inkscape:export-ydpi="8.4535837"
|
109
|
+
inkscape:export-xdpi="8.4535837"
|
110
|
+
y="446.05267"
|
111
|
+
x="382.17081"
|
112
|
+
height="70"
|
113
|
+
width="70"
|
114
|
+
id="rect4156"
|
115
|
+
style="fill:#338000;fill-opacity:1;stroke:none;stroke-width:0.2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1" />
|
116
|
+
<text
|
117
|
+
inkscape:export-ydpi="8.4535837"
|
118
|
+
inkscape:export-xdpi="8.4535837"
|
119
|
+
sodipodi:linespacing="125%"
|
120
|
+
id="text4140"
|
121
|
+
y="495.36066"
|
122
|
+
x="400.5531"
|
123
|
+
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:44.49308777px;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
124
|
+
xml:space="preserve"><tspan
|
125
|
+
y="495.36066"
|
126
|
+
x="400.5531"
|
127
|
+
id="tspan4142"
|
128
|
+
sodipodi:role="line">A</tspan></text>
|
129
|
+
<rect
|
130
|
+
inkscape:export-ydpi="8.4535837"
|
131
|
+
inkscape:export-xdpi="8.4535837"
|
132
|
+
style="fill:#000000;fill-opacity:1;stroke:none;stroke-width:0.2;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
|
133
|
+
id="rect4158"
|
134
|
+
width="70"
|
135
|
+
height="70"
|
136
|
+
x="382.17081"
|
137
|
+
y="515.71124" />
|
138
|
+
<text
|
139
|
+
inkscape:export-ydpi="8.4535837"
|
140
|
+
inkscape:export-xdpi="8.4535837"
|
141
|
+
sodipodi:linespacing="125%"
|
142
|
+
id="text4148"
|
143
|
+
y="566.70984"
|
144
|
+
x="401.24396"
|
145
|
+
style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:40.71053314px;line-height:125%;font-family:sans-serif;-inkscape-font-specification:'sans-serif Bold';letter-spacing:0px;word-spacing:0px;fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
146
|
+
xml:space="preserve"><tspan
|
147
|
+
y="566.70984"
|
148
|
+
x="401.24396"
|
149
|
+
id="tspan4150"
|
150
|
+
sodipodi:role="line">G</tspan></text>
|
151
|
+
</g>
|
152
|
+
</g>
|
153
|
+
</svg>
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe YAMG::Icon do
|
4
|
+
|
5
|
+
ICONS_PATH = Dir.pwd + '/spec/icons/'
|
6
|
+
OUT_PATH = Dir.pwd + '/spec/out/'
|
7
|
+
|
8
|
+
before(:all) do
|
9
|
+
FileUtils.rm_rf '/spec/out/*'
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'PNG flow' do
|
13
|
+
it 'should outputs a png file 16px > i16.png' do
|
14
|
+
out = OUT_PATH + 'i16.png'
|
15
|
+
YAMG::Icon.new(ICONS_PATH, 16).image(out)
|
16
|
+
expect(File.exist?(out)).to be_truthy
|
17
|
+
expect(File.size(out)).to eq(524) # transparency channel
|
18
|
+
img = ::MiniMagick::Image.open out
|
19
|
+
expect(img.width).to eq(16)
|
20
|
+
expect(img.height).to eq(16)
|
21
|
+
expect(img.type).to eq('PNG')
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should outputs a png file > i256.png' do
|
25
|
+
out = OUT_PATH + 'i256.png'
|
26
|
+
YAMG::Icon.new(ICONS_PATH, 256).image(out)
|
27
|
+
expect(File.exist?(out)).to be_truthy
|
28
|
+
img = ::MiniMagick::Image.open out
|
29
|
+
expect(img.type).to eq('PNG')
|
30
|
+
expect(img.width).to eq(256)
|
31
|
+
expect(img.height).to eq(256)
|
32
|
+
expect(File.size(out)).to eq(5070) # transparency channel
|
33
|
+
# expect(File.size(out)).to eq(4952) # set format?
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'should outputs a png file with bg > i256bg.png' do
|
37
|
+
out = OUT_PATH + 'i256bg.png'
|
38
|
+
YAMG::Icon.new(ICONS_PATH, 256, 'black').image(out)
|
39
|
+
expect(File.exist?(out)).to be_truthy
|
40
|
+
expect(File.size(out)).to eq(5141) # transparency channel
|
41
|
+
img = ::MiniMagick::Image.open out
|
42
|
+
expect(img.width).to eq(256)
|
43
|
+
expect(img.height).to eq(256)
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should outputs a png file round > i256r.png' do
|
47
|
+
out = OUT_PATH + 'i256r.png'
|
48
|
+
YAMG::Icon.new(ICONS_PATH, 256, nil, :round).image(out)
|
49
|
+
expect(File.exist?(out)).to be_truthy
|
50
|
+
expect(File.size(out)).to eq(5089) # transparency channel
|
51
|
+
img = ::MiniMagick::Image.open out
|
52
|
+
expect(img.width).to eq(256)
|
53
|
+
expect(img.height).to eq(256)
|
54
|
+
end
|
55
|
+
|
56
|
+
it 'should outputs a png file bg & round > i256bgr.png' do
|
57
|
+
out = OUT_PATH + 'i256bgr.png'
|
58
|
+
YAMG::Icon.new(ICONS_PATH, 256, '#FF0000', :round).image(out)
|
59
|
+
expect(File.exist?(out)).to be_truthy
|
60
|
+
expect(File.size(out)).to eq(5809) # transparency channel
|
61
|
+
img = ::MiniMagick::Image.open out
|
62
|
+
expect(img.width).to eq(256)
|
63
|
+
expect(img.height).to eq(256)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
describe 'ICO flow' do
|
68
|
+
it 'should output a multiple size ico file' do
|
69
|
+
out = OUT_PATH + 'favicon.ico'
|
70
|
+
YAMG::Icon.new(ICONS_PATH, 48).image(out)
|
71
|
+
expect(File.exist?(out)).to be_truthy
|
72
|
+
expect(File.size(out)).to eq(7406) # transparency channel
|
73
|
+
img = ::MiniMagick::Image.open out
|
74
|
+
expect(img.type).to eq('ICO')
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'should have a nice find icon 16' do
|
79
|
+
expect(YAMG).to receive(:load_images).with('foo')
|
80
|
+
.and_return(['16.png', '32.png', '64.png'])
|
81
|
+
icon = YAMG::Icon.new('foo', 16)
|
82
|
+
expect(icon.find_closest_gte_icon).to eq('16.png')
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'should have a nice find icon 48' do
|
86
|
+
expect(YAMG).to receive(:load_images).with('foo')
|
87
|
+
.and_return(['16.png', '32.png', '64.png'])
|
88
|
+
icon = YAMG::Icon.new('foo', 48)
|
89
|
+
expect(icon.find_closest_gte_icon).to eq('64.png')
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should have a nice find icon 256' do
|
93
|
+
expect(YAMG).to receive(:load_images).with('foo')
|
94
|
+
.and_return(['16.png', '32.png', '64.png'])
|
95
|
+
icon = YAMG::Icon.new('foo', 256)
|
96
|
+
expect(icon.find_closest_gte_icon).to eq('64.png')
|
97
|
+
end
|
98
|
+
|
99
|
+
it 'should have a nice find icon mixed names' do
|
100
|
+
expect(YAMG).to receive(:load_images).with('foo')
|
101
|
+
.and_return(['xx16.png', '32oo.png', 'x64o.png'])
|
102
|
+
icon = YAMG::Icon.new('foo', 64)
|
103
|
+
expect(icon.find_closest_gte_icon).to eq('x64o.png')
|
104
|
+
end
|
105
|
+
end
|
data/spec/yamg/yamg_spec.rb
CHANGED
@@ -5,24 +5,12 @@ describe YAMG do
|
|
5
5
|
stub_const('YAML', y = class_double('YAML'))
|
6
6
|
expect(y).to receive(:load_file).and_return({})
|
7
7
|
|
8
|
-
expect { YAMG.new }.to_not raise_error
|
8
|
+
expect { YAMG::CLI.new([]) }.to_not raise_error
|
9
9
|
end
|
10
10
|
|
11
11
|
describe 'stubbed' do
|
12
12
|
let :conf do
|
13
13
|
stub_const('YAML', class_double('YAML'))
|
14
14
|
end
|
15
|
-
|
16
|
-
it 'should read conf icon' do
|
17
|
-
expect(conf).to receive(:load_file).and_return(icon: {})
|
18
|
-
expect(YAMG.new.config).to eq(icon: {})
|
19
|
-
end
|
20
|
-
|
21
|
-
describe 'simple setup' do
|
22
|
-
it 'should map true to media' do
|
23
|
-
expect(conf).to receive(:load_file).and_return({})
|
24
|
-
expect(YAMG.new.setup_for(true)).to eq('path' => './media')
|
25
|
-
end
|
26
|
-
end
|
27
15
|
end
|
28
16
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yamg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcos Piccinini
|
@@ -71,7 +71,9 @@ files:
|
|
71
71
|
- Rakefile
|
72
72
|
- bin/yamg
|
73
73
|
- lib/yamg.rb
|
74
|
+
- lib/yamg/assets/browserconfig.xml
|
74
75
|
- lib/yamg/assets/dot.png
|
76
|
+
- lib/yamg/assets/manifest.json
|
75
77
|
- lib/yamg/cli.rb
|
76
78
|
- lib/yamg/icon.rb
|
77
79
|
- lib/yamg/screenshot.rb
|
@@ -79,7 +81,12 @@ files:
|
|
79
81
|
- lib/yamg/templates.yaml
|
80
82
|
- lib/yamg/version.rb
|
81
83
|
- lib/yamg/yamg.yml
|
84
|
+
- spec/icons/icon16.png
|
85
|
+
- spec/icons/icon32.png
|
86
|
+
- spec/icons/icon512.svg
|
87
|
+
- spec/out/.gitkeep
|
82
88
|
- spec/spec_helper.rb
|
89
|
+
- spec/yamg/icon_spec.rb
|
83
90
|
- spec/yamg/yamg_spec.rb
|
84
91
|
- yamg.gemspec
|
85
92
|
homepage: http://github.com/nofxx/yamg
|
@@ -107,5 +114,10 @@ signing_key:
|
|
107
114
|
specification_version: 4
|
108
115
|
summary: Yet another media generator
|
109
116
|
test_files:
|
117
|
+
- spec/icons/icon16.png
|
118
|
+
- spec/icons/icon32.png
|
119
|
+
- spec/icons/icon512.svg
|
120
|
+
- spec/out/.gitkeep
|
110
121
|
- spec/spec_helper.rb
|
122
|
+
- spec/yamg/icon_spec.rb
|
111
123
|
- spec/yamg/yamg_spec.rb
|