favicon_maker 1.2.1 → 1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/favicon_maker.rb +4 -1
- data/lib/favicon_maker/base_command.rb +30 -0
- data/lib/favicon_maker/creator.rb +13 -56
- data/lib/favicon_maker/generator.rb +1 -1
- data/lib/favicon_maker/ico_command.rb +25 -0
- data/lib/favicon_maker/png_command.rb +19 -0
- data/lib/favicon_maker/version.rb +2 -2
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9f56d73840c0d1a741f3eb58b7b429491fcdcc9
|
4
|
+
data.tar.gz: 658309f9a8a5841224b9be54f00f20b38f10c013
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f6a390aff4cc5751c65a73d5acef579e32d78b9ba4bd778aac642617de2e1d0f08189534605e3801ceff5c2ad9788fc9c0f38a79b4f5b433f68c27476df4c449
|
7
|
+
data.tar.gz: ebec04c983eb2ecc4ecaf9d72dc19bb713ed16a26618709f33635989d584d04a2c0eec8205be2d88eaab98813f9e0a10b240da5a28f49ba3694edf5cc380f46e
|
data/lib/favicon_maker.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
require "favicon_maker/maker_config"
|
2
2
|
require "favicon_maker/generator"
|
3
3
|
require "favicon_maker/creator"
|
4
|
-
require "favicon_maker/
|
4
|
+
require "favicon_maker/base_command"
|
5
|
+
require "favicon_maker/ico_command"
|
6
|
+
require "favicon_maker/png_command"
|
7
|
+
require "favicon_maker/input_validator"
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module BaseCommand
|
2
|
+
|
3
|
+
def run_convert(template_file_path, output_file_path, convert_settings, options, format, &block)
|
4
|
+
ico_cmd = [ "convert -background none #{options}".strip ]
|
5
|
+
ico_cmd += [ "\"#{template_file_path}\" #{options_to_args(convert_settings)}" ]
|
6
|
+
ico_cmd += yield([]) if block_given?
|
7
|
+
ico_cmd += [ " #{format}:\"#{output_file_path}\"" ]
|
8
|
+
@command = ico_cmd.join(' ')
|
9
|
+
end
|
10
|
+
|
11
|
+
def options_to_args(options)
|
12
|
+
return nil if options.nil?
|
13
|
+
options.map { |k,v|
|
14
|
+
if [ :xc, :null ].include?(k)
|
15
|
+
"#{k}:#{v}"
|
16
|
+
else
|
17
|
+
"-#{k} #{v}".strip
|
18
|
+
end
|
19
|
+
}.join(' ')
|
20
|
+
end
|
21
|
+
|
22
|
+
def on_windows?
|
23
|
+
(RbConfig::CONFIG['host_os'].match /mswin|mingw|cygwin/)
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_s
|
27
|
+
@command
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
@@ -4,7 +4,6 @@ module FaviconMaker
|
|
4
4
|
|
5
5
|
class Creator
|
6
6
|
RECENT_IM_VERSION = "6.8.0"
|
7
|
-
COLORSPACE_MIN_IM_VERSION = "6.7.5"
|
8
7
|
|
9
8
|
attr_accessor :template_file_path
|
10
9
|
attr_accessor :output_path
|
@@ -16,6 +15,7 @@ module FaviconMaker
|
|
16
15
|
@output_path = output_path
|
17
16
|
@options = options
|
18
17
|
@finished_block = finished_block
|
18
|
+
@command_set = []
|
19
19
|
|
20
20
|
im_version = fetch_image_magick_version
|
21
21
|
|
@@ -33,9 +33,14 @@ module FaviconMaker
|
|
33
33
|
|
34
34
|
validate_input(format, size)
|
35
35
|
|
36
|
-
|
36
|
+
@command_set << [ generate_command(template_file_path, output_file_path, size, format), output_file_path, template_file_path ]
|
37
|
+
end
|
37
38
|
|
38
|
-
|
39
|
+
def run
|
40
|
+
@command_set.map do |cmd, output_file_path, template_file_path|
|
41
|
+
`#{cmd}`
|
42
|
+
finished_block.call(output_file_path, template_file_path) if finished_block
|
43
|
+
end
|
39
44
|
end
|
40
45
|
|
41
46
|
private
|
@@ -65,56 +70,12 @@ module FaviconMaker
|
|
65
70
|
matches[1] if matches
|
66
71
|
end
|
67
72
|
|
68
|
-
def
|
73
|
+
def generate_command(template_file_path, output_file_path, size, format)
|
74
|
+
args = template_file_path, output_file_path, size, @options
|
69
75
|
case format.to_sym
|
70
|
-
when :png
|
71
|
-
|
72
|
-
|
73
|
-
[ :format, "png" ],
|
74
|
-
[ :resize, size ],
|
75
|
-
[ :gravity, "center" ],
|
76
|
-
[ :background, "none" ],
|
77
|
-
[ :extent, size ],
|
78
|
-
]
|
79
|
-
|
80
|
-
run_convert(template_file_path, convert_settings, output_file_path, format)
|
81
|
-
when :ico
|
82
|
-
convert_settings = [
|
83
|
-
[ :quiet, nil ],
|
84
|
-
]
|
85
|
-
|
86
|
-
center_settings = [
|
87
|
-
[ :gravity, "center" ],
|
88
|
-
[ :background, "none" ],
|
89
|
-
]
|
90
|
-
|
91
|
-
run_convert(template_file_path, convert_settings, output_file_path, format) do |ico_cmd|
|
92
|
-
escapes = "\\" unless on_windows?
|
93
|
-
size.split(',').sort_by{|s| s.split('x')[0].to_i}.each do |s|
|
94
|
-
ico_cmd << "#{escapes}( -clone 0 -resize #{s} #{options_to_args(center_settings)} -extent #{s} #{escapes}) "
|
95
|
-
end
|
96
|
-
ico_cmd << "-delete 0"
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
def run_convert(template_file_path, convert_settings, output_file_path, format, &block)
|
102
|
-
ico_cmd = "convert -background none #{@options} "
|
103
|
-
ico_cmd << "\"#{template_file_path}\" #{options_to_args(convert_settings)} "
|
104
|
-
ico_cmd = yield(ico_cmd) if block_given?
|
105
|
-
ico_cmd << " #{format}:\"#{output_file_path}\""
|
106
|
-
print `#{ico_cmd}`
|
107
|
-
end
|
108
|
-
|
109
|
-
def options_to_args(options)
|
110
|
-
return nil if options.nil?
|
111
|
-
options.map { |k,v|
|
112
|
-
if [ :xc, :null ].include?(k)
|
113
|
-
"#{k}:#{v}"
|
114
|
-
else
|
115
|
-
"-#{k} #{v}"
|
116
|
-
end
|
117
|
-
}.join(' ')
|
76
|
+
when :png then PngCommand.new(*args)
|
77
|
+
when :ico then IcoCommand.new(*args)
|
78
|
+
end.to_s
|
118
79
|
end
|
119
80
|
|
120
81
|
def print_image_magick_ancient_version_warning
|
@@ -126,10 +87,6 @@ module FaviconMaker
|
|
126
87
|
puts "FaviconMaker: WARNING! The version of your installed ImageMagick could not be detected!"
|
127
88
|
end
|
128
89
|
|
129
|
-
def on_windows?
|
130
|
-
(RbConfig::CONFIG['host_os'].match /mswin|mingw|cygwin/)
|
131
|
-
end
|
132
|
-
|
133
90
|
end
|
134
91
|
|
135
92
|
end
|
@@ -38,7 +38,7 @@ module FaviconMaker
|
|
38
38
|
creators.each do |template_filename, options_and_block|
|
39
39
|
template_file = File.join(template_dir, template_filename)
|
40
40
|
options, creator_block = *options_and_block
|
41
|
-
Docile.dsl_eval(Creator.new(template_file, output_dir, options, finished_block), &creator_block)
|
41
|
+
Docile.dsl_eval(Creator.new(template_file, output_dir, options, finished_block), &creator_block).run
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class IcoCommand
|
2
|
+
|
3
|
+
include ::BaseCommand
|
4
|
+
|
5
|
+
def initialize(template_file_path, output_file_path, size, options)
|
6
|
+
|
7
|
+
convert_settings = [
|
8
|
+
[ :quiet, nil ],
|
9
|
+
]
|
10
|
+
|
11
|
+
center_settings = [
|
12
|
+
[ :gravity, "center" ],
|
13
|
+
[ :background, "none" ],
|
14
|
+
]
|
15
|
+
|
16
|
+
run_convert(template_file_path, output_file_path, convert_settings, options, :ico) do |ico_cmd|
|
17
|
+
escapes = "\\" unless on_windows?
|
18
|
+
size.split(',').sort_by{|s| s.split('x')[0].to_i}.each do |s|
|
19
|
+
ico_cmd += [ "#{escapes}( -clone 0 -resize #{s} #{options_to_args(center_settings)} -extent #{s} #{escapes})" ]
|
20
|
+
end
|
21
|
+
ico_cmd += [ "-delete 0" ]
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class PngCommand
|
2
|
+
|
3
|
+
include ::BaseCommand
|
4
|
+
|
5
|
+
def initialize(template_file_path, output_file_path, size, options)
|
6
|
+
|
7
|
+
convert_settings = [
|
8
|
+
[ :define, "png:include-chunk=none,trns,gama" ],
|
9
|
+
[ :format, "png" ],
|
10
|
+
[ :resize, size ],
|
11
|
+
[ :gravity, "center" ],
|
12
|
+
[ :background, "none" ],
|
13
|
+
[ :extent, size ],
|
14
|
+
]
|
15
|
+
|
16
|
+
run_convert(template_file_path, output_file_path, convert_settings, options, :png)
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: favicon_maker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: '1.3'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andreas Follmann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-05-
|
11
|
+
date: 2014-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docile
|
@@ -75,10 +75,13 @@ files:
|
|
75
75
|
- README.md
|
76
76
|
- favicon_maker.gemspec
|
77
77
|
- lib/favicon_maker.rb
|
78
|
+
- lib/favicon_maker/base_command.rb
|
78
79
|
- lib/favicon_maker/creator.rb
|
79
80
|
- lib/favicon_maker/generator.rb
|
81
|
+
- lib/favicon_maker/ico_command.rb
|
80
82
|
- lib/favicon_maker/input_validator.rb
|
81
83
|
- lib/favicon_maker/maker_config.rb
|
84
|
+
- lib/favicon_maker/png_command.rb
|
82
85
|
- lib/favicon_maker/version.rb
|
83
86
|
- spec/favicon_maker_spec.rb
|
84
87
|
- spec/input_validator_spec.rb
|