emojidex-static-collector 0.0.1 → 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/bin/emojidex-static-collector +7 -5
- data/emojidex-static-collector.gemspec +4 -4
- data/lib/emojidex_static_collector.rb +45 -15
- data/spec/emojidex_static_collector_spec.rb +18 -7
- metadata +21 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e9ffb813f3555a51b8fcdeec9e3e3e19492c843c
|
4
|
+
data.tar.gz: d6226db06139639a65bf25cbd56c5fd08dba8a6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6e00286c61492cf6461effd9aeacbe9d960d17828acead33a29ba970d8a8383f2b2668ad5fc01bb0c5849c99ff1350cd099006a2eacfd4b73b007f3b9b96ada0
|
7
|
+
data.tar.gz: d82cfdbd856b88266456048e083270ce83d332777aa926fa76932b7e792cb521d6ff30251cc0a8b21174b2f7065719e05fdcbe6639139876839bbdd97031f93f
|
@@ -3,10 +3,10 @@ require 'optparse'
|
|
3
3
|
require 'fileutils'
|
4
4
|
require_relative '../lib/emojidex_static_collector'
|
5
5
|
|
6
|
-
puts '⊂ em
|
6
|
+
puts '⊂ em😜🏼jidex Static Collector⊃'
|
7
7
|
|
8
8
|
# s:size, t:type, o:output
|
9
|
-
params = ARGV.getopts('s:t:o:h', 'utf-only', 'clean-cache')
|
9
|
+
params = ARGV.getopts('s:t:o:h', 'utf-only', 'uncategorized', 'clean-cache')
|
10
10
|
|
11
11
|
# Set params.
|
12
12
|
params['s'] = '256' if params['s'].nil?
|
@@ -23,8 +23,10 @@ if params['h']
|
|
23
23
|
" \"en\" (standard English codes)\n" \
|
24
24
|
" \"ja\" (Japanese codes)\n" \
|
25
25
|
" \"char\" (raw character codes)\n" \
|
26
|
-
" \"moji\" (moji code (
|
27
|
-
"
|
26
|
+
" \"moji\" (moji code (character code with Japanese category directories))\n" \
|
27
|
+
" \"unicode\" (unicode/utf code)\n" \
|
28
|
+
"--utf-only UTF/Unicode only (does not export Extended)\n" \
|
29
|
+
"--uncategorized doesn't separate emoji into categorized folders" \
|
28
30
|
else
|
29
31
|
# Create folder.
|
30
32
|
out_dir = File.expand_path(params['o'], __FILE__)
|
@@ -33,5 +35,5 @@ else
|
|
33
35
|
# Generate
|
34
36
|
collector = EmojidexStaticCollector.new
|
35
37
|
collector.generate(params['o'], params['s'].to_i, params['utf-only'],
|
36
|
-
params['t'].to_sym)
|
38
|
+
params['t'].to_sym, !(params['uncategorized']))
|
37
39
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'emojidex-static-collector'
|
3
|
-
s.version = '0.0
|
3
|
+
s.version = '0.2.0'
|
4
4
|
s.license = 'emojiOL'
|
5
5
|
s.summary = 'Create static collections from emojidex assets'
|
6
6
|
s.description = 'Generates PNG rasters from emojidex vectors in a ' \
|
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.executables << 'emojidex-static-collector'
|
15
15
|
s.homepage = 'http://developer.emojidex.com'
|
16
16
|
|
17
|
-
s.add_dependency 'emojidex'
|
18
|
-
s.add_dependency 'emojidex-vectors'
|
19
|
-
s.add_dependency 'emojidex-converter'
|
17
|
+
s.add_dependency 'emojidex', '~> 0.3', '~> 0.3.2'
|
18
|
+
s.add_dependency 'emojidex-vectors', '~> 1.0'
|
19
|
+
s.add_dependency 'emojidex-converter', '~> 0.3'
|
20
20
|
end
|
@@ -1,15 +1,17 @@
|
|
1
1
|
require 'emojidex-vectors'
|
2
2
|
require 'emojidex_converter'
|
3
|
-
require 'emojidex/
|
3
|
+
require 'emojidex/data/utf'
|
4
|
+
require 'emojidex/data/extended'
|
5
|
+
require 'emojidex/data/categories'
|
4
6
|
|
5
7
|
require 'fileutils'
|
6
8
|
|
7
9
|
# Generates static collections of emojidex assets
|
8
10
|
class EmojidexStaticCollector
|
9
11
|
def initialize
|
10
|
-
@utf = Emojidex::UTF.new
|
11
|
-
@extended = Emojidex::Extended.new
|
12
|
-
@categories = Emojidex::Categories.new
|
12
|
+
@utf = Emojidex::Data::UTF.new
|
13
|
+
@extended = Emojidex::Data::Extended.new
|
14
|
+
@categories = Emojidex::Data::Categories.new
|
13
15
|
end
|
14
16
|
|
15
17
|
# Generates a static collection
|
@@ -17,23 +19,29 @@ class EmojidexStaticCollector
|
|
17
19
|
# path: path to export to
|
18
20
|
# size: export size
|
19
21
|
# utf_only: weather or not to limit to unicode standard emoji
|
22
|
+
# categorized: put emoji in categorized folders
|
20
23
|
# code_type: can be
|
21
24
|
# :en (standard English codes)
|
22
25
|
# :ja (Japanese codes)
|
23
26
|
# :char (raw character codes)
|
24
27
|
# :moji (moji code (:char with Japanese category directories))
|
25
|
-
|
28
|
+
# :unicode (unicode codes as file names)
|
29
|
+
def generate(path = './', size = 64, utf_only = false, code_type = :en, categorized = true, clean_cache = true)
|
26
30
|
cache_dir = File.join(path, '.cache')
|
27
|
-
@utf.cache
|
28
|
-
@extended.cache
|
29
|
-
collection = Emojidex::Collection.new(
|
30
|
-
|
31
|
+
@utf.cache(cache_path: cache_dir, formats: [:svg])
|
32
|
+
@extended.cache(cache_path: cache_dir, formats: [:svg]) unless utf_only
|
33
|
+
collection = Emojidex::Data::Collection.new(local_load_path: "#{cache_dir}/emoji")
|
34
|
+
if categorized
|
35
|
+
_generate_categories(collection, path, size, code_type)
|
36
|
+
else
|
37
|
+
_generate_consolidated(collection, path, size, code_type)
|
38
|
+
end
|
31
39
|
FileUtils.rm_rf(cache_dir) if clean_cache
|
32
40
|
end
|
33
41
|
|
34
42
|
private
|
35
43
|
|
36
|
-
def _generate_categories(collection, path, size,
|
44
|
+
def _generate_categories(collection, path, size, code_type)
|
37
45
|
@categories.categories.each_value do |category|
|
38
46
|
cat_path = set_path(path, code_type, category)
|
39
47
|
FileUtils.mkdir_p cat_path
|
@@ -46,11 +54,17 @@ class EmojidexStaticCollector
|
|
46
54
|
end
|
47
55
|
end
|
48
56
|
|
57
|
+
def _generate_consolidated(collection, path, size, code_type)
|
58
|
+
puts "Processing Consolidated Collection"
|
59
|
+
puts "Collection emoji Count: #{collection.emoji.count}"
|
60
|
+
_write_emoji(path, collection, size, code_type)
|
61
|
+
end
|
62
|
+
|
49
63
|
def set_path(path, code_type, category)
|
50
64
|
cat_path = ''
|
51
65
|
if code_type == :ja || code_type == :moji
|
52
66
|
cat_path = File.join(path, category.ja)
|
53
|
-
elsif code_type == :en || code_type == :char
|
67
|
+
elsif code_type == :en || code_type == :char || :unicode
|
54
68
|
cat_path = File.join(path, category.en)
|
55
69
|
end
|
56
70
|
cat_path
|
@@ -67,10 +81,26 @@ class EmojidexStaticCollector
|
|
67
81
|
def _rename_files(path, collection, code_type)
|
68
82
|
collection.each do |emoji|
|
69
83
|
case code_type
|
70
|
-
when :ja then FileUtils.
|
71
|
-
when :moji
|
72
|
-
|
73
|
-
|
84
|
+
when :ja then FileUtils.cp "#{path}/working/#{emoji.code}.png", "#{path}/#{emoji.code_ja}.png"
|
85
|
+
when :moji
|
86
|
+
if emoji.moji.nil? || emoji.moji == ""
|
87
|
+
FileUtils.cp "#{path}/working/#{emoji.code}.png", "#{path}/#{emoji.code}.png"
|
88
|
+
else
|
89
|
+
FileUtils.cp "#{path}/working/#{emoji.code}.png", "#{path}/#{emoji.moji}.png"
|
90
|
+
end
|
91
|
+
when :en then FileUtils.cp "#{path}/working/#{emoji.code}.png", "#{path}/#{emoji.code}.png"
|
92
|
+
when :char
|
93
|
+
if emoji.moji.nil? || emoji.moji == ""
|
94
|
+
FileUtils.cp "#{path}/working/#{emoji.code}.png", "#{path}/#{emoji.code}.png"
|
95
|
+
else
|
96
|
+
FileUtils.cp "#{path}/working/#{emoji.code}.png", "#{path}/#{emoji.moji}.png"
|
97
|
+
end
|
98
|
+
when :unicode
|
99
|
+
if emoji.unicode.nil? || emoji.unicode == ""
|
100
|
+
FileUtils.cp "#{path}/working/#{emoji.code}.png", "#{path}/#{emoji.code}.png"
|
101
|
+
else
|
102
|
+
FileUtils.cp "#{path}/working/#{emoji.code}.png", "#{path}/#{emoji.unicode.to_s}.png"
|
103
|
+
end
|
74
104
|
end
|
75
105
|
end
|
76
106
|
FileUtils.rm_rf "#{path}/working/"
|
@@ -17,22 +17,33 @@ describe EmojidexStaticCollector do
|
|
17
17
|
expect(File.exist?(@tmpdir + '/emojidex/')).to be_truthy
|
18
18
|
end
|
19
19
|
|
20
|
-
it 'generates a collection of UTF only' do
|
21
|
-
expect(collector.generate(@tmpdir + '/UTF', 512, false)).to be_truthy
|
22
|
-
end
|
23
|
-
|
24
20
|
it '日本語のコードを使ってコレクションを作成する' do
|
25
|
-
expect(collector.generate(@tmpdir + '/日本語', 8,
|
21
|
+
expect(collector.generate(@tmpdir + '/日本語', 8, false, :ja)).to be_truthy
|
22
|
+
expect(File.exist?(@tmpdir + '/日本語/抽象物/18禁.png')).to be_truthy
|
23
|
+
expect(File.exist?(@tmpdir + '/日本語/抽象物/糞.png')).to be_truthy
|
26
24
|
end
|
27
25
|
|
28
26
|
it 'generates a collection using moji character codes' do
|
29
27
|
expect(collector.generate(@tmpdir + '/moji', 8, true, :moji)).to be_truthy
|
30
28
|
end
|
31
29
|
|
32
|
-
it 'generates a collection of UTF only, extended emoji
|
30
|
+
it 'generates a collection of UTF only, extended emoji should not be included' do
|
33
31
|
collector.generate(@tmpdir + '/UTF_only', 8, true, :en)
|
34
32
|
expect(File.exist?(@tmpdir + '/UTF_only/Faces/angry.png')).to be_truthy
|
35
|
-
expect(File.exist?(@tmpdir + '/UTF_only/
|
33
|
+
expect(File.exist?(@tmpdir + '/UTF_only/Abstract/shit.png')).to be_falsey
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'generates a collection with unicode codes as file names' do
|
37
|
+
collector.generate(@tmpdir + '/unicode', 8, false, :unicode)
|
38
|
+
expect(File.exist?(@tmpdir + '/unicode/Symbols/00ae.png')).to be_truthy
|
39
|
+
expect(File.exist?(@tmpdir + '/unicode/Abstract/shit.png')).to be_truthy
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'generates a collection, not sorted into categories, with unicode codes for file names' do
|
43
|
+
collector.generate(@tmpdir + '/uncategorized_charcodes', 300, false, :unicode, false)
|
44
|
+
expect(File.exist?(@tmpdir + '/uncategorized_charcodes/00ae.png')).to be_truthy
|
45
|
+
expect(File.exist?(@tmpdir + '/uncategorized_charcodes/0033-20e3.png')).to be_truthy
|
46
|
+
expect(File.exist?(@tmpdir + '/uncategorized_charcodes/shit.png')).to be_truthy
|
36
47
|
end
|
37
48
|
end
|
38
49
|
end
|
metadata
CHANGED
@@ -1,57 +1,63 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: emojidex-static-collector
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rei Kagetsuki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: emojidex
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '0'
|
19
|
+
version: '0.3'
|
20
|
+
- - "~>"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 0.3.2
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - "~>"
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0.3'
|
30
|
+
- - "~>"
|
25
31
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
32
|
+
version: 0.3.2
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: emojidex-vectors
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
|
-
- - "
|
37
|
+
- - "~>"
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
39
|
+
version: '1.0'
|
34
40
|
type: :runtime
|
35
41
|
prerelease: false
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
37
43
|
requirements:
|
38
|
-
- - "
|
44
|
+
- - "~>"
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
46
|
+
version: '1.0'
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: emojidex-converter
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
|
-
- - "
|
51
|
+
- - "~>"
|
46
52
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
53
|
+
version: '0.3'
|
48
54
|
type: :runtime
|
49
55
|
prerelease: false
|
50
56
|
version_requirements: !ruby/object:Gem::Requirement
|
51
57
|
requirements:
|
52
|
-
- - "
|
58
|
+
- - "~>"
|
53
59
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
60
|
+
version: '0.3'
|
55
61
|
description: Generates PNG rasters from emojidex vectors in a specified size and manually
|
56
62
|
sorts them into categorized folders.
|
57
63
|
email: info@emojidex.com
|
@@ -90,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
90
96
|
version: '0'
|
91
97
|
requirements: []
|
92
98
|
rubyforge_project:
|
93
|
-
rubygems_version: 2.
|
99
|
+
rubygems_version: 2.5.1
|
94
100
|
signing_key:
|
95
101
|
specification_version: 4
|
96
102
|
summary: Create static collections from emojidex assets
|