resper 0.1.5 → 0.2.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 +11 -0
- data/bin/resper +12 -1
- data/lib/resper.rb +30 -11
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fa4f687987dac06025e377de87e6f2bff283fa09
|
4
|
+
data.tar.gz: f999808785d3a1b73082a5b135e6c913ce118bcd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a8181c6bbd295be2e08b588189acaa091505aaf543a4d79751f1eb1ee9bc6c0f0c16242c8a038878b6a217861899b1154cc2574dc37365118888ac3291ff123e
|
7
|
+
data.tar.gz: 8ba411602a2a414808daf678a044f91ffd94ec95790f056f902bbf8466fa7f675bf9e98042e9ffcc0f68063c8669173d6b581f581d5949637e3ea4d2bde433ac
|
data/README.md
CHANGED
@@ -18,6 +18,8 @@ Hooray!
|
|
18
18
|
|
19
19
|
## Installation
|
20
20
|
|
21
|
+
### Mac
|
22
|
+
|
21
23
|
```
|
22
24
|
brew remove imagemagick
|
23
25
|
brew install imagemagick --with-librsvg
|
@@ -25,6 +27,15 @@ brew install pngquant
|
|
25
27
|
gem install resper
|
26
28
|
```
|
27
29
|
|
30
|
+
### Linux
|
31
|
+
|
32
|
+
```
|
33
|
+
sudo apt-get update
|
34
|
+
sudo apt-get install imagemagick
|
35
|
+
sudo apt-get install pngquant
|
36
|
+
gem install resper
|
37
|
+
```
|
38
|
+
|
28
39
|
## Usage
|
29
40
|
|
30
41
|
```
|
data/bin/resper
CHANGED
@@ -10,7 +10,9 @@ 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.output_reactive = 'reactive'
|
13
14
|
options.format = 'svg'
|
15
|
+
options.image_set_type = :all
|
14
16
|
|
15
17
|
OptionParser.new do |opts|
|
16
18
|
opts.banner = "Usage: resper [options]"
|
@@ -36,6 +38,15 @@ OptionParser.new do |opts|
|
|
36
38
|
opts.on("-aOUTPUT_IOS", "--output-ios=OUTPUT_IOS", "Output iOS folder, default: Images.xcassets") do |opt|
|
37
39
|
options.output_ios = opt
|
38
40
|
end
|
41
|
+
opts.on("-d", "--android", "Only Android image resources will be created") do
|
42
|
+
options.image_set_type = :android
|
43
|
+
end
|
44
|
+
opts.on("-p", "--ios", "Only iOS image assets will be created") do
|
45
|
+
options.image_set_type = :ios
|
46
|
+
end
|
47
|
+
opts.on("-r", "--reactive", "Only Reactive-Native images will be created") do
|
48
|
+
options.image_set_type = :reactive
|
49
|
+
end
|
39
50
|
opts.on("-i", "--help", "Prints this help") do
|
40
51
|
puts opts
|
41
52
|
exit
|
@@ -49,6 +60,6 @@ options.base_height = options.base_size if options.base_height.nil?
|
|
49
60
|
|
50
61
|
abort unless File.exist? options.input_file
|
51
62
|
|
52
|
-
res = Resper::Parser.new options.input_file, options.base_width, options.base_height, [options.output_android, options.output_ios], options.format
|
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.output_reactive], options.format
|
53
64
|
|
54
65
|
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.
|
11
|
+
VERSION = '0.2.0'
|
12
12
|
|
13
13
|
require 'json'
|
14
14
|
require 'string'
|
@@ -29,7 +29,8 @@ module Resper
|
|
29
29
|
{s: 3.0, d: 480, o: '@3x'},
|
30
30
|
]
|
31
31
|
|
32
|
-
def initialize input, width, height, output, format
|
32
|
+
def initialize type, input, width, height, output, format
|
33
|
+
@type = type
|
33
34
|
@input = input
|
34
35
|
@width = width
|
35
36
|
@height = height
|
@@ -38,17 +39,27 @@ module Resper
|
|
38
39
|
end
|
39
40
|
|
40
41
|
def parse_resources!
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
42
|
+
if @type == :all || @type == :android
|
43
|
+
@@ANDROID_SCALES.each do |scale|
|
44
|
+
file = for_android w: scale[:s]*@width, h: scale[:s]*@height,
|
45
|
+
d: scale[:d], o: "drawable-#{scale[:o]}"
|
46
|
+
reduce_size file
|
47
|
+
end
|
45
48
|
end
|
46
49
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
+
if @type == :all || @type == :ios
|
51
|
+
@@IOS_UNIVERSAL_SCALES.each do |scale|
|
52
|
+
file = for_ios scale[:s], scale[:o], scale[:d]
|
53
|
+
reduce_size file
|
54
|
+
end
|
55
|
+
generate_universal_contents
|
56
|
+
end
|
57
|
+
if @type == :all || @type == :reactive
|
58
|
+
@@IOS_UNIVERSAL_SCALES.each do |scale|
|
59
|
+
file = for_reactive scale[:s], scale[:o], scale[:d]
|
60
|
+
reduce_size file
|
61
|
+
end
|
50
62
|
end
|
51
|
-
generate_universal_contents
|
52
63
|
|
53
64
|
end
|
54
65
|
|
@@ -63,7 +74,15 @@ module Resper
|
|
63
74
|
convert width: @width*factor, height: @height*factor,
|
64
75
|
density: density, to: ios_output_path, name: ios_image_name(postfix)
|
65
76
|
end
|
66
|
-
|
77
|
+
|
78
|
+
def for_reactive factor, postfix, density
|
79
|
+
path = @output[2]
|
80
|
+
name = "#{ios_image_name_without_ext}#{postfix}.png"
|
81
|
+
name = "#{ios_image_name_without_ext}.png" if factor == 1
|
82
|
+
|
83
|
+
convert width: @width*factor, height: @height*factor, density: density, to: path, name: name
|
84
|
+
end
|
85
|
+
|
67
86
|
def generate_universal_contents
|
68
87
|
images = @@IOS_UNIVERSAL_SCALES.map do |scale|
|
69
88
|
{
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nikolay Moskvin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
137
|
version: 1.3.5
|
138
138
|
requirements: []
|
139
139
|
rubyforge_project:
|
140
|
-
rubygems_version: 2.6.
|
140
|
+
rubygems_version: 2.6.12
|
141
141
|
signing_key:
|
142
142
|
specification_version: 4
|
143
143
|
summary: There is tool for extracting vector graphic resources to Android and iOS
|