emojidex-converter 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +4 -3
- data/Guardfile +17 -34
- data/README.md +15 -4
- data/emojidex-converter.gemspec +2 -2
- data/lib/emojidex/converter.rb +21 -2
- data/lib/emojidex/preprocessor.rb +2 -2
- data/spec/converter_spec.rb +21 -18
- data/spec/spec_helper.rb +3 -1
- metadata +6 -7
- data/LICENSE.md +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76eaa52defa7cbbb6d31be156ed79139e8f19a86
|
4
|
+
data.tar.gz: 4de19d91db926a6ab641946e5c12b2f254a704e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b6ba1485af79445f478137447b75f3ceb8408323ca8da20879e1b382c67bf72dc23d6bbdb370ce580ca7f1cc0576fbf81c59dd29d2867a76ac889f8e48c6b67
|
7
|
+
data.tar.gz: 4eacecf737b222d86b19cbc750116646f37abcd4e815c614c15c43dd46074694cc9f182c2dbc54577e05f3ada2b6f23bf2ee3a8db32a99c83e7f36dd2c0bcf84
|
data/Gemfile
CHANGED
@@ -2,7 +2,8 @@ source 'http://rubygems.org'
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
gem 'emojidex', '~> 0.2.0'
|
5
|
+
#gem 'emojidex', '~> 0.2.0'
|
6
|
+
gem 'emojidex', path: '../emojidex'
|
6
7
|
|
7
8
|
group :development do
|
8
9
|
gem 'rb-inotify', require: false
|
@@ -11,10 +12,10 @@ group :development do
|
|
11
12
|
gem 'guard-rspec'
|
12
13
|
gem 'rubocop'
|
13
14
|
gem 'guard-rubocop'
|
15
|
+
|
16
|
+
gem 'emojidex-vectors', require: false
|
14
17
|
end
|
15
18
|
|
16
19
|
group :test do
|
17
|
-
gem 'coveralls', require: false
|
18
20
|
gem 'rspec'
|
19
|
-
gem 'webmock'
|
20
21
|
end
|
data/Guardfile
CHANGED
@@ -1,38 +1,21 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
group :red_green_refactor, halt_on_fail: true do
|
2
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
3
|
+
require "guard/rspec/dsl"
|
4
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
3
5
|
|
4
|
-
#
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
# installed the spring binstubs per the docs)
|
10
|
-
# * zeus: 'zeus rspec' (requires the server to be started separetly)
|
11
|
-
# * 'just' rspec: 'rspec'
|
12
|
-
guard :rspec, cmd: 'bundle exec rspec' do
|
13
|
-
watch(%r{^spec/.+_spec\.rb$})
|
14
|
-
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
15
|
-
watch('spec/spec_helper.rb') { "spec" }
|
6
|
+
# RSpec files
|
7
|
+
rspec = dsl.rspec
|
8
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
9
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
10
|
+
watch(rspec.spec_files)
|
16
11
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
22
|
-
watch('config/routes.rb') { "spec/routing" }
|
23
|
-
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
24
|
-
watch('spec/rails_helper.rb') { "spec" }
|
12
|
+
# Ruby files
|
13
|
+
ruby = dsl.ruby
|
14
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
15
|
+
end
|
25
16
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
watch(%r{^spec/acceptance/(.+)\.feature$})
|
31
|
-
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
32
|
-
end
|
33
|
-
|
34
|
-
|
35
|
-
guard :rubocop do
|
36
|
-
watch(%r{.+\.rb$})
|
37
|
-
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
17
|
+
guard :rubocop, all_on_start: false do
|
18
|
+
watch(%r{.+\.rb$})
|
19
|
+
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
20
|
+
end
|
38
21
|
end
|
data/README.md
CHANGED
@@ -3,6 +3,12 @@ Emojidex Converter
|
|
3
3
|
==================
|
4
4
|
A set of tools for converting emoji arrays to and from vectors [SVG] and rasters [PNG].
|
5
5
|
|
6
|
+
This tool is primarily for internal use. You can find converted assets here:
|
7
|
+
* Vectors: [emojidex-vectors](https://github.com/emojidex/emojidex-vectors)
|
8
|
+
* Rasters: [emojidex-rasters](https://github.com/emojidex/emojidex-rasters)
|
9
|
+
|
10
|
+
or on-line from the asset repository or CDN, [see documentation here](http://developer.emojidex.com/#assets)
|
11
|
+
|
6
12
|
Requirements
|
7
13
|
------------
|
8
14
|
Uses Phantom SVG, which in turn uses rapngasm.
|
@@ -14,10 +20,11 @@ Usage
|
|
14
20
|
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
21
|
- You can specify the destination manually with an options hash key of :destination.
|
16
22
|
- You can sepcify your own sizes using a :sizes hash. The keys to the hash become the directory names.
|
23
|
+
|
17
24
|
```ruby
|
18
25
|
converter = Emojidex::Converter.new(destination: "/output/destination/file/path", sizes: {super_huge: 2000, px12: 12})
|
19
|
-
|
20
|
-
#
|
26
|
+
|
27
|
+
# Sizes and output destination can be changed after initialization:
|
21
28
|
converter.destination = '/new/destination'
|
22
29
|
converter.sizes = {superTiny: 3, '720p': 720}
|
23
30
|
```
|
@@ -45,5 +52,9 @@ Contributing
|
|
45
52
|
Fork, edit, commit, push, pull request!
|
46
53
|
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
54
|
|
48
|
-
|
49
|
-
|
55
|
+
License
|
56
|
+
=======
|
57
|
+
emojidex and emojidex tools are licensed under the
|
58
|
+
[emojidex Open License](https://www.emojidex.com/emojidex/emojidex_open_license).
|
59
|
+
|
60
|
+
©2013 the emojidex project / Genshin Souzou K.K. [Phantom Creation Inc.]
|
data/emojidex-converter.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'emojidex-converter'
|
3
|
-
s.version = '0.
|
3
|
+
s.version = '0.3.0'
|
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\
|
@@ -17,6 +17,6 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.add_dependency 'rapngasm'
|
18
18
|
s.add_dependency 'nokogiri'
|
19
19
|
s.add_dependency 'cairo'
|
20
|
-
s.add_dependency 'emojidex'
|
20
|
+
s.add_dependency 'emojidex', '~> 0.3'
|
21
21
|
s.add_dependency 'phantom_svg'
|
22
22
|
end
|
data/lib/emojidex/converter.rb
CHANGED
@@ -18,6 +18,7 @@ module Emojidex
|
|
18
18
|
|
19
19
|
start_time = Time.now
|
20
20
|
emoji.each do |moji|
|
21
|
+
puts "Source: #{source_dir}/#{moji.code}.svg" if @noisy
|
21
22
|
render_threads = []
|
22
23
|
@sizes.each do |key, val|
|
23
24
|
render_threads << Thread.new do
|
@@ -30,6 +31,7 @@ module Emojidex
|
|
30
31
|
phantom_svg.save_apng("#{out_dir}/#{moji.code}.png")
|
31
32
|
phantom_svg.reset
|
32
33
|
phantom_svg = nil
|
34
|
+
moji.paths[:png][key] = "#{out_dir}/#{moji.code}.png"
|
33
35
|
end
|
34
36
|
end
|
35
37
|
render_threads.each { |th| th.join }
|
@@ -43,7 +45,21 @@ module Emojidex
|
|
43
45
|
|
44
46
|
def rasterize_collection(collection)
|
45
47
|
rasterize(collection.emoji.values, collection.source_path)
|
46
|
-
collection.
|
48
|
+
collection.generate_checksums
|
49
|
+
puts "Rasterization completed. Writing index." if @noisy
|
50
|
+
collection.write_index @destination
|
51
|
+
|
52
|
+
puts "Re-opening collection at #{@destination} to generate meta data" if @noisy
|
53
|
+
converted_collection = Emojidex::Data::Collection.new(local_load_path: @destination)
|
54
|
+
converted_collection.raster_source_path = @destination
|
55
|
+
converted_collection.generate_paths
|
56
|
+
|
57
|
+
puts "Generating checksums..." if @noisy
|
58
|
+
converted_collection.generate_checksums
|
59
|
+
|
60
|
+
puts "Checksums generated. Writing index to emoji.json..." if @noisy
|
61
|
+
converted_collection.write_index @destination
|
62
|
+
converted_collection
|
47
63
|
end
|
48
64
|
|
49
65
|
def preprocess(path)
|
@@ -54,8 +70,11 @@ module Emojidex
|
|
54
70
|
private
|
55
71
|
|
56
72
|
def _create_output_paths
|
57
|
-
@sizes.each do |key,
|
73
|
+
@sizes.each do |key, _val|
|
58
74
|
out_dir = "#{@destination}/#{key}"
|
75
|
+
puts "*Clearning #{@destination}/#{key}" if @noisy
|
76
|
+
FileUtils.rm_rf(out_dir)
|
77
|
+
puts "*Creating #{@destination}/#{key}" if @noisy
|
59
78
|
FileUtils.mkdir_p(out_dir)
|
60
79
|
end
|
61
80
|
end
|
@@ -7,13 +7,13 @@ module Emojidex
|
|
7
7
|
Dir.entries(path).each do |file|
|
8
8
|
current_path = "#{path}/#{file}"
|
9
9
|
next unless File.ftype(current_path) == 'directory'
|
10
|
-
|
10
|
+
_svg_compile(current_path) unless file.start_with?('.')
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
14
|
private
|
15
15
|
|
16
|
-
def
|
16
|
+
def _svg_compile(source_dir)
|
17
17
|
json_path = "#{source_dir}/animation.json"
|
18
18
|
|
19
19
|
return unless File.exist?(json_path)
|
data/spec/converter_spec.rb
CHANGED
@@ -28,41 +28,44 @@ describe Emojidex::Converter do
|
|
28
28
|
describe '.preprocess' do
|
29
29
|
it 'preprocesses folders with SVG frame and animation.json files into frame-animated SVGs' do
|
30
30
|
setup_working_collection
|
31
|
-
converter.preprocess("#{@
|
32
|
-
expect(File.exist?("#{@
|
31
|
+
converter.preprocess("#{@collection_out_path}")
|
32
|
+
expect(File.exist?("#{@collection_out_path}/heartbeat.svg")).to be true
|
33
33
|
end
|
34
34
|
end
|
35
35
|
|
36
36
|
describe '.rasterize' do
|
37
37
|
it 'converts base SVG from the source directory to PNG in the destination directory' do
|
38
38
|
setup_working_collection
|
39
|
-
converter.preprocess("#{@
|
39
|
+
converter.preprocess("#{@collection_out_path}")
|
40
40
|
converter.rasterize([Emojidex::Data::Emoji.new(code: 'kiss')],
|
41
|
-
"#{@
|
41
|
+
"#{@collection_out_path}")
|
42
42
|
|
43
|
-
expect(File.exist?("#{@destination}/ldpi/kiss.png")).to
|
44
|
-
expect(File.exist?("#{@destination}/mdpi/kiss.png")).to
|
45
|
-
expect(File.exist?("#{@destination}/hdpi/kiss.png")).to
|
46
|
-
expect(File.exist?("#{@destination}/xhdpi/kiss.png")).to
|
47
|
-
expect(File.exist?("#{@destination}/px8/kiss.png")).to
|
48
|
-
expect(File.exist?("#{@destination}/px16/kiss.png")).to
|
49
|
-
expect(File.exist?("#{@destination}/px32/kiss.png")).to
|
50
|
-
expect(File.exist?("#{@destination}/px64/kiss.png")).to
|
51
|
-
expect(File.exist?("#{@destination}/px128/kiss.png")).to
|
52
|
-
expect(File.exist?("#{@destination}/px256/kiss.png")).to
|
43
|
+
expect(File.exist?("#{@destination}/ldpi/kiss.png")).to be true
|
44
|
+
expect(File.exist?("#{@destination}/mdpi/kiss.png")).to be true
|
45
|
+
expect(File.exist?("#{@destination}/hdpi/kiss.png")).to be true
|
46
|
+
expect(File.exist?("#{@destination}/xhdpi/kiss.png")).to be true
|
47
|
+
expect(File.exist?("#{@destination}/px8/kiss.png")).to be true
|
48
|
+
expect(File.exist?("#{@destination}/px16/kiss.png")).to be true
|
49
|
+
expect(File.exist?("#{@destination}/px32/kiss.png")).to be true
|
50
|
+
expect(File.exist?("#{@destination}/px64/kiss.png")).to be true
|
51
|
+
expect(File.exist?("#{@destination}/px128/kiss.png")).to be true
|
52
|
+
expect(File.exist?("#{@destination}/px256/kiss.png")).to be true
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
56
|
describe '.rasterize_collection' do
|
57
57
|
it 'converts an emojidex collection' do
|
58
58
|
setup_working_collection
|
59
|
-
converter.preprocess(
|
60
|
-
collection = Emojidex::Data::Collection.new
|
61
|
-
|
62
|
-
converter.rasterize_collection(collection)
|
59
|
+
converter.preprocess(@collection_out_path)
|
60
|
+
collection = Emojidex::Data::Collection.new(local_load_path: @collection_out_path)
|
61
|
+
processed_collection = converter.rasterize_collection(collection)
|
63
62
|
|
64
63
|
expect(File.exist?("#{@destination}/ldpi/kiss.png")).to be_truthy
|
65
64
|
expect(File.exist?("#{@destination}/emoji.json")).to be_truthy
|
65
|
+
|
66
|
+
processed_collection.generate_checksums
|
67
|
+
puts "CHECKSUM IS #{collection.emoji.values.first.checksums[:png][:ldpi]}"
|
68
|
+
expect(processed_collection.emoji.values.first.checksums[:png][:ldpi]).to be_truthy
|
66
69
|
end
|
67
70
|
end
|
68
71
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'emojidex_converter'
|
2
2
|
require 'emojidex'
|
3
3
|
|
4
|
+
|
4
5
|
def setup_working_collection
|
5
6
|
@support_dir = File.expand_path('../support', __FILE__)
|
6
7
|
|
@@ -8,5 +9,6 @@ def setup_working_collection
|
|
8
9
|
FileUtils.mkdir_p("#{@support_dir}/tmp")
|
9
10
|
FileUtils.cp_r("#{@support_dir}/collection", "#{@support_dir}/tmp")
|
10
11
|
|
11
|
-
"#{@support_dir}/tmp/collection"
|
12
|
+
@collection_out_path = "#{@support_dir}/tmp/collection"
|
13
|
+
@collection_out_path
|
12
14
|
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.
|
4
|
+
version: 0.3.0
|
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: 2016-
|
12
|
+
date: 2016-05-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rsvg2
|
@@ -99,16 +99,16 @@ dependencies:
|
|
99
99
|
name: emojidex
|
100
100
|
requirement: !ruby/object:Gem::Requirement
|
101
101
|
requirements:
|
102
|
-
- - "
|
102
|
+
- - "~>"
|
103
103
|
- !ruby/object:Gem::Version
|
104
|
-
version: '0'
|
104
|
+
version: '0.3'
|
105
105
|
type: :runtime
|
106
106
|
prerelease: false
|
107
107
|
version_requirements: !ruby/object:Gem::Requirement
|
108
108
|
requirements:
|
109
|
-
- - "
|
109
|
+
- - "~>"
|
110
110
|
- !ruby/object:Gem::Version
|
111
|
-
version: '0'
|
111
|
+
version: '0.3'
|
112
112
|
- !ruby/object:Gem::Dependency
|
113
113
|
name: phantom_svg
|
114
114
|
requirement: !ruby/object:Gem::Requirement
|
@@ -140,7 +140,6 @@ files:
|
|
140
140
|
- ".travis.yml"
|
141
141
|
- Gemfile
|
142
142
|
- Guardfile
|
143
|
-
- LICENSE.md
|
144
143
|
- README.md
|
145
144
|
- Rakefile
|
146
145
|
- emojidex-converter.gemspec
|
data/LICENSE.md
DELETED