emojidex-converter 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f1cc5b623be7c3f5821acc4f20b51aaa97d9cb33
4
- data.tar.gz: 84309a2a5ff49c71eb2d261d2a1a4dd1fdb97ad3
3
+ metadata.gz: 29a47a2247beb62b394b15ffaea318b73401c538
4
+ data.tar.gz: ae1dcaafb1209a572323ae4bca7d7adc5007e0ba
5
5
  SHA512:
6
- metadata.gz: 7e8c1099c78dcda6eed3149273c46a5980c0d85fd1b8657d29af46885532e1c316cbb8bf173be29b99d29d3d778df36b4ee9ab3886505ccdb86e4534764ec0ed
7
- data.tar.gz: 2f0908dac36d8597b09b7fd10a26504c79f4bd3be6a6b034db19481d31d29eb9e6d35a7f0470825689ead4832fc01ae2e109d7eaf0242a18bab5e385fa380a76
6
+ metadata.gz: e495bc673a905a2a7dda220021f6fa98db126dc59d421b2561aa551fe1524dbe11421fda9f750601af2dd9d508731c8f7178d4c4c45c068a8503dc994a4aabda
7
+ data.tar.gz: d3f965e7bc5416cea91458d5988da72e1221818c991602e7833ba427ec214081bcb884dbeda0df9c5c4b81f718505d5a43473e2c54858d21517c6c8d9e285709
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'emojidex-converter'
3
- s.version = '0.0.6'
3
+ s.version = '0.0.7'
4
4
  s.license = 'emojiOL'
5
5
  s.summary = 'Image conversion modules for emojidex'
6
6
  s.description = 'Adds the convert method to Emojidex::Collection and Emojidex::Emoji, which\
@@ -5,7 +5,7 @@ require_relative 'preprocessor'
5
5
  module Emojidex
6
6
  # Converter utility for emojidex
7
7
  class Converter
8
- attr_accessor :sizes, :destination
8
+ attr_accessor :sizes, :destination, :last_run_time
9
9
 
10
10
  def initialize(override = {})
11
11
  @sizes = override[:sizes] || Emojidex::Defaults.sizes
@@ -14,23 +14,31 @@ module Emojidex
14
14
  end
15
15
 
16
16
  def rasterize(emoji, source_dir)
17
+ _create_output_paths
18
+
19
+ start_time = Time.now
17
20
  emoji.each do |moji|
18
- phantom_svg = Phantom::SVG::Base.new("#{source_dir}/#{moji.code}.svg")
21
+ render_threads = []
19
22
  @sizes.each do |key, val|
20
- # Create out directory.
21
- out_dir = "#{@destination}/#{key}"
22
- FileUtils.mkdir_p(out_dir)
23
-
24
- # Set size.
25
- phantom_svg.width = phantom_svg.height = val.to_i
26
-
27
- # Output png.
28
- puts "Converting: #{out_dir}/#{moji.code}.png" if @noisy
29
- phantom_svg.save_apng("#{out_dir}/#{moji.code}.png")
23
+ render_threads << Thread.new do
24
+ out_dir = "#{@destination}/#{key}"
25
+ phantom_svg = Phantom::SVG::Base.new("#{source_dir}/#{moji.code}.svg")
26
+ # Set size.
27
+ phantom_svg.width = phantom_svg.height = val.to_i
28
+ # Render PNGs
29
+ puts "Converting: #{out_dir}/#{moji.code}.png" if @noisy
30
+ phantom_svg.save_apng("#{out_dir}/#{moji.code}.png")
31
+ phantom_svg.reset
32
+ phantom_svg = nil
33
+ end
30
34
  end
31
- phantom_svg.reset
35
+ render_threads.each {|th| th.join }
32
36
  GC.start
33
37
  end
38
+
39
+ run_time = Time.now - start_time
40
+ puts "Total Converstion Time: #{run_time}" if @noisy
41
+ @last_run_time = run_time
34
42
  end
35
43
 
36
44
  def rasterize_collection(collection)
@@ -42,5 +50,14 @@ module Emojidex
42
50
  preprocessor = Emojidex::Preprocessor.new
43
51
  preprocessor.compile_svg_animations(path)
44
52
  end
53
+
54
+ private
55
+
56
+ def _create_output_paths
57
+ @sizes.each do |key, val|
58
+ out_dir = "#{@destination}/#{key}"
59
+ FileUtils.mkdir_p(out_dir)
60
+ end
61
+ end
45
62
  end
46
63
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emojidex-converter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rei Kagetsuki
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-11-19 00:00:00.000000000 Z
12
+ date: 2014-12-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rsvg2