resper 0.2.0 → 0.2.1
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/bin/resper +7 -6
- data/lib/resper.rb +12 -7
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 115cb551addff325bb03c8593afeb7bd35d4f7e3
|
4
|
+
data.tar.gz: e9cc76adb903f63d183d9190156d7303669e7b91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08a7016668069c8aec451d74118fb6392ef4fcaf5fec8d88b85882acb140bb9723e271cc9ec7eb7bdffcd790c3a228013b47032d502617b153d800decab41b23'
|
7
|
+
data.tar.gz: 6db52f2f47d5ae3cfb86d1defeb978144e875e496ac091671842c4fec46e46235c5896607673e1a21f691f927d4c70b8cf6ef0543a64cea71b338f58356d3787
|
data/bin/resper
CHANGED
@@ -10,10 +10,12 @@ options.base_size = 20
|
|
10
10
|
options.input_file = 'example/icon.svg'
|
11
11
|
options.output_android = 'res'
|
12
12
|
options.output_ios = 'Images.xcassets'
|
13
|
-
options.
|
13
|
+
options.output_react = 'react'
|
14
14
|
options.format = 'svg'
|
15
15
|
options.image_set_type = :all
|
16
16
|
|
17
|
+
require 'resper'
|
18
|
+
|
17
19
|
OptionParser.new do |opts|
|
18
20
|
opts.banner = "Usage: resper [options]"
|
19
21
|
|
@@ -44,22 +46,21 @@ OptionParser.new do |opts|
|
|
44
46
|
opts.on("-p", "--ios", "Only iOS image assets will be created") do
|
45
47
|
options.image_set_type = :ios
|
46
48
|
end
|
47
|
-
opts.on("-r", "--
|
48
|
-
options.image_set_type = :
|
49
|
+
opts.on("-r", "--react", "Only React Native images will be created") do
|
50
|
+
options.image_set_type = :react
|
49
51
|
end
|
50
52
|
opts.on("-i", "--help", "Prints this help") do
|
53
|
+
puts "Resper version: #{Resper::VERSION}"
|
51
54
|
puts opts
|
52
55
|
exit
|
53
56
|
end
|
54
57
|
end.parse!
|
55
58
|
|
56
|
-
require 'resper'
|
57
|
-
|
58
59
|
options.base_width = options.base_size if options.base_width.nil?
|
59
60
|
options.base_height = options.base_size if options.base_height.nil?
|
60
61
|
|
61
62
|
abort unless File.exist? options.input_file
|
62
63
|
|
63
|
-
res = Resper::Parser.new options.image_set_type, options.input_file, options.base_width, options.base_height, [options.output_android, options.output_ios, options.
|
64
|
+
res = Resper::Parser.new options.image_set_type, options.input_file, options.base_width, options.base_height, [options.output_android, options.output_ios, options.output_react], options.format
|
64
65
|
|
65
66
|
res.parse_resources!
|
data/lib/resper.rb
CHANGED
@@ -8,7 +8,7 @@ Created on 2017-03-17
|
|
8
8
|
|
9
9
|
module Resper
|
10
10
|
|
11
|
-
VERSION = '0.2.
|
11
|
+
VERSION = '0.2.1'
|
12
12
|
|
13
13
|
require 'json'
|
14
14
|
require 'string'
|
@@ -54,9 +54,9 @@ module Resper
|
|
54
54
|
end
|
55
55
|
generate_universal_contents
|
56
56
|
end
|
57
|
-
if @type == :all || @type == :
|
57
|
+
if @type == :all || @type == :react
|
58
58
|
@@IOS_UNIVERSAL_SCALES.each do |scale|
|
59
|
-
file =
|
59
|
+
file = for_react scale[:s], scale[:o], scale[:d]
|
60
60
|
reduce_size file
|
61
61
|
end
|
62
62
|
end
|
@@ -75,10 +75,10 @@ module Resper
|
|
75
75
|
density: density, to: ios_output_path, name: ios_image_name(postfix)
|
76
76
|
end
|
77
77
|
|
78
|
-
def
|
79
|
-
path = @output[2]
|
80
|
-
name = "#{
|
81
|
-
name = "#{
|
78
|
+
def for_react factor, postfix, density
|
79
|
+
path = File.join(@output[2], 'img')
|
80
|
+
name = "#{react_image_name_without_ext}#{postfix}.png"
|
81
|
+
name = "#{react_image_name_without_ext}.png" if factor == 1
|
82
82
|
|
83
83
|
convert width: @width*factor, height: @height*factor, density: density, to: path, name: name
|
84
84
|
end
|
@@ -127,6 +127,11 @@ module Resper
|
|
127
127
|
name.split('_').map{|e| e.capitalize}.join
|
128
128
|
end
|
129
129
|
|
130
|
+
def react_image_name_without_ext
|
131
|
+
name = File.basename(@input, ".*").underscore
|
132
|
+
name.gsub "_", "-"
|
133
|
+
end
|
134
|
+
|
130
135
|
def android_output_path
|
131
136
|
@output[0]
|
132
137
|
end
|