emojidex-converter 0.0.1 → 0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eca96b398c96a4bea4792951d367c36f9f1c8852
4
- data.tar.gz: dae9f088cb49370d089f11a2e69d601d0ea5997f
3
+ metadata.gz: 24e45dc6b3dec2a38ceacbe368d2c3eafc7702e8
4
+ data.tar.gz: b58b995ecb7af840dc954a7a0910a78b134a378c
5
5
  SHA512:
6
- metadata.gz: 8e7b1f51c202e1cb931e68a13b92705175c29c9ec6280bc32e8a7ec7912e90c5af38808af192e600e328762c8f03fe45b788d7df07172b0a83a71786a6facf80
7
- data.tar.gz: 9e760bdf75c0a2074cdcaa0ab51acfe3f1935c810e8db719e2b00ac422699ad68d3ae52a1c4274f56444c1f1f98611be614df7cefb7b93dd3ad8d8e5ebb48665
6
+ metadata.gz: ae6186035b3952c32df12fb3d6ffdd5702e25e7666ca3219759cc4bf11e6c75d274b072b6ac72e277aec0f486ec5ae6cf2e83ce8bbb27042b02401544364ea90
7
+ data.tar.gz: 587bac316614d110a8686ef6b86e70426595b38e464ab59be98c909b306c834f7d6d0af7c3ef6136ffca62868d5478c6355bc460dfeb6a4d4583bc54b4f916ee
data/README.md CHANGED
@@ -1,5 +1,49 @@
1
1
  [![Build Status](https://travis-ci.org/Genshin/emojidex-converter.svg)](https://travis-ci.org/Genshin/emojidex-converter)
2
2
  Emojidex Converter
3
- ------------------
3
+ ==================
4
+ A set of tools for converting emoji arrays to and from vectors [SVG] and rasters [PNG].
4
5
 
5
- WIP
6
+ Requirements
7
+ ------------
8
+ Uses Phantom SVG, which in turn uses rapngasm.
9
+ rapngasm requires libapngasm to build, see instructions [here](https://github.com/apngasm/rapngasm).
10
+
11
+ Usage
12
+ -----
13
+ **Instantiation:**
14
+ The default destination will be your local emojidex cache (set with environment variable $EMOJI_CACHE, defaults to $HOME/.emojidex/cache) or the current directory if $EMOJI_CACHE is not set.
15
+ - You can specify the destination manually with an options hash key of :destination.
16
+ - You can sepcify your own sizes using a :sizes hash. The keys to the hash become the directory names.
17
+ ```ruby
18
+ converter = Emojidex::Converter.new(destination: "/output/destination/file/path", sizes: {super_huge: 2000, px12: 12})
19
+
20
+ # sizes and output destination can be changed after initialization as well
21
+ converter.destination = '/new/destination'
22
+ converter.sizes = {superTiny: 3, '720p': 720}
23
+ ```
24
+
25
+ **Pre-process SVG frames into animated SVGs:**
26
+ Used to compile folders with SVG frames and animation.json files into single key-framed SVG files. The pre-processor should be run on every collection directory with sub-directories containing SVG animation sources before rasterization.
27
+ ```ruby
28
+ converter.preprocess('/path/to/collection')
29
+ ```
30
+
31
+ **Convert an array of emoji with vector sources to rasters:**
32
+ The emoji array is an array of Emojidex::Emoji objects.
33
+ ```ruby
34
+ converter.rasterize(emoji_array, '/directory/with/SVG/sources')
35
+ ```
36
+
37
+ **Convert an Emojidex::Collection:**
38
+ Emojidex::Collection objects contain references to their source directories so you only need to pass the collection object.
39
+ ```ruby
40
+ converer.convert_collection(collection)
41
+ ```
42
+
43
+ Contributing
44
+ ------------
45
+ Fork, edit, commit, push, pull request!
46
+ emojidex-converter is a very primitivate, fairly single-purpose tool. If you can think of any features that could extend its functionality we'd love to see it!
47
+
48
+ ----
49
+ exmojidex-toolkit©2014 emojidex™/Genshin Souzou K.K. [Phantom Creation Inc.]
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'emojidex-converter'
3
- s.version = '0.0.1'
3
+ s.version = '0.0.2'
4
4
  s.license = 'Equivilent to emojidex-toolkit'
5
5
  s.summary = 'Image conversion modules for emojidex'
6
6
  s.description = 'Adds the convert method to Emojidex::Collection and Emojidex::Emoji, which\
@@ -9,10 +9,10 @@ module Emojidex
9
9
  px16: 16, px32: 32, px64: 64, px128: 128, px256: 256 }
10
10
  end
11
11
 
12
- attr_accessor :sizes, :formats, :location
12
+ attr_accessor :sizes, :destination
13
13
  def initialize(override = {})
14
14
  @sizes = override[:sizes] || Converter.default_sizes
15
- @path = File.expand_path(override[:destination] || ENV['EMOJI_CACHE'] || './')
15
+ @destination = File.expand_path(override[:destination] || ENV['EMOJI_CACHE'] || './')
16
16
  end
17
17
 
18
18
  def rasterize(emoji, source_dir)
@@ -20,7 +20,7 @@ module Emojidex
20
20
  phantom_svg = Phantom::SVG::Base.new("#{source_dir}/#{moji.code}.svg")
21
21
  @sizes.each do |key, val|
22
22
  # Create out directory.
23
- out_dir = "#{@path}/#{key}"
23
+ out_dir = "#{@destination}/#{key}"
24
24
  FileUtils.mkdir_p(out_dir)
25
25
 
26
26
  # Set size.
@@ -32,9 +32,13 @@ module Emojidex
32
32
  end
33
33
  end
34
34
 
35
- def preprocess(source_dir)
35
+ def rasterize_collection(collection)
36
+ rasterize(collection.emoji.values, collection.source_path)
37
+ end
38
+
39
+ def preprocess(path)
36
40
  preprocessor = Emojidex::Preprocessor.new
37
- preprocessor.compile_svg_animations(source_dir)
41
+ preprocessor.compile_svg_animations(path)
38
42
  end
39
43
  end
40
44
  end
@@ -51,4 +51,21 @@ describe Emojidex::Converter do
51
51
  expect(File.exist?("#{@destination}/px256/kiss.png")).to be_truthy
52
52
  end
53
53
  end
54
+
55
+ describe '.rasterize_collection' do
56
+ it 'converts an emojidex collection' do
57
+ setup_working_collection
58
+ converter.preprocess("#{@support_dir}/tmp/collection")
59
+ collection = Emojidex::Collection.new
60
+ collection.load_local_collection("#{@support_dir}/tmp/collection")
61
+ converter.rasterize_collection(collection)
62
+
63
+ expect(File.exist?("#{@destination}/ldpi/kiss.png")).to be_truthy
64
+ end
65
+ end
66
+
67
+ describe '.write_index' do
68
+ it 'writes an emojidex index (emoji.joson) at the destination' do
69
+ end
70
+ end
54
71
  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.1
4
+ version: 0.0.2
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-07-14 00:00:00.000000000 Z
12
+ date: 2014-07-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rsvg2