emojidex 0.0.12 → 0.0.13

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: bfe7f958b3d9cddc8a46b7fd69a53f4d2033aa19
4
- data.tar.gz: 21a64c3586491ad787530f25c5b83f1a159955f8
3
+ metadata.gz: 7fb0e58cdb8f56bba4804967288937ce8563117e
4
+ data.tar.gz: aa853515d11aa563914eeed11a204abba89ef509
5
5
  SHA512:
6
- metadata.gz: 103138ff174c2e96d99e46d70c3beb0c171a13f0a07b25de739403ae2b7a94ddbe7836d94788367bbb15895462471b22e3158bb6d8b6529e8e8c93461d724dc4
7
- data.tar.gz: c871f112771225a548f95c79d4571b8c0cdf8e283172084d8804bbebb434b4b8ba6ff7706de372e9d33272f70d455a27236e97de249b01d6c76011b45ba0dd7d
6
+ metadata.gz: e8ae6c083e875c9aec163fcfd7aed042bee6b23a1d060de5ecc46d1c2bf99bbb427b367de57d2f860988e3af13c6e3f7caa51410805aa80d1ba5c9f45df85f57
7
+ data.tar.gz: 5d13c8f7bbca590ee2155fe0f2aafe5d0f3245f9cfa7029b575be4b79ae7e275c64dc5e005b038057eab794063e8f3c559eca2b8ae1b886f31b80a93b40a7a97
data/emojidex.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'emojidex'
3
- s.version = '0.0.12'
3
+ s.version = '0.0.13'
4
4
  s.license = 'GPL-3, AGPL-3'
5
5
  s.summary = 'emojidex Ruby tools'
6
6
  s.description = 'emojidex emoji handling, search and lookup, listing and caching functionality' \
@@ -11,11 +11,11 @@ module Emojidex
11
11
 
12
12
  def get_checksums(moji, formats, sizes)
13
13
  sums = {}
14
- sums[:svg] = _checksum_for_file("#{@vector_path}/#{moji.code}.svg") if formats.include? :svg
14
+ sums[:svg] = _checksum_for_file("#{@vector_source_path}/#{moji.code}.svg") if formats.include? :svg
15
15
  if formats.include? :png
16
16
  sums[:png] = {}
17
17
  sizes.keys.each do |size|
18
- sums[:png][size] = _checksum_for_file("#{@vector_path}/#{size}/#{moji.code}.png")
18
+ sums[:png][size] = _checksum_for_file("#{@raster_source_path}/#{size}/#{moji.code}.png")
19
19
  end
20
20
  end
21
21
  sums
@@ -29,12 +29,12 @@ module Emojidex
29
29
 
30
30
  def get_paths(moji, formats, sizes)
31
31
  paths = {}
32
- path = "#{@vector_path}/#{moji.code}.svg"
32
+ path = "#{@vector_source_path}/#{moji.code}.svg"
33
33
  paths[:svg] = path if File.exist? path
34
34
  if formats.include? :png
35
35
  paths[:png] = {}
36
36
  sizes.keys.each do |size|
37
- path = "#{@vector_path}/#{size}/#{moji.code}.png"
37
+ path = "#{@raster_source_path}/#{size}/#{moji.code}.png"
38
38
  paths[:png][size] = path if File.exist? path
39
39
  end
40
40
  end
@@ -47,6 +47,13 @@ module Emojidex
47
47
  end
48
48
  end
49
49
 
50
+ def write_index(destination)
51
+ idx = @emoji.values.to_json
52
+ idx = JSON.parse idx
53
+ idx.each { |moji| moji.delete_if{ |k, v| v.nil? }}
54
+ File.open("#{destination}/emoji.json", 'w') { |f| f.write idx.to_json }
55
+ end
56
+
50
57
  private
51
58
 
52
59
  def _svg_check_copy(moji)
@@ -23,8 +23,8 @@ module Emojidex
23
23
  # Loads an emoji collection on local storage
24
24
  def load_local_collection(path)
25
25
  @source_path = File.expand_path(path)
26
- @vector_path = @source_path if @vector_path.nil?
27
- @raster_path = @raster_path if @raster_path.nil?
26
+ @vector_source_path = @source_path if @vector_source_path.nil?
27
+ @raster_source_path = @source_path if @raster_source_path.nil?
28
28
  json = IO.read(@source_path + '/emoji.json')
29
29
  list = JSON.parse(json, symbolize_names: true)
30
30
  add_emoji(list)
@@ -82,6 +82,17 @@ describe Emojidex::Collection do
82
82
  end
83
83
  end
84
84
 
85
+ describe '.write_index' do
86
+ it 'writes a cleaned index to the specified location' do
87
+ tmp_cache_path = File.expand_path('../support/tmpcache', __FILE__)
88
+ FileUtils.mkdir_p(tmp_cache_path)
89
+ collection.cache_index tmp_cache_path
90
+ expect(File.exist? tmp_cache_path + '/emoji.json').to be_truthy
91
+
92
+ FileUtils.rm_rf tmp_cache_path
93
+ end
94
+ end
95
+
85
96
  describe '.generate_checksums' do
86
97
  it 'generates checksums for assets' do
87
98
  expect(collection.generate_checksums).to be_an_instance_of(Array)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emojidex
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.12
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rei Kagetsuki