emojidex 0.3.5 → 0.4.0
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 +4 -4
- data/emojidex.gemspec +1 -1
- data/lib/emojidex/data/collection.rb +9 -0
- data/lib/emojidex/data/collection/asset_information.rb +40 -0
- data/lib/emojidex/data/emoji.rb +20 -1
- data/lib/emojidex/data/emoji/asset_information.rb +2 -0
- data/lib/emojidex/data/emoji/combination.rb +44 -0
- data/lib/emojidex/data/emoji/combination_asset_information.rb +92 -0
- data/lib/emojidex/data/emoji/combination_information.rb +40 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2e959579357aeba554ee22e943695350f4e8531e
|
4
|
+
data.tar.gz: 2a35e42c90834d6324fef0beabd2fbebfc728d09
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47764eda85a0f7fbb57db70dddbd267b377b7db322bb04c9f10d652bc3883d585467cf45ee7059cb144731787441c4a6f02dab6253becac0c443be4734ac6427
|
7
|
+
data.tar.gz: 2349ecb35576c0b56026905657c017848ee764cdf508bc4f89789905184998a138327e383c960272c320cf91da44ca2b1eee165a4cd1b267283bfc445bcd78f5
|
data/emojidex.gemspec
CHANGED
@@ -128,6 +128,7 @@ module Emojidex
|
|
128
128
|
_add_list(list)
|
129
129
|
categorize
|
130
130
|
associate_variants
|
131
|
+
associate_customizations
|
131
132
|
condense_moji_code_data
|
132
133
|
@emoji
|
133
134
|
end
|
@@ -174,6 +175,14 @@ module Emojidex
|
|
174
175
|
end
|
175
176
|
end
|
176
177
|
|
178
|
+
def associate_customizations
|
179
|
+
@emoji.values.each do |emoji_obj|
|
180
|
+
emoji_obj.combinations.each do |combo|
|
181
|
+
@emoji[combo.base.to_sym].add_customization(combo)
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
177
186
|
def _sub_search(list, criteria = {})
|
178
187
|
cr = criteria.shift
|
179
188
|
return list if cr.nil?
|
@@ -9,6 +9,9 @@ module Emojidex
|
|
9
9
|
sizes = Emojidex::Defaults.sizes)
|
10
10
|
@emoji.values.each do |moji|
|
11
11
|
moji.checksums = get_checksums(moji, formats, sizes)
|
12
|
+
moji.combinations.each do |combo|
|
13
|
+
combo.checksums = get_combo_checksums(moji, combo, formats, sizes)
|
14
|
+
end
|
12
15
|
end
|
13
16
|
end
|
14
17
|
|
@@ -25,9 +28,34 @@ module Emojidex
|
|
25
28
|
sums
|
26
29
|
end
|
27
30
|
|
31
|
+
def get_combo_checksums(moji, combo, formats = Emojidex::Defaults.formats,
|
32
|
+
sizes = Emojidex::Defaults.sizes)
|
33
|
+
sums = combo.generate_blank_entry_set
|
34
|
+
if formats.include? :svg
|
35
|
+
for i in 0..(combo.components.length - 1)
|
36
|
+
combo.components[i].each do |component|
|
37
|
+
sums[i][component][:svg] = _checksum_for_file("#{@vector_source_path}/#{combo.base}/#{i}/#{component}.svg")
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
if formats.include? :png
|
42
|
+
sizes.keys.each do |size|
|
43
|
+
for i in 0..(combo.components.length - 1)
|
44
|
+
combo.components[i].each do |component|
|
45
|
+
sums[i][component][:png] = _checksum_for_file("#{@raster_source_path}/#{size}/#{combo.base}/#{i}/#{component}.png")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
sums
|
51
|
+
end
|
52
|
+
|
28
53
|
def generate_paths(formats = Emojidex::Defaults.formats, sizes = Emojidex::Defaults.sizes)
|
29
54
|
@emoji.values.each do |moji|
|
30
55
|
moji.paths = get_paths(moji, formats, sizes)
|
56
|
+
moji.combinations.each do |combo|
|
57
|
+
combo.paths = get_combo_paths(moji, combo, formats, sizes)
|
58
|
+
end
|
31
59
|
end
|
32
60
|
end
|
33
61
|
|
@@ -58,6 +86,18 @@ module Emojidex
|
|
58
86
|
paths
|
59
87
|
end
|
60
88
|
|
89
|
+
def get_combo_paths(moji, combo, formats = Emojidex::Defaults.formats,
|
90
|
+
sizes = Emojidex::Defaults.sizes)
|
91
|
+
paths = combo.generate_blank_path_set
|
92
|
+
paths[:svg] = "#{@vector_source_path}/#{moji.code}"
|
93
|
+
if formats.include? :png
|
94
|
+
sizes.keys.each do |size|
|
95
|
+
paths[:png][size] = "#{@raster_source_path}/#{size}/#{moji.code}"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
paths
|
99
|
+
end
|
100
|
+
|
61
101
|
private
|
62
102
|
|
63
103
|
def _checksum_for_file(path)
|
data/lib/emojidex/data/emoji.rb
CHANGED
@@ -1,19 +1,33 @@
|
|
1
1
|
require_relative '../../emojidex'
|
2
|
+
require_relative 'emoji/combination_information'
|
2
3
|
require_relative 'emoji/asset_information'
|
3
4
|
|
4
5
|
module Emojidex
|
5
6
|
module Data
|
6
7
|
# emoji base class
|
7
8
|
class Emoji
|
9
|
+
# Attribute Definitions:
|
10
|
+
# * moji: the actual character code associated with this emoji (if any)
|
11
|
+
# * category: category this emoji belongs to (usually as defined by Unicode)
|
12
|
+
# * code: the "short code" for the emoji
|
13
|
+
# * code_ja: the Japanese version of the "short code"
|
14
|
+
# * unicode: a string representing the hex of the unicode characters with - between multiples
|
15
|
+
# * tags: the tags registered to this emoji (usually only from the service)
|
16
|
+
# * emoticon: the emoticon that maps to this emoji (rarely used/not recommended)
|
17
|
+
# * variants: different (variants) of the emoji EG: racial modifiers
|
18
|
+
# * base: the base variant EG: the base emoji without modifiers
|
19
|
+
# * r18: flag indicating adult content
|
8
20
|
attr_accessor :moji, :category, :code, :code_ja,
|
9
21
|
:unicode, :tags, :emoticon, :variants, :base,
|
10
22
|
:r18
|
11
23
|
|
24
|
+
include Emojidex::Data::EmojiCombinationInformation
|
12
25
|
include Emojidex::Data::EmojiAssetInformation
|
13
26
|
|
14
27
|
def initialize(details = {})
|
15
28
|
_init_identifier_info(details)
|
16
29
|
_init_descriptor_info(details)
|
30
|
+
init_combination_info(details)
|
17
31
|
init_asset_info(details)
|
18
32
|
end
|
19
33
|
|
@@ -22,7 +36,12 @@ module Emojidex
|
|
22
36
|
end
|
23
37
|
|
24
38
|
def to_json(*args)
|
25
|
-
to_hash
|
39
|
+
hash = to_hash
|
40
|
+
hash.each do |key, val|
|
41
|
+
hash.delete(key) if (val.instance_of?(Array) && val.length == 0)
|
42
|
+
hash.delete(key) if (val.instance_of?(String) && val == "")
|
43
|
+
end
|
44
|
+
hash.to_json(*args)
|
26
45
|
end
|
27
46
|
|
28
47
|
def to_hash
|
@@ -63,6 +63,7 @@ module Emojidex
|
|
63
63
|
Emojidex::Defaults.sizes.keys.each do |size|
|
64
64
|
@paths[:png][size] = paths[:png][size] if paths[:png].include? size
|
65
65
|
end
|
66
|
+
@combinations.each { |combo| combo.fill_paths(paths) }
|
66
67
|
@paths
|
67
68
|
end
|
68
69
|
|
@@ -112,6 +113,7 @@ module Emojidex
|
|
112
113
|
@paths[:png].keys.each do |size|
|
113
114
|
@checksums[:png][size] = _checksum_for_file(@paths[:png][size])
|
114
115
|
end
|
116
|
+
@combinations.each { |combo| combo.generate_checksums }
|
115
117
|
@checksums
|
116
118
|
end
|
117
119
|
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require_relative 'combination_asset_information.rb'
|
2
|
+
|
3
|
+
module Emojidex
|
4
|
+
module Data
|
5
|
+
# Combination information container
|
6
|
+
class Combination
|
7
|
+
# * base: the named base that this combination belongs to
|
8
|
+
# * combinations: combinations starting with this emoji; base/components/component order
|
9
|
+
# * cutomizations: emoji which start customization of this emoji (this is combination base)
|
10
|
+
attr_accessor :base, :component_layer_order, :components
|
11
|
+
|
12
|
+
include Emojidex::Data::EmojiCombinationAssetInformation
|
13
|
+
|
14
|
+
def initialize(code, combination_info, details = {})
|
15
|
+
@base = combination_info[:base]
|
16
|
+
|
17
|
+
@components = []
|
18
|
+
@components << [Emojidex.escape_code(code.to_s)]
|
19
|
+
combination_info[:components].each { |component_set| @components << component_set }
|
20
|
+
if combination_info.include? :component_layer_order
|
21
|
+
@component_layer_order = combination_info[:component_layer_order]
|
22
|
+
else
|
23
|
+
@component_layer_order = []
|
24
|
+
for i in 0..(@components.length - 1)
|
25
|
+
@component_layer_order << i
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
init_asset_info(details)
|
30
|
+
end
|
31
|
+
|
32
|
+
def to_json(options = {})
|
33
|
+
truncated_components = @components.dup
|
34
|
+
truncated_components.shift
|
35
|
+
{
|
36
|
+
base: @base,
|
37
|
+
component_layer_order: @component_layer_order,
|
38
|
+
components: truncated_components,
|
39
|
+
checksums: @checksums
|
40
|
+
}.to_json
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
require_relative '../../defaults'
|
3
|
+
|
4
|
+
module Emojidex
|
5
|
+
module Data
|
6
|
+
# Asset information for emoji
|
7
|
+
module EmojiCombinationAssetInformation
|
8
|
+
attr_accessor :checksums, :paths, :remote_checksums
|
9
|
+
|
10
|
+
def init_asset_info(details = {})
|
11
|
+
blank_paths
|
12
|
+
blank_checksums
|
13
|
+
fill_remote_checksums(details[:checksums]) if details.include? :checksums
|
14
|
+
end
|
15
|
+
|
16
|
+
def generate_blank_entry_set
|
17
|
+
entry_set = []
|
18
|
+
@components.each do |component_set|
|
19
|
+
component_group = {}
|
20
|
+
component_set.each do |single_component|
|
21
|
+
component_group[single_component] = {}
|
22
|
+
component_group[single_component][:svg] = nil
|
23
|
+
component_group[single_component][:png] = {}
|
24
|
+
Emojidex::Defaults.sizes.keys.each do |size|
|
25
|
+
component_group[single_component][:png][size] = nil
|
26
|
+
end
|
27
|
+
end
|
28
|
+
entry_set << component_group
|
29
|
+
end
|
30
|
+
entry_set
|
31
|
+
end
|
32
|
+
|
33
|
+
def blank_paths
|
34
|
+
@paths = generate_blank_path_set
|
35
|
+
end
|
36
|
+
|
37
|
+
def generate_blank_path_set
|
38
|
+
paths = {}
|
39
|
+
paths[:svg] = nil
|
40
|
+
paths[:png] = {}
|
41
|
+
Emojidex::Defaults.sizes.keys.each do |size|
|
42
|
+
paths[:png][size] = nil
|
43
|
+
end
|
44
|
+
paths
|
45
|
+
end
|
46
|
+
|
47
|
+
def fill_paths(paths)
|
48
|
+
@paths = paths
|
49
|
+
@paths[:svg].slice!(/\.svg$/)
|
50
|
+
@paths[:png].each { |png| png.slice!(/\.png$/) }
|
51
|
+
end
|
52
|
+
|
53
|
+
def blank_checksums
|
54
|
+
@checksums = generate_blank_entry_set
|
55
|
+
@remote_checksums = generate_blank_entry_set
|
56
|
+
end
|
57
|
+
|
58
|
+
def generate_checksum(component_set_num, component_name, format, size = nil)
|
59
|
+
case format
|
60
|
+
when :png
|
61
|
+
return @checksums[component_set_num][component_name][:png][size] =
|
62
|
+
_checksum_for_file("#{@paths[:png][size]}/#{component_set_num}/#{component_name}.png")
|
63
|
+
when :svg
|
64
|
+
return @checksums[component_set_num][component_name][:svg] =
|
65
|
+
_checksum_for_file("#{@paths[:svg]}/#{component_set_num}/#{component_name}.svg")
|
66
|
+
end
|
67
|
+
nil
|
68
|
+
end
|
69
|
+
|
70
|
+
def generate_checksums
|
71
|
+
@components.each_with_index do |component_set, i|
|
72
|
+
component_set.each do |component_name|
|
73
|
+
generate_checksum(i, component_name, :svg)
|
74
|
+
@checksums[i][component_name][:png].keys.each do |size_key|
|
75
|
+
generate_checksum(i, component_name, :png, size_key)
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def fill_remote_checksums(checksums)
|
82
|
+
#todo once implemented in API
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
def _checksum_for_file(path)
|
88
|
+
(File.exist? path) ? Digest::MD5.file(path).hexdigest : nil
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative '../../defaults'
|
2
|
+
require_relative 'combination'
|
3
|
+
|
4
|
+
module Emojidex
|
5
|
+
module Data
|
6
|
+
# Combination information for emoji
|
7
|
+
module EmojiCombinationInformation
|
8
|
+
attr_accessor :combinations, :customizations
|
9
|
+
|
10
|
+
def init_combination_info(details)
|
11
|
+
_check_and_init_combinations
|
12
|
+
fill_combinations(details[:combinations]) if details.include? :combinations
|
13
|
+
end
|
14
|
+
|
15
|
+
def fill_combinations(combinations)
|
16
|
+
_check_and_init_combinations
|
17
|
+
combinations.each do |combination|
|
18
|
+
add_combination(combination)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def add_combination(combination_info)
|
23
|
+
_check_and_init_combinations
|
24
|
+
@combinations << Combination.new(@code, combination_info)
|
25
|
+
end
|
26
|
+
|
27
|
+
def add_customization(combo)
|
28
|
+
_check_and_init_combinations
|
29
|
+
@customizations << combo
|
30
|
+
@customizations.uniq!
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
def _check_and_init_combinations
|
35
|
+
@combinations = [] if @combinations.nil?
|
36
|
+
@customizations = [] if @customizations.nil?
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: emojidex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.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: 2017-01-
|
11
|
+
date: 2017-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -90,6 +90,9 @@ files:
|
|
90
90
|
- lib/emojidex/data/collection/static_collection.rb
|
91
91
|
- lib/emojidex/data/emoji.rb
|
92
92
|
- lib/emojidex/data/emoji/asset_information.rb
|
93
|
+
- lib/emojidex/data/emoji/combination.rb
|
94
|
+
- lib/emojidex/data/emoji/combination_asset_information.rb
|
95
|
+
- lib/emojidex/data/emoji/combination_information.rb
|
93
96
|
- lib/emojidex/data/extended.rb
|
94
97
|
- lib/emojidex/data/utf.rb
|
95
98
|
- lib/emojidex/defaults.rb
|
@@ -122,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
122
125
|
version: '0'
|
123
126
|
requirements: []
|
124
127
|
rubyforge_project:
|
125
|
-
rubygems_version: 2.
|
128
|
+
rubygems_version: 2.6.8
|
126
129
|
signing_key:
|
127
130
|
specification_version: 4
|
128
131
|
summary: emojidex Ruby tools
|