emojidex 0.2.1 → 0.2.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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e6f88686eccedc6de0ac1cc7fae3d7cbe5ecea2
|
4
|
+
data.tar.gz: 7c50835110dd0241205e3793b2a557cc1b31fce8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1f0bc60a900cdf724fc878d5b4c7cb0f13921c105c017a61ce9443ed920dc412717af1fd10a86f0b3ce513ac6192e209f93293e4dbc1670391e654a103e2107f
|
7
|
+
data.tar.gz: 088cdba0c8bed81cebee332c1bec647dbf41c797c4b7d9466a5a6d0dc764ae67c751752cc5b80f94c7ab34eaf85af60543f65d08e95833b4dff0d929889c7807
|
data/emojidex.gemspec
CHANGED
@@ -16,12 +16,14 @@ module Emojidex
|
|
16
16
|
include Emojidex::Data::CollectionAssetInformation
|
17
17
|
include Emojidex::Data::CollectionMojiData
|
18
18
|
attr_accessor :emoji, :categories,
|
19
|
-
:source_path, :vector_source_path, :raster_source_path
|
19
|
+
:source_path, :vector_source_path, :raster_source_path,
|
20
|
+
:r18 # set to true if collection contains R-18 emoji
|
20
21
|
|
21
22
|
# Initialize Collection. You can pass a list of emoji to seed the collection
|
22
23
|
def initialize(opts = {})
|
23
24
|
@emoji = {}
|
24
25
|
@raster_source_path = @vector_source_path = @source_path = nil
|
26
|
+
@r18 = opts[:r18] || false
|
25
27
|
if opts.include? :cache_path
|
26
28
|
setup_cache(opts[:cache_path])
|
27
29
|
opts.delete :cache_path
|
@@ -35,7 +37,7 @@ module Emojidex
|
|
35
37
|
|
36
38
|
# Loads an emoji collection on local storage
|
37
39
|
def load_local_collection(path)
|
38
|
-
@source_path =
|
40
|
+
@source_path = File.expand_path(path)
|
39
41
|
json = IO.read(@source_path + '/emoji.json')
|
40
42
|
list = JSON.parse(json, symbolize_names: true)
|
41
43
|
add_emoji(list)
|
@@ -134,11 +136,14 @@ module Emojidex
|
|
134
136
|
private
|
135
137
|
|
136
138
|
def _add_list(list)
|
139
|
+
return if list.nil?
|
137
140
|
list.each do |moji_info|
|
138
141
|
if moji_info.instance_of? Emojidex::Data::Emoji
|
142
|
+
next if @r18 == false && moji_info.r18 == true
|
139
143
|
@emoji[moji_info.code.to_sym] = moji_info.dup
|
140
144
|
@emoji[moji_info.code.to_sym].paths = get_paths(moji_info)
|
141
145
|
else
|
146
|
+
next if @r18 == false && moji_info.include?(:r18) && moji_info[:r18] == true
|
142
147
|
emoji = Emojidex::Data::Emoji.new moji_info
|
143
148
|
emoji.paths = get_paths(emoji)
|
144
149
|
@emoji[Emojidex.escape_code(emoji.code.to_s).to_sym] = emoji
|
@@ -43,15 +43,22 @@ module Emojidex
|
|
43
43
|
# (default is ENV['EMOJI_CACHE'] or '$HOME/.emoji_cache')
|
44
44
|
# formats: formats to cache (default is SVG only)
|
45
45
|
# sizes: sizes to cache (default is px32, but this is irrelivant for SVG)
|
46
|
+
def cache(options = {})
|
47
|
+
_cache(options)
|
48
|
+
cache_index
|
49
|
+
end
|
50
|
+
|
51
|
+
# Caches emoji to local emoji storage cache
|
52
|
+
# +regenerates checksums and paths
|
53
|
+
# Options:
|
54
|
+
# cache_path: manually specify cache location
|
55
|
+
# (default is ENV['EMOJI_CACHE'] or '$HOME/.emoji_cache')
|
56
|
+
# formats: formats to cache (default is SVG only)
|
57
|
+
# sizes: sizes to cache (default is px32, but this is irrelivant for SVG)
|
46
58
|
def cache!(options = {})
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
@emoji.values.each do |moji|
|
51
|
-
_svg_check_copy(moji) if formats.include? :svg
|
52
|
-
_raster_check_copy(moji, :png, sizes) if formats.include? :png
|
53
|
-
end
|
54
|
-
_process_download_queue
|
59
|
+
_cache(options)
|
60
|
+
generate_paths
|
61
|
+
generate_checksums
|
55
62
|
cache_index
|
56
63
|
end
|
57
64
|
|
@@ -63,7 +70,8 @@ module Emojidex
|
|
63
70
|
idx = Emojidex::Data::Collection.new
|
64
71
|
idx.load_local_collection(destination) if FileTest.exist? "#{destination}/emoji.json"
|
65
72
|
idx.add_emoji @emoji.values
|
66
|
-
File.open("#{destination}/emoji.json", 'w') { |f| f.write idx.emoji.values.to_json }
|
73
|
+
#File.open("#{destination}/emoji.json", 'w') { |f| f.write idx.emoji.values.to_json }
|
74
|
+
write_index(destination)
|
67
75
|
end
|
68
76
|
|
69
77
|
# [over]writes a sanitized index to the specified destination.
|
@@ -71,7 +79,11 @@ module Emojidex
|
|
71
79
|
def write_index(destination)
|
72
80
|
idx = @emoji.values.to_json
|
73
81
|
idx = JSON.parse idx
|
74
|
-
idx.each
|
82
|
+
idx.each do |moji|
|
83
|
+
moji['paths'] = nil
|
84
|
+
moji['local_checksums'] = nil
|
85
|
+
moji.delete_if { |_k, v| v.nil? }
|
86
|
+
end
|
75
87
|
File.open("#{destination}/emoji.json", 'w') { |f| f.write idx.to_json }
|
76
88
|
end
|
77
89
|
|
@@ -127,6 +139,17 @@ module Emojidex
|
|
127
139
|
dls << Thread.new { moji.cache(:png, sizes) } if formats.include? :png
|
128
140
|
dls.each(&:join)
|
129
141
|
end
|
142
|
+
|
143
|
+
def _cache(options)
|
144
|
+
setup_cache options[:cache_path]
|
145
|
+
formats = options[:formats] || Emojidex::Defaults.selected_formats
|
146
|
+
sizes = options[:sizes] || Emojidex::Defaults.selected_sizes
|
147
|
+
@emoji.values.each do |moji|
|
148
|
+
_svg_check_copy(moji) if formats.include? :svg
|
149
|
+
_raster_check_copy(moji, :png, sizes) if formats.include? :png
|
150
|
+
end
|
151
|
+
_process_download_queue
|
152
|
+
end
|
130
153
|
end
|
131
154
|
end
|
132
155
|
end
|
data/lib/emojidex/data/emoji.rb
CHANGED
@@ -6,7 +6,8 @@ module Emojidex
|
|
6
6
|
# emoji base class
|
7
7
|
class Emoji
|
8
8
|
attr_accessor :moji, :category, :code, :code_ja,
|
9
|
-
:unicode, :tags, :emoticon, :variants, :base
|
9
|
+
:unicode, :tags, :emoticon, :variants, :base,
|
10
|
+
:r18
|
10
11
|
|
11
12
|
include Emojidex::Data::EmojiAssetInformation
|
12
13
|
|
@@ -49,6 +50,7 @@ module Emojidex
|
|
49
50
|
@unicode = details[:unicode].to_s
|
50
51
|
@full_name = details[:full_name].to_s
|
51
52
|
@emoticon = details[:emoticon].to_s
|
53
|
+
@r18 = details[:r18] || false
|
52
54
|
end
|
53
55
|
|
54
56
|
def _init_descriptor_info(details)
|
@@ -37,6 +37,15 @@ module Emojidex
|
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
40
|
+
def blank_paths
|
41
|
+
@paths = {}
|
42
|
+
@paths[:svg] = nil
|
43
|
+
@paths[:png] = {}
|
44
|
+
Emojidex::Defaults.sizes.keys.each do |size|
|
45
|
+
@paths[:png][size] = nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
40
49
|
def fill_paths(paths)
|
41
50
|
@paths[:svg] = paths[:svg] if paths.include? :svg
|
42
51
|
return unless paths.include? :png
|
@@ -78,6 +78,15 @@ module Emojidex
|
|
78
78
|
end
|
79
79
|
col
|
80
80
|
end
|
81
|
+
|
82
|
+
def self._check_auth(opts)
|
83
|
+
if !(opts.include? :auth_token) && Emojidex::Client.USER.authorized?
|
84
|
+
opts[:username] = Emojidex::Client::USER.username
|
85
|
+
opts[:auth_token] = Emojidex::Client::USER.auth_token
|
86
|
+
end
|
87
|
+
|
88
|
+
opts
|
89
|
+
end
|
81
90
|
end
|
82
91
|
end
|
83
92
|
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.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rei Kagetsuki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|