emojidex 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +4 -0
- data/Guardfile +0 -27
- data/README.md +1 -0
- data/emojidex.gemspec +1 -1
- data/lib/emojidex/collection.rb +21 -10
- data/lib/emojidex/collection/asset_information.rb +49 -0
- data/lib/emojidex/{cache.rb → collection/cache.rb} +2 -2
- data/lib/emojidex/collection_checker.rb +8 -6
- data/lib/emojidex/defaults.rb +1 -1
- data/lib/emojidex/emoji.rb +7 -35
- data/lib/emojidex/emoji/asset_information.rb +20 -0
- data/lib/emojidex/extended.rb +7 -3
- data/lib/emojidex/utf.rb +7 -3
- data/spec/collection_checker_spec.rb +9 -1
- data/spec/collection_spec.rb +108 -0
- data/spec/emoji_spec.rb +0 -16
- data/spec/spec_helper.rb +1 -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: bfe7f958b3d9cddc8a46b7fd69a53f4d2033aa19
|
4
|
+
data.tar.gz: 21a64c3586491ad787530f25c5b83f1a159955f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 103138ff174c2e96d99e46d70c3beb0c171a13f0a07b25de739403ae2b7a94ddbe7836d94788367bbb15895462471b22e3158bb6d8b6529e8e8c93461d724dc4
|
7
|
+
data.tar.gz: c871f112771225a548f95c79d4571b8c0cdf8e283172084d8804bbebb434b4b8ba6ff7706de372e9d33272f70d455a27236e97de249b01d6c76011b45ba0dd7d
|
data/.rubocop.yml
CHANGED
data/Guardfile
CHANGED
@@ -1,14 +1,3 @@
|
|
1
|
-
# A sample Guardfile
|
2
|
-
# More info at https://github.com/guard/guard#readme
|
3
|
-
|
4
|
-
# Note: The cmd option is now required due to the increasing number of ways
|
5
|
-
# rspec may be run, below are examples of the most common uses.
|
6
|
-
# * bundler: 'bundle exec rspec'
|
7
|
-
# * bundler binstubs: 'bin/rspec'
|
8
|
-
# * spring: 'bin/rsspec' (This will use spring if running and you have
|
9
|
-
# installed the spring binstubs per the docs)
|
10
|
-
# * zeus: 'zeus rspec' (requires the server to be started separetly)
|
11
|
-
# * 'just' rspec: 'rspec'
|
12
1
|
guard :rubocop do
|
13
2
|
watch(%r{.+\.rb$})
|
14
3
|
watch(%r{(?:.+/)?\.rubocop\.yml$}) { |m| File.dirname(m[0]) }
|
@@ -18,20 +7,4 @@ guard :rspec, cmd: 'bundle exec rspec' do
|
|
18
7
|
watch(%r{^spec/.+_spec\.rb$})
|
19
8
|
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
20
9
|
watch('spec/spec_helper.rb') { "spec" }
|
21
|
-
|
22
|
-
# Rails example
|
23
|
-
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
24
|
-
watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
25
|
-
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
26
|
-
watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
|
27
|
-
watch('config/routes.rb') { "spec/routing" }
|
28
|
-
watch('app/controllers/application_controller.rb') { "spec/controllers" }
|
29
|
-
watch('spec/rails_helper.rb') { "spec" }
|
30
|
-
|
31
|
-
# Capybara features specs
|
32
|
-
watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
|
33
|
-
|
34
|
-
# Turnip features and steps
|
35
|
-
watch(%r{^spec/acceptance/(.+)\.feature$})
|
36
|
-
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
37
10
|
end
|
data/README.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
[![Gem Version](https://badge.fury.io/rb/emojidex.png)](http://badge.fury.io/rb/emojidex)
|
2
2
|
[![Build Status](https://travis-ci.org/emojidex/emojidex.png)](https://travis-ci.org/emojidex/emojidex)
|
3
3
|
[![Code Climate](https://codeclimate.com/github/emojidex/emojidex.png)](https://codeclimate.com/github/emojidex/emojidex)
|
4
|
+
[![Gitter chat](https://badges.gitter.im/emojidex/emojidex.png)](https://gitter.im/emojidex/emojidex)
|
4
5
|
emojidex
|
5
6
|
========
|
6
7
|
emojidex core tools and scripts in Ruby. Provides a set of tools to utilize emojidex emoji right away in Ruby. Available as the "emojidex" gem.
|
data/emojidex.gemspec
CHANGED
data/lib/emojidex/collection.rb
CHANGED
@@ -3,38 +3,49 @@
|
|
3
3
|
require 'json'
|
4
4
|
require_relative 'emoji'
|
5
5
|
require_relative 'categories'
|
6
|
-
require_relative 'cache'
|
6
|
+
require_relative 'collection/cache'
|
7
|
+
require_relative 'collection/asset_information'
|
7
8
|
|
8
9
|
module Emojidex
|
9
10
|
# listing and search of standard UTF emoji
|
10
11
|
class Collection
|
11
|
-
include Emojidex::
|
12
|
+
include Emojidex::CollectionCache
|
13
|
+
include Emojidex::CollectionAssetInformation
|
12
14
|
attr_accessor :emoji, :categories
|
13
|
-
attr_reader :source_path
|
15
|
+
attr_reader :source_path, :vector_source_path, :raster_source_path
|
14
16
|
# Initialize Collection. You can pass a list of emoji to seed the collection
|
15
|
-
def initialize(emoji_list = nil)
|
17
|
+
def initialize(emoji_list = nil, local_load_path = nil)
|
16
18
|
@emoji = {}
|
19
|
+
load_local_collection(local_load_path) unless local_load_path.nil?
|
17
20
|
add_emoji(emoji_list) unless emoji_list.nil?
|
18
21
|
end
|
19
22
|
|
20
23
|
# Loads an emoji collection on local storage
|
21
24
|
def load_local_collection(path)
|
22
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?
|
23
28
|
json = IO.read(@source_path + '/emoji.json')
|
24
29
|
list = JSON.parse(json, symbolize_names: true)
|
25
30
|
add_emoji(list)
|
26
31
|
end
|
27
32
|
|
28
33
|
# each override to map each functionality to the emoji hash values
|
29
|
-
def each
|
30
|
-
|
31
|
-
@emoji.values.each { |emoji| yield emoji }
|
34
|
+
def each(&block)
|
35
|
+
@emoji.values.each(&block)
|
32
36
|
end
|
33
37
|
|
34
38
|
# select override to map select functionality to the emoji hash values
|
35
|
-
def select
|
36
|
-
|
37
|
-
|
39
|
+
def select(&block)
|
40
|
+
@emoji.values.select(&block)
|
41
|
+
end
|
42
|
+
|
43
|
+
def map(&block)
|
44
|
+
@emoji.values.map(&block)
|
45
|
+
end
|
46
|
+
|
47
|
+
def collect(&block)
|
48
|
+
@emoji.values.collect(&block)
|
38
49
|
end
|
39
50
|
|
40
51
|
# Retreives an Emoji object by the actual moji code/character code
|
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
|
3
|
+
module Emojidex
|
4
|
+
# Asset Information for Collections
|
5
|
+
module CollectionAssetInformation
|
6
|
+
def generate_checksums(formats = Emojidex::Defaults.formats, sizes = Emojidex::Defaults.sizes)
|
7
|
+
@emoji.values.each do |moji|
|
8
|
+
moji.checksums = get_checksums(moji, formats, sizes)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def get_checksums(moji, formats, sizes)
|
13
|
+
sums = {}
|
14
|
+
sums[:svg] = _checksum_for_file("#{@vector_path}/#{moji.code}.svg") if formats.include? :svg
|
15
|
+
if formats.include? :png
|
16
|
+
sums[:png] = {}
|
17
|
+
sizes.keys.each do |size|
|
18
|
+
sums[:png][size] = _checksum_for_file("#{@vector_path}/#{size}/#{moji.code}.png")
|
19
|
+
end
|
20
|
+
end
|
21
|
+
sums
|
22
|
+
end
|
23
|
+
|
24
|
+
def generate_paths(formats = Emojidex::Defaults.formats, sizes = Emojidex::Defaults.sizes)
|
25
|
+
@emoji.values.each do |moji|
|
26
|
+
moji.paths = get_paths(moji, formats, sizes)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def get_paths(moji, formats, sizes)
|
31
|
+
paths = {}
|
32
|
+
path = "#{@vector_path}/#{moji.code}.svg"
|
33
|
+
paths[:svg] = path if File.exist? path
|
34
|
+
if formats.include? :png
|
35
|
+
paths[:png] = {}
|
36
|
+
sizes.keys.each do |size|
|
37
|
+
path = "#{@vector_path}/#{size}/#{moji.code}.png"
|
38
|
+
paths[:png][size] = path if File.exist? path
|
39
|
+
end
|
40
|
+
end
|
41
|
+
paths
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
def _checksum_for_file(path)
|
46
|
+
(File.exist? path)? Digest::MD5.file(path).hexdigest : nil
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
require 'json'
|
2
|
-
require_relative 'defaults'
|
3
2
|
require 'fileutils'
|
3
|
+
require_relative '../defaults'
|
4
4
|
|
5
5
|
module Emojidex
|
6
6
|
# local caching functionality for collections
|
7
|
-
module
|
7
|
+
module CollectionCache
|
8
8
|
attr_reader :cache_path
|
9
9
|
|
10
10
|
def setup_cache(path = nil)
|
@@ -24,8 +24,8 @@ module Emojidex
|
|
24
24
|
|
25
25
|
def create_asset_file_list(dir, sizes, formats)
|
26
26
|
result = {}
|
27
|
-
result.merge!(create_file_list(dir, '.svg', '')) if formats.include?(
|
28
|
-
if formats.include?(
|
27
|
+
result.merge!(create_file_list(dir, '.svg', '')) if formats.include?(:svg)
|
28
|
+
if formats.include?(:png)
|
29
29
|
sizes.each do |size|
|
30
30
|
result.merge!(create_file_list("#{dir}/#{size}", '.png', "#{size}/"))
|
31
31
|
end
|
@@ -35,6 +35,7 @@ module Emojidex
|
|
35
35
|
|
36
36
|
def create_file_list(dir, ext, prefix)
|
37
37
|
result = {}
|
38
|
+
return result unless Dir.exists?(dir)
|
38
39
|
Dir.foreach(dir) do |file|
|
39
40
|
result["#{prefix}#{File.basename(file, '.*')}".to_sym] =
|
40
41
|
"#{prefix}#{file}" if File.extname(file) == ext
|
@@ -46,8 +47,8 @@ module Emojidex
|
|
46
47
|
collections.each do |collection|
|
47
48
|
collection.emoji.values.each do |emoji|
|
48
49
|
tmp = []
|
49
|
-
tmp += create_svg_array(emoji, asset_files) if formats.include?(
|
50
|
-
tmp += create_png_array(emoji, asset_files, sizes) if formats.include?(
|
50
|
+
tmp += create_svg_array(emoji, asset_files) if formats.include?(:svg)
|
51
|
+
tmp += create_png_array(emoji, asset_files, sizes) if formats.include?(:png)
|
51
52
|
@index_only[emoji.code.to_sym] = tmp unless tmp.empty?
|
52
53
|
end
|
53
54
|
end
|
@@ -55,7 +56,8 @@ module Emojidex
|
|
55
56
|
|
56
57
|
def create_svg_array(emoji, asset_files)
|
57
58
|
result = []
|
58
|
-
|
59
|
+
asset_file = asset_files[emoji.code.to_sym]
|
60
|
+
result << "#{emoji.code}.svg" if asset_files[emoji.code.to_sym].nil?
|
59
61
|
result
|
60
62
|
end
|
61
63
|
|
@@ -63,7 +65,7 @@ module Emojidex
|
|
63
65
|
result = []
|
64
66
|
sizes.each do |size|
|
65
67
|
name = "#{size}/#{emoji.code}"
|
66
|
-
result << name if asset_files[name.to_sym].nil?
|
68
|
+
result << "#{name}.png" if asset_files[name.to_sym].nil?
|
67
69
|
end
|
68
70
|
result
|
69
71
|
end
|
data/lib/emojidex/defaults.rb
CHANGED
data/lib/emojidex/emoji.rb
CHANGED
@@ -1,27 +1,26 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
#
|
1
|
+
require_relative 'emoji/asset_information'
|
2
|
+
|
4
3
|
module Emojidex
|
5
4
|
# emoji base class
|
6
5
|
class Emoji
|
7
6
|
attr_accessor :moji, :category, :code, :unicode,
|
8
|
-
:tags, :
|
7
|
+
:tags, :emoticon
|
8
|
+
|
9
|
+
include Emojidex::EmojiAssetInformation
|
9
10
|
|
10
11
|
def initialize(details = {})
|
11
12
|
@moji = details[:moji]
|
12
13
|
@code, @code_ja = details[:code], details[:code_ja]
|
13
14
|
@unicode = details[:unicode]
|
15
|
+
@emoticon = details[:emoticon]
|
14
16
|
@category = details[:category] ? details[:category].to_sym : :other
|
15
17
|
@tags = details[:tags].map { |tag| tag.to_sym } unless details[:tags].nil?
|
16
|
-
@frames = details[:frames] || [@code]
|
17
|
-
@delays = details[:delays] || [100]
|
18
|
-
@loops = details[:loops]
|
19
18
|
@link = details[:link]
|
20
19
|
@is_wide = details[:is_wide]
|
21
20
|
end
|
22
21
|
|
23
22
|
def to_s
|
24
|
-
@moji ||
|
23
|
+
@moji || ":#{@code}:"
|
25
24
|
end
|
26
25
|
|
27
26
|
def to_json(*args)
|
@@ -43,32 +42,5 @@ module Emojidex
|
|
43
42
|
def []=(key, val)
|
44
43
|
instance_variable_set(key.to_s.delete(':').insert(0, '@'), val)
|
45
44
|
end
|
46
|
-
|
47
|
-
def set_animation_data(params)
|
48
|
-
set_frames(params)
|
49
|
-
set_delays(params)
|
50
|
-
end
|
51
|
-
|
52
|
-
def set_frames(params)
|
53
|
-
return if params[:frames].nil?
|
54
|
-
|
55
|
-
@frames = params[:frames].clone
|
56
|
-
params[:frames].each_with_index do |frame, i|
|
57
|
-
@frames[i] = frame.keys.first.to_s if frame.is_a? Hash
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
def set_delays(params)
|
62
|
-
default_delay = params[:default_delay] || 100
|
63
|
-
|
64
|
-
@delays = params[:delays] unless params[:delays].nil?
|
65
|
-
if @delays.length < @frames.length
|
66
|
-
@delays << default_delay until @delays.length == @frames.length
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
def animated?
|
71
|
-
@frames.count > 1
|
72
|
-
end
|
73
45
|
end
|
74
46
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
module Emojidex
|
3
|
+
# Asset information for emoji
|
4
|
+
module EmojiAssetInformation
|
5
|
+
attr_accessor :checksums, :paths
|
6
|
+
|
7
|
+
# returns asset checksum
|
8
|
+
def checksum?(format, variant = nil)
|
9
|
+
puts @checksums
|
10
|
+
return @checksums[format][variant] unless variant.nil?
|
11
|
+
@checksums[format]
|
12
|
+
end
|
13
|
+
|
14
|
+
# returns asset path
|
15
|
+
def path?(format, variant = nil)
|
16
|
+
return @paths[format][variant] unless variant.nil?
|
17
|
+
@paths[format]
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/emojidex/extended.rb
CHANGED
@@ -6,10 +6,14 @@ module Emojidex
|
|
6
6
|
def initialize
|
7
7
|
super
|
8
8
|
if defined? Emojidex::Vectors
|
9
|
-
|
10
|
-
|
11
|
-
# TODO: load from service
|
9
|
+
@vector_source_path = Emojidex::Vectors.path + '/extended/'
|
10
|
+
load_local_collection @vector_source_path
|
12
11
|
end
|
12
|
+
if defined? Emojidex::Rasters
|
13
|
+
@raster_source_path = Emojidex::Rasters.path + '/extended/'
|
14
|
+
load_local_collection @raster_source_path
|
15
|
+
end
|
16
|
+
# TODO: load from service
|
13
17
|
end
|
14
18
|
end
|
15
19
|
end
|
data/lib/emojidex/utf.rb
CHANGED
@@ -6,10 +6,14 @@ module Emojidex
|
|
6
6
|
def initialize
|
7
7
|
super
|
8
8
|
if defined? Emojidex::Vectors
|
9
|
-
|
10
|
-
|
11
|
-
# TODO: load from service
|
9
|
+
@vector_source_path = Emojidex::Vectors.path + '/utf/'
|
10
|
+
load_local_collection @vector_source_path
|
12
11
|
end
|
12
|
+
if defined? Emojidex::Rasters
|
13
|
+
@raster_source_path = Emojidex::Rasters.path + '/utf/'
|
14
|
+
load_local_collection @raster_source_path
|
15
|
+
end
|
16
|
+
# TODO: load from service
|
13
17
|
end
|
14
18
|
end
|
15
19
|
end
|
@@ -39,13 +39,21 @@ describe Emojidex::CollectionChecker do
|
|
39
39
|
expect(checker.asset_only).to be_empty
|
40
40
|
end
|
41
41
|
|
42
|
+
it 'checks to see if a size of an asset exists' do
|
43
|
+
checker = Emojidex::CollectionChecker.new(col_good, {sizes: [:px64]})
|
44
|
+
|
45
|
+
expect(checker).to be_an_instance_of(Emojidex::CollectionChecker)
|
46
|
+
expect(checker.index_only.size).to eq(4)
|
47
|
+
expect(checker.asset_only).to be_empty
|
48
|
+
end
|
49
|
+
|
42
50
|
it 'checks for and identifies missing assets' do
|
43
51
|
checker = Emojidex::CollectionChecker.new(col_missing_assets, {sizes: @sizes})
|
44
52
|
|
45
53
|
expect(checker.asset_only).to be_empty
|
46
54
|
expect(checker.index_only.size).to eq(2)
|
47
55
|
expect(checker.index_only).to eq(
|
48
|
-
{:
|
56
|
+
{nut_and_bolt: ["nut_and_bolt.svg"], purple_heart: ["px32/purple_heart.png"]})
|
49
57
|
end
|
50
58
|
|
51
59
|
it 'checks for and identifies missing index entries' do
|
@@ -0,0 +1,108 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Emojidex::Collection do
|
6
|
+
let(:collection) { Emojidex::Collection.new(nil, './spec/support/sample_collections/good') }
|
7
|
+
|
8
|
+
describe '.load_local_collection' do
|
9
|
+
it 'loads a local collection' do
|
10
|
+
expect(collection).to be_an_instance_of(Emojidex::Collection)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '.each' do
|
15
|
+
it 'provides each emoji' do
|
16
|
+
collection.each do |emoji|
|
17
|
+
expect(emoji).to be_an_instance_of(Emojidex::Emoji)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '.find_by_moji' do
|
23
|
+
it 'finds and returns an emoji object by UTF moji code' do
|
24
|
+
expect(collection.find_by_moji('👯')).to be_an_instance_of(Emojidex::Emoji)
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'returns nil when the moji code does not exist' do
|
28
|
+
expect(collection.find_by_moji('XX')).to be_nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '.文字検索' do
|
33
|
+
it 'find_by_moji_codeをaliasして文字コードで検索する' do
|
34
|
+
expect(collection.文字検索('👯')).to be_an_instance_of(Emojidex::Emoji)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '.find_by_code' do
|
39
|
+
it 'finds and returns an emoji by code' do
|
40
|
+
ss = collection.find_by_code('nut_and_bolt')
|
41
|
+
expect(ss).to be_an_instance_of(Emojidex::Emoji)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'returns nil when a code does not exist' do
|
45
|
+
expect(collection.find_by_code('super_fantastic')).to be_nil
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
describe '.find_by_code_ja' do
|
50
|
+
it 'finds and returns an emoji by Japanese code' do
|
51
|
+
expect(collection.find_by_code_ja('ハート(紫)')).to be_an_instance_of(Emojidex::Emoji)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '.コード検索' do
|
56
|
+
it 'find_by_code_jaをaliasして日本語の絵文字コードで検索する' do
|
57
|
+
expect(collection.コード検索('ハート(紫)')).to be_an_instance_of(Emojidex::Emoji)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
describe '.cache!' do
|
62
|
+
it 'caches emoji to local storage cache' do
|
63
|
+
tmp_cache_path = File.expand_path('../support/tmpcache', __FILE__)
|
64
|
+
collection.cache!(cache_path: tmp_cache_path)
|
65
|
+
expect(ENV['EMOJI_CACHE']).to eq(collection.cache_path)
|
66
|
+
expect(File.exist? tmp_cache_path).to be_truthy
|
67
|
+
expect(File.exist? tmp_cache_path + '/mouth.svg').to be_truthy
|
68
|
+
expect(File.exist? tmp_cache_path + '/emoji.json').to be_truthy
|
69
|
+
|
70
|
+
FileUtils.rm_rf tmp_cache_path # cleanup
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe '.cache_index' do
|
75
|
+
it 'caches the index to the specified location' do
|
76
|
+
tmp_cache_path = File.expand_path('../support/tmpcache', __FILE__)
|
77
|
+
FileUtils.mkdir_p(tmp_cache_path)
|
78
|
+
collection.cache_index tmp_cache_path
|
79
|
+
expect(File.exist? tmp_cache_path + '/emoji.json').to be_truthy
|
80
|
+
|
81
|
+
FileUtils.rm_rf tmp_cache_path
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
describe '.generate_checksums' do
|
86
|
+
it 'generates checksums for assets' do
|
87
|
+
expect(collection.generate_checksums).to be_an_instance_of(Array)
|
88
|
+
expect(collection.emoji.values.first.checksums[:svg]).to be_truthy
|
89
|
+
expect(collection.emoji.values.first.checksum?(:svg)).to be_truthy
|
90
|
+
expect(collection.emoji.values.first.checksums[:png][:px32]).to be_truthy
|
91
|
+
expect(collection.emoji.values.first.checksum?(:png, :px32)).to be_truthy
|
92
|
+
expect(collection.emoji.values.first.checksums[:png][:px64]).to be_nil
|
93
|
+
expect(collection.emoji.values.first.checksum?(:png, :px64)).to be_nil
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
describe '.generate_paths' do
|
98
|
+
it 'generates file paths for each emoji' do
|
99
|
+
expect(collection.generate_paths).to be_an_instance_of(Array)
|
100
|
+
expect(collection.emoji.values.first.paths[:svg]).to be_truthy
|
101
|
+
expect(collection.emoji.values.first.path?(:svg)).to be_truthy
|
102
|
+
expect(collection.emoji.values.first.paths[:png][:px32]).to be_truthy
|
103
|
+
expect(collection.emoji.values.first.path?(:png, :px32)).to be_truthy
|
104
|
+
expect(collection.emoji.values.first.paths[:png][:px64]).to be_nil
|
105
|
+
expect(collection.emoji.values.first.path?(:png, :px64)).to be_nil
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
data/spec/emoji_spec.rb
CHANGED
@@ -44,20 +44,4 @@ describe Emojidex::Emoji do
|
|
44
44
|
expect(JSON.parse(emoji.to_json)).to be_an_instance_of(Hash)
|
45
45
|
end
|
46
46
|
end
|
47
|
-
|
48
|
-
describe '.frames' do
|
49
|
-
it 'holds an array of source frames' do
|
50
|
-
expect(emoji.frames).to be_an_instance_of(Array)
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
describe '.delays' do
|
55
|
-
it 'holds an array of delays between frames' do
|
56
|
-
expect(emoji.delays).to be_an_instance_of(Array)
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'defaults to 100ms when nothing is specified' do
|
60
|
-
expect(emoji.delays[0]).to eq(100)
|
61
|
-
end
|
62
|
-
end
|
63
47
|
end
|
data/spec/spec_helper.rb
CHANGED
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.
|
4
|
+
version: 0.0.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rei Kagetsuki
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2014-
|
14
|
+
date: 2014-09-08 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: faraday
|
@@ -61,14 +61,16 @@ files:
|
|
61
61
|
- lib/emojidex/api/categories.rb
|
62
62
|
- lib/emojidex/api/emoji.rb
|
63
63
|
- lib/emojidex/api/search/emoji.rb
|
64
|
-
- lib/emojidex/cache.rb
|
65
64
|
- lib/emojidex/categories.rb
|
66
65
|
- lib/emojidex/category.rb
|
67
66
|
- lib/emojidex/client.rb
|
68
67
|
- lib/emojidex/collection.rb
|
68
|
+
- lib/emojidex/collection/asset_information.rb
|
69
|
+
- lib/emojidex/collection/cache.rb
|
69
70
|
- lib/emojidex/collection_checker.rb
|
70
71
|
- lib/emojidex/defaults.rb
|
71
72
|
- lib/emojidex/emoji.rb
|
73
|
+
- lib/emojidex/emoji/asset_information.rb
|
72
74
|
- lib/emojidex/error.rb
|
73
75
|
- lib/emojidex/extended.rb
|
74
76
|
- lib/emojidex/service.rb
|
@@ -79,6 +81,7 @@ files:
|
|
79
81
|
- spec/categories_spec.rb
|
80
82
|
- spec/client_spec.rb
|
81
83
|
- spec/collection_checker_spec.rb
|
84
|
+
- spec/collection_spec.rb
|
82
85
|
- spec/emoji_spec.rb
|
83
86
|
- spec/extended_spec.rb
|
84
87
|
- spec/spec_helper.rb
|