yamg 0.0.9 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -2
- data/lib/yamg/assets/dot.png +0 -0
- data/lib/yamg/cli.rb +48 -29
- data/lib/yamg/icon.rb +27 -6
- data/lib/yamg/screenshot.rb +7 -2
- data/lib/yamg/splash.rb +33 -19
- data/lib/yamg/templates.yaml +79 -35
- data/lib/yamg/version.rb +1 -1
- data/lib/yamg/yamg.yml +13 -9
- data/lib/yamg.rb +37 -44
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a7e652f48f91c43b778c3d54fe1130274ef3fba4
|
4
|
+
data.tar.gz: 3f2e4c1b25a818a87e441b137ee7b5f9f4464df6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6308eb73468929091a1f21e56c344866fc06bb706e614df38bfb61ee07c54ea01650a1b65e35367b256221fe153ba41ce8e549184f0925e5242011b6808a519b
|
7
|
+
data.tar.gz: e97d26fcc5e2e26a73c1485b0672ab9e625e07bf307b3d97b201af11e2deebfc602d76fb783218293cb5cc0dc03030bbfb8b87a08f381b9cd8aceac08a0382b3
|
data/README.md
CHANGED
@@ -21,22 +21,25 @@
|
|
21
21
|
YAMG - Yet Another Media Generator
|
22
22
|
|
23
23
|
|
24
|
+
|
24
25
|
## Install
|
25
26
|
|
26
27
|
Linux
|
27
28
|
|
28
|
-
nice-pkg-manager install imagemagick phantomjs ruby
|
29
|
+
nice-pkg-manager install imagemagick phantomjs librsvg ruby
|
29
30
|
gem install yamg
|
30
31
|
|
31
32
|
OSX
|
32
33
|
|
33
|
-
brew install imagemagick phantomjs ruby
|
34
|
+
brew install imagemagick phantomjs librsvg ruby
|
34
35
|
gem install yamg
|
35
36
|
|
36
37
|
|
37
38
|
## Features
|
38
39
|
|
39
40
|
* Find best version (size) to use from icons folder.
|
41
|
+
* Shrinks binaries from the closest or greater size version.
|
42
|
+
* Raster SVG to PNG with exact size and dpi.
|
40
43
|
* Splash screen/banner generation with gravity.
|
41
44
|
* Works with iOS/Android/Other mobile with Phonegap or Cordova.
|
42
45
|
* Exports icons and splashes for stores and social networks.
|
@@ -49,8 +52,15 @@ OSX
|
|
49
52
|
|
50
53
|
A `.yamg.yml` will be created on the folder.
|
51
54
|
|
55
|
+
|
52
56
|
### Icons
|
53
57
|
|
58
|
+
Your main icon(s) may be SVG or PNG. Or both:
|
59
|
+
SVG is always the best choice except really small (16x16, 32x32)
|
60
|
+
icons: there you can show your pixel art skills to the world.
|
61
|
+
|
62
|
+
#### PNG
|
63
|
+
|
54
64
|
Multiple sizes:
|
55
65
|
Just save your files with the size in pixels first, example:
|
56
66
|
In the 'icons/' folder: '16-icon.png', '32-icon.png', '512-icon.png'.
|
@@ -59,6 +69,12 @@ the icon if sizes are a match.
|
|
59
69
|
|
60
70
|
It's ok to (or if you) have only one icon, make it >512px.
|
61
71
|
|
72
|
+
#### SVG
|
73
|
+
|
74
|
+
You may still use best size match: Just have you folder:
|
75
|
+
'16-icon.svg', '256-icon.svg', problably not much more:
|
76
|
+
The SVG will be rasterized in the correct size needed.
|
77
|
+
|
62
78
|
|
63
79
|
### Splash
|
64
80
|
|
Binary file
|
data/lib/yamg/cli.rb
CHANGED
@@ -1,78 +1,97 @@
|
|
1
1
|
module YAMG
|
2
2
|
# Command line interface
|
3
3
|
class CLI
|
4
|
-
attr_accessor :works
|
4
|
+
attr_accessor :works, :scope
|
5
5
|
|
6
6
|
def initialize(argv)
|
7
7
|
puts
|
8
8
|
puts Rainbow(' Y A M G').red
|
9
9
|
puts
|
10
|
-
|
10
|
+
if argv.join =~ /debug/
|
11
|
+
YAMG.debug = true
|
12
|
+
puts Rainbow('!!! DEBUG !!!').red
|
13
|
+
argv.delete('debug')
|
14
|
+
end
|
11
15
|
return YAMG.init if argv.join =~ /init/
|
12
16
|
YAMG.load_config # (argv)
|
13
17
|
@works = YAMG.config['compile']
|
18
|
+
@scope = argv.empty? ? nil : argv.join
|
14
19
|
end
|
15
20
|
|
16
21
|
def setup_for(opts)
|
17
22
|
case opts
|
18
|
-
when Hash then opts
|
23
|
+
when Hash then { 'path' => './export/' }.merge(opts)
|
19
24
|
when String then { 'path' => opts }
|
20
|
-
when TrueClass then { 'path' => './
|
25
|
+
when TrueClass then { 'path' => './export/' }
|
21
26
|
else fail
|
22
27
|
end
|
23
28
|
end
|
24
29
|
|
30
|
+
def home_for(asset, setup)
|
31
|
+
path = setup['path']
|
32
|
+
FileUtils.mkdir_p path unless File.exist?(path)
|
33
|
+
File.join(path, asset)
|
34
|
+
end
|
35
|
+
|
36
|
+
def compile_media(i, size, setup)
|
37
|
+
end
|
38
|
+
|
25
39
|
def compile_icon(i, size, setup)
|
26
40
|
folder = setup['icon'] || YAMG.config['icon']['path']
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
41
|
+
# Don' use || here, we are after false
|
42
|
+
round = setup['rounded']
|
43
|
+
round = YAMG.config['icon']['rounded'] if round.nil?
|
44
|
+
Icon.new(folder, size, round).image(home_for(i, setup))
|
45
|
+
print Rainbow(round ? '(i)' : '[i]').black
|
46
|
+
YAMG.info("Icon #{size}px -> #{setup['path']}#{i} ", :black)
|
33
47
|
end
|
34
48
|
|
35
49
|
def compile_splash(s, size, setup)
|
36
50
|
path = setup['splash'] || YAMG.config['splash']['path']
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
print Rainbow('S').black
|
51
|
+
background = YAMG.config['splash']['background']
|
52
|
+
Splash.new(path, size, background).image(home_for(s, setup))
|
53
|
+
print Rainbow('{S}').black
|
54
|
+
YAMG.info("Splash #{size.join('x')}px #{setup['path']}#{s}", :black)
|
42
55
|
end
|
43
56
|
|
44
|
-
def compile_work(
|
57
|
+
def compile_work(template, opts)
|
45
58
|
setup = setup_for(opts)
|
46
59
|
|
47
|
-
if (task = YAMG::TEMPLATES[
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
60
|
+
if (task = YAMG::TEMPLATES[template])
|
61
|
+
%w(icon splash media).each do |key|
|
62
|
+
next unless (work = task[key])
|
63
|
+
work.each do |i, d|
|
64
|
+
#Thread.new do # 200% speed up with 8 cores
|
65
|
+
send(:"compile_#{key}", i, d, setup)
|
66
|
+
#end
|
67
|
+
end
|
68
|
+
end
|
53
69
|
else
|
54
70
|
# puts 'Custom job!'
|
55
71
|
end
|
56
72
|
end
|
57
73
|
|
58
|
-
def compile
|
59
|
-
works.select! {
|
74
|
+
def compile
|
75
|
+
works.select! { |k,_v| k =~ /#{scope}/ } if scope
|
76
|
+
puts Rainbow("Tasks: #{works.keys.join(', ')}").yellow
|
60
77
|
works.each { |out, opts| compile_work(out, opts) }
|
61
|
-
works.select! { |w| w =~ scope } if scope
|
62
|
-
puts Rainbow("Working on #{works.keys.join(', ')}").yellow
|
63
78
|
end
|
64
79
|
|
65
80
|
def screenshot
|
66
81
|
YAMG.config['screenshots'].each do |ss|
|
67
|
-
Thread.new
|
82
|
+
Thread.new do
|
83
|
+
Screenshot.new(ss).work('./export')
|
84
|
+
puts Rainbow("[o]SS #{ss[0]} #{ss[1]}").black
|
85
|
+
end
|
68
86
|
end
|
69
87
|
end
|
70
88
|
|
71
89
|
def work!
|
72
90
|
time = Time.now
|
73
91
|
compile
|
74
|
-
screenshot
|
75
|
-
puts
|
92
|
+
screenshot if scope.nil? || scope =~ /ss|shot|screen/
|
93
|
+
puts
|
94
|
+
puts Rainbow(Thread.list.size.to_s + ' jobs to go').black
|
76
95
|
Thread.list.reject { |t| t == Thread.current }.each(&:join)
|
77
96
|
puts Rainbow('-' * 59).black
|
78
97
|
puts Rainbow("Done compile #{Time.now - time}").red
|
data/lib/yamg/icon.rb
CHANGED
@@ -4,7 +4,7 @@ module YAMG
|
|
4
4
|
#
|
5
5
|
#
|
6
6
|
class Icon
|
7
|
-
attr_accessor :src, :size, :rounded, :icons
|
7
|
+
attr_accessor :src, :size, :dpi, :rounded, :icons
|
8
8
|
|
9
9
|
def initialize(src, size, rounded = false)
|
10
10
|
fail if src.nil? || src.empty?
|
@@ -12,7 +12,11 @@ module YAMG
|
|
12
12
|
@size = size
|
13
13
|
@rounded = rounded
|
14
14
|
@icons = YAMG.load_images(src)
|
15
|
+
YAMG.puts_and_exit("No sources in '#{src}'") if icons.empty?
|
16
|
+
@path = File.join(src, find_closest_gte_icon)
|
17
|
+
@dpi = 90
|
15
18
|
end
|
19
|
+
alias_method :rounded?, :rounded
|
16
20
|
|
17
21
|
def find_closest_gte_icon
|
18
22
|
return icons.max_by(&:to_i) if icons.map(&:to_i).max < size
|
@@ -23,11 +27,18 @@ module YAMG
|
|
23
27
|
end
|
24
28
|
end
|
25
29
|
|
26
|
-
def image
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
30
|
+
def image(out)
|
31
|
+
if File.extname(@path) =~ /svg/
|
32
|
+
pixels = dpi ? "-d #{dpi} -p #{dpi}" : nil
|
33
|
+
args = "#{pixels} -w #{size} -h #{size} -f png"
|
34
|
+
YAMG.run_rsvg(@path, out, args)
|
35
|
+
img = MiniMagick::Image.open(out)
|
36
|
+
else
|
37
|
+
img = MiniMagick::Image.open(@path)
|
38
|
+
img.resize size # "NxN"
|
39
|
+
write_out(img, out)
|
40
|
+
end
|
41
|
+
write_out(round(img), out) if rounded?
|
31
42
|
end
|
32
43
|
|
33
44
|
#
|
@@ -73,5 +84,15 @@ module YAMG
|
|
73
84
|
end
|
74
85
|
masked
|
75
86
|
end
|
87
|
+
|
88
|
+
#
|
89
|
+
# Writes image to disk
|
90
|
+
#
|
91
|
+
def write_out(img, out)
|
92
|
+
FileUtils.mkdir_p File.dirname(out)
|
93
|
+
img.write(out)
|
94
|
+
rescue Errno::ENOENT
|
95
|
+
puts_and_exit("Path not found '#{out}'")
|
96
|
+
end
|
76
97
|
end
|
77
98
|
end
|
data/lib/yamg/screenshot.rb
CHANGED
@@ -11,13 +11,19 @@ module YAMG
|
|
11
11
|
# Uses PhantomJS
|
12
12
|
def initialize(ss)
|
13
13
|
@name, opts = *ss
|
14
|
+
fail 'No screen size provided' unless opts['size']
|
14
15
|
uri = URI.parse(opts['url'])
|
15
16
|
@url = "http://#{uri}"
|
16
|
-
@size = opts['size']
|
17
|
+
@size = opts['size']
|
18
|
+
@size = @size.split(/\s?,\s?/) if @size.respond_to?(:split)
|
17
19
|
# @fetcher = Smartshot::Screenshot.new(window_size: @size)
|
18
20
|
@fetcher = Screencap::Fetcher.new(@url)
|
19
21
|
end
|
20
22
|
|
23
|
+
def android
|
24
|
+
# adb -e shell screencap -p | perl -pe 's/\x0D\x0A/\x0A/g' > screen.png
|
25
|
+
end
|
26
|
+
|
21
27
|
# Take the screenshot
|
22
28
|
# Do we need pixel depth??
|
23
29
|
def work(path)
|
@@ -25,7 +31,6 @@ module YAMG
|
|
25
31
|
# page.save_screenshot("#{path}/#{@name}.png")
|
26
32
|
# @fetcher.take_screenshot!(url: url, output: "#{path}/#{@name}.png")
|
27
33
|
@fetcher.fetch(output: "#{path}/#{@name}.png", width: @size[0], height: @size[1])
|
28
|
-
puts Rainbow("SS #{url} #{size}").black
|
29
34
|
end
|
30
35
|
end
|
31
36
|
end
|
data/lib/yamg/splash.rb
CHANGED
@@ -4,55 +4,69 @@ module YAMG
|
|
4
4
|
#
|
5
5
|
#
|
6
6
|
class Splash
|
7
|
-
attr_accessor :src, :bg, :size, :
|
7
|
+
attr_accessor :src, :bg, :size, :assets, :img
|
8
8
|
|
9
9
|
def initialize(src, size, background)
|
10
10
|
@src = src
|
11
11
|
@size = size
|
12
12
|
@bg = background
|
13
|
-
@
|
14
|
-
|
13
|
+
@assets = YAMG.load_images(src)
|
14
|
+
%w(bg background wallpaper).each do |i|
|
15
|
+
@wallpaper = assets.delete("#{i}.png")
|
16
|
+
end
|
17
|
+
if (center = assets.delete('center.png'))
|
18
|
+
@center = File.join(src, center)
|
19
|
+
end
|
20
|
+
@center ||= File.join(File.dirname(__FILE__), 'assets', 'dot.png')
|
21
|
+
YAMG.puts_and_exit("No sources in '#{src}'") if assets.empty?
|
22
|
+
@img = MiniMagick::Image.open(@center)
|
23
|
+
end
|
15
24
|
|
16
25
|
#
|
17
26
|
# Center image
|
18
27
|
#
|
19
|
-
def
|
20
|
-
icon_size = size.max /
|
28
|
+
def splash_start
|
29
|
+
icon_size = size.max / 9
|
21
30
|
img.resize icon_size if img.dimensions.max >= icon_size
|
22
|
-
img.background bg if bg
|
23
31
|
img.combine_options do |o|
|
24
32
|
o.gravity 'center'
|
33
|
+
o.background bg if bg
|
25
34
|
o.extent size.join('x') # "WxH"
|
26
35
|
end
|
27
36
|
end
|
28
37
|
|
29
38
|
def compose(other, name)
|
30
39
|
img.composite(other) do |o|
|
31
|
-
o.compose 'Over'
|
32
40
|
o.gravity File.basename(name, '.*')
|
33
|
-
o.
|
41
|
+
o.compose 'Over'
|
42
|
+
padding = name =~ /east|west/ ? '+40%' : '+0%'
|
43
|
+
padding += name =~ /north|south/ ? '+40%' : '+0%'
|
44
|
+
o.geometry padding
|
34
45
|
end
|
35
46
|
end
|
36
47
|
|
37
48
|
#
|
38
49
|
# Composite 9 gravity
|
39
50
|
#
|
40
|
-
def splash_composite
|
41
|
-
max =
|
42
|
-
|
51
|
+
def splash_composite
|
52
|
+
max = size.min / 9
|
53
|
+
assets.each do |over|
|
43
54
|
other = MiniMagick::Image.open(File.join(src, over))
|
44
55
|
other.resize(max) if other.dimensions.max >= max
|
45
|
-
compose(other, over)
|
56
|
+
self.img = compose(other, over)
|
46
57
|
end
|
47
|
-
base
|
48
58
|
end
|
49
59
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
splash_composite
|
60
|
+
#
|
61
|
+
# Writes image to disk
|
62
|
+
#
|
63
|
+
def image(out)
|
64
|
+
splash_start
|
65
|
+
splash_composite
|
66
|
+
FileUtils.mkdir_p File.dirname(out)
|
67
|
+
img.write(out)
|
68
|
+
rescue Errno::ENOENT
|
69
|
+
YAMG.puts_and_exit("Path not found '#{out}'")
|
56
70
|
end
|
57
71
|
end
|
58
72
|
end
|
data/lib/yamg/templates.yaml
CHANGED
@@ -1,5 +1,22 @@
|
|
1
|
+
raster:
|
2
|
+
icon:
|
3
|
+
'icon16.png': 16
|
4
|
+
'icon32.png': 32
|
5
|
+
'icon64.png': 64
|
6
|
+
'icon128.png': 128
|
7
|
+
'icon256.png': 256
|
8
|
+
splash:
|
9
|
+
'splash-port-sm.png': [480, 320]
|
10
|
+
'splash-port-md.png': [1024, 768]
|
11
|
+
'splash-port-lg.png': [2048, 1536]
|
12
|
+
'splash-land-sm.png': [320, 480]
|
13
|
+
'splash-land-md.png': [768, 1024]
|
14
|
+
'splash-land-lg.png': [1536, 2048]
|
15
|
+
media:
|
16
|
+
'media-preview.png': [512]
|
17
|
+
|
1
18
|
android:
|
2
|
-
|
19
|
+
icon:
|
3
20
|
'res/drawable/icon.png': 96
|
4
21
|
'res/drawable-ldpi/icon.png': 36
|
5
22
|
'res/drawable-mdpi/icon.png': 48
|
@@ -44,7 +61,7 @@ android:
|
|
44
61
|
|
45
62
|
|
46
63
|
ios:
|
47
|
-
|
64
|
+
icon:
|
48
65
|
'Resources/icons/icon.png': 57
|
49
66
|
'Resources/icons/icon@2x.png': 114
|
50
67
|
'Resources/icons/icon-40.png': 40
|
@@ -75,6 +92,24 @@ ios:
|
|
75
92
|
'Resources/splash/Default-736h.png': [1242, 2208]
|
76
93
|
'Resources/splash/Default-Landscape-736h.png' : [2208, 1242]
|
77
94
|
|
95
|
+
windows:
|
96
|
+
icons:
|
97
|
+
'StoreLogo.scale-240.png': 120
|
98
|
+
'StoreLogo.scale-100.png': 50
|
99
|
+
'Square150x150Logo.scale-100.png': 150
|
100
|
+
'Square150x150Logo.scale-240.png': 360
|
101
|
+
'Square30x30Logo.scale-100.png': 30
|
102
|
+
'Square310x310Logo.scale-100.png': 310
|
103
|
+
'Square44x44Logo.scale-100.png': 44
|
104
|
+
'Square44x44Logo.scale-240.png': 106
|
105
|
+
'Square70x70Logo.scale-100.png': 70
|
106
|
+
'Square71x71Logo.scale-100.png': 71
|
107
|
+
'Square71x71Logo.scale-240.png': 170
|
108
|
+
splash:
|
109
|
+
'SplashScreen.scale-100.png': [620, 300]
|
110
|
+
'SplashScreenPhone.scale-240.png': [1152, 1920]
|
111
|
+
'Wide310x150Logo.scale-100.png': [310, 150]
|
112
|
+
'Wide310x150Logo.scale-240.png': [744, 360]
|
78
113
|
|
79
114
|
phonegap:
|
80
115
|
icon:
|
@@ -117,52 +152,35 @@ phonegap:
|
|
117
152
|
|
118
153
|
|
119
154
|
web:
|
120
|
-
|
155
|
+
icon:
|
121
156
|
'icon.png': 256
|
122
157
|
media:
|
123
158
|
'media.png': 256
|
124
159
|
|
125
160
|
|
126
161
|
rails:
|
127
|
-
|
162
|
+
icon:
|
128
163
|
'public/favicon.png': 16
|
129
164
|
'public/favicon.ico': 16
|
130
165
|
'public/icon.png': 512
|
131
166
|
'app/assets/images/icon.png': 512
|
132
167
|
'app/assets/images/favicon.png': 16
|
133
168
|
media:
|
169
|
+
'app/assets/images/logo.png': 512
|
134
170
|
'public/logo.png': 512
|
135
171
|
|
136
172
|
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
google:
|
143
|
-
icons:
|
144
|
-
'icon.png': 512
|
145
|
-
'icon1024.png': 1024
|
146
|
-
'180.png': 180
|
147
|
-
splash:
|
148
|
-
'splash.png': [1024, 768]
|
149
|
-
screenshots:
|
150
|
-
'android/android-10in-1280x720-land': [1280, 720]
|
151
|
-
'android/android-10in-2048x1152-land': [2048, 1152]
|
152
|
-
'android/android-10in-1280x720-port': [720, 1280]
|
153
|
-
'android/android-10in-2048x1152-port': [1152, 2048]
|
154
|
-
'android/android-7in-1280x800-land': [1280, 800]
|
155
|
-
'android/android-7in-1280x800-port': [800, 1280]
|
156
|
-
'android/android-4in-1280x720-land': [1920, 1080]
|
157
|
-
'android/android-4in-1280x720-port': [1080, 1920]
|
158
|
-
|
159
|
-
|
173
|
+
#
|
174
|
+
#
|
175
|
+
# STORES
|
176
|
+
#
|
177
|
+
#
|
160
178
|
apple:
|
161
|
-
|
162
|
-
'icon.png': 1024
|
163
|
-
'icon16.png': 16
|
179
|
+
icon:
|
180
|
+
'apple/icon.png': 1024
|
181
|
+
'apple/icon16.png': 16
|
164
182
|
splash:
|
165
|
-
'splash.png': [1024, 768]
|
183
|
+
'apple/splash.png': [1024, 768]
|
166
184
|
screenshots:
|
167
185
|
'ios/ipad-1024x768-land': [1024, 768]
|
168
186
|
'ios/ipad-1024x768-port': [768, 1024]
|
@@ -177,10 +195,36 @@ apple:
|
|
177
195
|
'ios/iphone6-1334x750-land': [1334, 750, 2]
|
178
196
|
'ios/iphone6-750x1334-port': [750, 1334, 2]
|
179
197
|
|
198
|
+
google:
|
199
|
+
icon:
|
200
|
+
'google/icon.png': 512
|
201
|
+
'google/icon1024.png': 1024
|
202
|
+
'google/180.png': 180
|
203
|
+
splash:
|
204
|
+
'google/splash.png': [1024, 768]
|
205
|
+
screenshots:
|
206
|
+
'android/android-10in-1280x720-land': [1280, 720]
|
207
|
+
'android/android-10in-2048x1152-land': [2048, 1152]
|
208
|
+
'android/android-10in-1280x720-port': [720, 1280]
|
209
|
+
'android/android-10in-2048x1152-port': [1152, 2048]
|
210
|
+
'android/android-7in-1280x800-land': [1280, 800]
|
211
|
+
'android/android-7in-1280x800-port': [800, 1280]
|
212
|
+
'android/android-4in-1280x720-land': [1920, 1080]
|
213
|
+
'android/android-4in-1280x720-port': [1080, 1920]
|
214
|
+
|
215
|
+
|
216
|
+
#
|
217
|
+
#
|
218
|
+
# NETWORKS
|
219
|
+
#
|
220
|
+
#
|
221
|
+
twitter:
|
222
|
+
icon:
|
223
|
+
'twitter/icon.png': 256
|
180
224
|
|
181
225
|
facebook:
|
182
|
-
|
183
|
-
'icon.png': 1024
|
184
|
-
'icon16.png': 16
|
226
|
+
icon:
|
227
|
+
'fb/icon.png': 1024
|
228
|
+
'fb/icon16.png': 16
|
185
229
|
splash:
|
186
|
-
'splash.png': [1024, 768]
|
230
|
+
'fb/splash.png': [1024, 768]
|
data/lib/yamg/version.rb
CHANGED
data/lib/yamg/yamg.yml
CHANGED
@@ -6,12 +6,12 @@
|
|
6
6
|
icon:
|
7
7
|
path: 'icons' # path to icons folder
|
8
8
|
rounded: true # defaults to false
|
9
|
-
background: false # or color
|
9
|
+
background: false # nil or color RGBA
|
10
10
|
|
11
11
|
# Splash screen
|
12
12
|
splash:
|
13
|
-
path: 'splash'
|
14
|
-
background: '#fff6d5' # or color
|
13
|
+
path: 'splash' # path to the splash assets folder
|
14
|
+
background: '#fff6d5' # nil or color RGBA
|
15
15
|
|
16
16
|
# Icon + name for instance
|
17
17
|
media:
|
@@ -24,6 +24,9 @@ media:
|
|
24
24
|
compile:
|
25
25
|
# Just remove if you don't need
|
26
26
|
|
27
|
+
# Preview to ./export/
|
28
|
+
raster: true
|
29
|
+
|
27
30
|
# Web projects
|
28
31
|
#
|
29
32
|
web: true
|
@@ -57,11 +60,12 @@ compile:
|
|
57
60
|
|
58
61
|
# Custom icons/splash
|
59
62
|
# Compiles to media/*
|
60
|
-
custom:
|
61
|
-
|
62
|
-
|
63
|
+
# custom:
|
64
|
+
# icons: [32, 64, 128]
|
65
|
+
# medias: [400, 800]
|
63
66
|
|
64
67
|
# Custom screenshots
|
65
|
-
screenshots:
|
66
|
-
|
67
|
-
|
68
|
+
# screenshots:
|
69
|
+
# home:
|
70
|
+
# url: 'github.com'
|
71
|
+
# size: [1280, 720]
|
data/lib/yamg.rb
CHANGED
@@ -14,72 +14,65 @@ module YAMG
|
|
14
14
|
autoload :Splash, 'yamg/splash'
|
15
15
|
autoload :Screenshot, 'yamg/screenshot'
|
16
16
|
|
17
|
+
CONFIG_FILE = './.yamg.yml'
|
17
18
|
# Load template works
|
18
19
|
TEMPLATES = YAML.load_file(
|
19
20
|
File.join(File.dirname(__FILE__), 'yamg', 'templates.yaml')
|
20
21
|
)
|
21
22
|
|
22
|
-
# def initialize(conf = './.yamg.yml')
|
23
|
-
# load_config(conf)
|
24
|
-
# end
|
25
23
|
class << self
|
26
|
-
attr_accessor :config
|
24
|
+
attr_accessor :config, :debug
|
27
25
|
|
28
26
|
def init
|
29
|
-
|
30
|
-
|
31
|
-
puts "File exists: '#{file}'"
|
27
|
+
if File.exist?(CONFIG_FILE)
|
28
|
+
puts "File exists: '#{CONFIG_FILE}'"
|
32
29
|
exit 1
|
33
30
|
end
|
34
|
-
puts Rainbow('Creating your configuration').black
|
35
31
|
src = File.join(File.dirname(__FILE__), 'yamg', 'yamg.yml')
|
36
|
-
FileUtils.cp(src,
|
32
|
+
FileUtils.cp(src, CONFIG_FILE)
|
33
|
+
puts_and_exit("Created configuration file '#{CONFIG_FILE}'", :black)
|
37
34
|
end
|
38
35
|
|
39
|
-
def load_config(conf =
|
36
|
+
def load_config(conf = CONFIG_FILE)
|
40
37
|
self.config = YAML.load_file(conf).freeze
|
41
38
|
rescue Errno::ENOENT
|
42
|
-
|
43
|
-
exit 1
|
39
|
+
puts_and_exit('Create config! Run: `yamg init`')
|
44
40
|
end
|
45
41
|
|
46
42
|
def load_images(dir)
|
47
43
|
return [dir] unless File.extname(dir).empty?
|
48
|
-
Dir["#{dir}/*.png"].map { |f| File.basename(f) }
|
44
|
+
Dir["#{dir}/*.{svg,png,jpg}"].map { |f| File.basename(f) }
|
49
45
|
end
|
50
46
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
47
|
+
def run(comm)
|
48
|
+
puts comm if debug
|
49
|
+
system(comm)
|
50
|
+
end
|
51
|
+
|
52
|
+
def run_rsvg(src, out, args = nil)
|
53
|
+
FileUtils.mkdir_p File.dirname(out)
|
54
|
+
run "rsvg-convert #{args} #{src} > #{out}"
|
55
|
+
end
|
56
|
+
|
57
|
+
|
58
|
+
def run_ffmpeg
|
59
|
+
end
|
60
|
+
|
61
|
+
def run_imagemagick(comm)
|
62
|
+
shell = MiniMagick::Shell.new #(whiny)
|
63
|
+
shell.run(comm).strip
|
64
|
+
end
|
65
|
+
|
66
|
+
def info(msg, color = :red)
|
67
|
+
return unless debug
|
68
|
+
puts Rainbow(msg).send(color)
|
69
|
+
end
|
70
|
+
|
71
|
+
def puts_and_exit(msg, color = :red)
|
59
72
|
puts
|
60
|
-
puts Rainbow(
|
61
|
-
|
73
|
+
puts Rainbow('---').black
|
74
|
+
puts Rainbow(msg).send(color)
|
75
|
+
exit color == :red ? 1 : 0
|
62
76
|
end
|
63
77
|
end
|
64
78
|
end
|
65
|
-
|
66
|
-
# },
|
67
|
-
# "customImages": [
|
68
|
-
# {
|
69
|
-
# "width": 120,
|
70
|
-
# "height": 120,
|
71
|
-
# "path": "../Media/custom",
|
72
|
-
# "filename": "outputFilename.png",
|
73
|
-
# "source": {
|
74
|
-
# "filename": "image.png",
|
75
|
-
# "background": "fff6d5"
|
76
|
-
# }
|
77
|
-
# }
|
78
|
-
# ],
|
79
|
-
# "screenshots": [
|
80
|
-
# {
|
81
|
-
# "url": "http://notabe.com",
|
82
|
-
# "name": "homepage"
|
83
|
-
# }
|
84
|
-
# ]
|
85
|
-
# }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: yamg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcos Piccinini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mini_magick
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- Rakefile
|
72
72
|
- bin/yamg
|
73
73
|
- lib/yamg.rb
|
74
|
+
- lib/yamg/assets/dot.png
|
74
75
|
- lib/yamg/cli.rb
|
75
76
|
- lib/yamg/icon.rb
|
76
77
|
- lib/yamg/screenshot.rb
|