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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/bin/resper +7 -6
  3. data/lib/resper.rb +12 -7
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fa4f687987dac06025e377de87e6f2bff283fa09
4
- data.tar.gz: f999808785d3a1b73082a5b135e6c913ce118bcd
3
+ metadata.gz: 115cb551addff325bb03c8593afeb7bd35d4f7e3
4
+ data.tar.gz: e9cc76adb903f63d183d9190156d7303669e7b91
5
5
  SHA512:
6
- metadata.gz: a8181c6bbd295be2e08b588189acaa091505aaf543a4d79751f1eb1ee9bc6c0f0c16242c8a038878b6a217861899b1154cc2574dc37365118888ac3291ff123e
7
- data.tar.gz: 8ba411602a2a414808daf678a044f91ffd94ec95790f056f902bbf8466fa7f675bf9e98042e9ffcc0f68063c8669173d6b581f581d5949637e3ea4d2bde433ac
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.output_reactive = 'reactive'
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", "--reactive", "Only Reactive-Native images will be created") do
48
- options.image_set_type = :reactive
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.output_reactive], options.format
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!
@@ -8,7 +8,7 @@ Created on 2017-03-17
8
8
 
9
9
  module Resper
10
10
 
11
- VERSION = '0.2.0'
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 == :reactive
57
+ if @type == :all || @type == :react
58
58
  @@IOS_UNIVERSAL_SCALES.each do |scale|
59
- file = for_reactive scale[:s], scale[:o], scale[:d]
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 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
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resper
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikolay Moskvin