emojidex 0.0.23 → 0.1.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/.coveralls.yml +1 -0
- data/.rubocop.yml +3 -0
- data/.travis.yml +7 -6
- data/Gemfile +0 -2
- data/Guardfile +17 -8
- data/README.md +54 -17
- data/emojidex.gemspec +4 -1
- data/lib/emojidex.rb +12 -10
- data/lib/emojidex/{categories.rb → data/categories.rb} +3 -4
- data/lib/emojidex/{category.rb → data/category.rb} +1 -1
- data/lib/emojidex/data/collection.rb +158 -0
- data/lib/emojidex/data/collection/asset_information.rb +52 -0
- data/lib/emojidex/data/collection/cache.rb +137 -0
- data/lib/emojidex/{collection → data/collection}/moji_data.rb +1 -1
- data/lib/emojidex/data/collection/static_collection.rb +35 -0
- data/lib/emojidex/data/collection_checker.rb +94 -0
- data/lib/emojidex/{emoji.rb → data/emoji.rb} +3 -2
- data/lib/emojidex/data/emoji/asset_information.rb +45 -0
- data/lib/emojidex/data/extended.rb +18 -0
- data/lib/emojidex/data/utf.rb +18 -0
- data/lib/emojidex/defaults.rb +21 -0
- data/lib/emojidex/env_helper.rb +11 -0
- data/lib/emojidex/service/collection.rb +67 -0
- data/lib/emojidex/service/error.rb +9 -0
- data/lib/emojidex/service/indexes.rb +43 -0
- data/lib/emojidex/service/search.rb +82 -0
- data/lib/emojidex/service/transactor.rb +100 -0
- data/lib/emojidex/service/user.rb +233 -0
- data/spec/{categories_spec.rb → emojidex/data/categories_spec.rb} +4 -3
- data/spec/{collection_checker_spec.rb → emojidex/data/collection_checker_spec.rb} +12 -15
- data/spec/{collection_spec.rb → emojidex/data/collection_spec.rb} +40 -23
- data/spec/{emoji_spec.rb → emojidex/data/emoji_spec.rb} +2 -2
- data/spec/{extended_spec.rb → emojidex/data/extended_spec.rb} +21 -10
- data/spec/{utf_spec.rb → emojidex/data/utf_spec.rb} +22 -17
- data/spec/emojidex/service/collection_spec.rb +20 -0
- data/spec/emojidex/service/error_spec.rb +17 -0
- data/spec/emojidex/service/indexes_spec.rb +62 -0
- data/spec/emojidex/service/search_spec.rb +87 -0
- data/spec/emojidex/service/transactor_spec.rb +11 -0
- data/spec/emojidex/service/user_spec.rb +128 -0
- data/spec/spec_helper.rb +9 -62
- metadata +36 -31
- data/lib/emojidex/api/categories.rb +0 -16
- data/lib/emojidex/api/emoji.rb +0 -26
- data/lib/emojidex/api/search/emoji.rb +0 -16
- data/lib/emojidex/client.rb +0 -60
- data/lib/emojidex/collection.rb +0 -156
- data/lib/emojidex/collection/asset_information.rb +0 -49
- data/lib/emojidex/collection/cache.rb +0 -78
- data/lib/emojidex/collection_checker.rb +0 -93
- data/lib/emojidex/emoji/asset_information.rb +0 -20
- data/lib/emojidex/error.rb +0 -15
- data/lib/emojidex/extended.rb +0 -19
- data/lib/emojidex/service.rb +0 -32
- data/lib/emojidex/utf.rb +0 -19
- data/spec/api/categories_spec.rb +0 -49
- data/spec/api/emoji_spec.rb +0 -89
- data/spec/api/search/emoji_spec.rb +0 -30
- data/spec/client_spec.rb +0 -24
@@ -1,17 +1,18 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Emojidex::Categories do
|
4
|
-
let(:categories) { Emojidex::Categories.new }
|
3
|
+
describe Emojidex::Data::Categories do
|
4
|
+
let(:categories) { Emojidex::Data::Categories.new }
|
5
5
|
|
6
6
|
describe '.initialize' do
|
7
7
|
it 'initializes a new categories object' do
|
8
|
-
expect(categories).to be_an_instance_of(Emojidex::Categories)
|
8
|
+
expect(categories).to be_an_instance_of(Emojidex::Data::Categories)
|
9
9
|
end
|
10
10
|
end
|
11
11
|
|
12
12
|
describe '.category' do
|
13
13
|
it 'is a proper hash and can be referenced by key' do
|
14
14
|
expect(categories.categories[:transportation].en).to eq('Transportation')
|
15
|
+
expect(categories.categories[:transportation].ja).to eq('乗り物')
|
15
16
|
end
|
16
17
|
end
|
17
18
|
|
@@ -1,15 +1,12 @@
|
|
1
|
-
|
2
1
|
require 'spec_helper'
|
2
|
+
require 'emojidex/data/collection_checker'
|
3
3
|
|
4
|
-
describe Emojidex::CollectionChecker do
|
4
|
+
describe Emojidex::Data::CollectionChecker do
|
5
5
|
|
6
6
|
before(:all) do
|
7
7
|
@sizes = [:px32]
|
8
8
|
end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
10
|
let(:col_good) do
|
14
11
|
sample_collection 'good'
|
15
12
|
end
|
@@ -24,31 +21,31 @@ describe Emojidex::CollectionChecker do
|
|
24
21
|
|
25
22
|
describe 'Spec Collections' do
|
26
23
|
it 'load cleanly' do
|
27
|
-
expect(col_good).to be_an_instance_of(Emojidex::Collection)
|
28
|
-
expect(col_missing_assets).to be_an_instance_of(Emojidex::Collection)
|
29
|
-
expect(col_missing_index).to be_an_instance_of(Emojidex::Collection)
|
24
|
+
expect(col_good).to be_an_instance_of(Emojidex::Data::Collection)
|
25
|
+
expect(col_missing_assets).to be_an_instance_of(Emojidex::Data::Collection)
|
26
|
+
expect(col_missing_index).to be_an_instance_of(Emojidex::Data::Collection)
|
30
27
|
end
|
31
28
|
end
|
32
29
|
|
33
30
|
describe '.new' do
|
34
31
|
it 'creates a valid CollectionChecker instance and checks a valid collection' do
|
35
|
-
checker = Emojidex::CollectionChecker.new(col_good, {sizes: @sizes})
|
32
|
+
checker = Emojidex::Data::CollectionChecker.new(col_good, {sizes: @sizes})
|
36
33
|
|
37
|
-
expect(checker).to be_an_instance_of(Emojidex::CollectionChecker)
|
34
|
+
expect(checker).to be_an_instance_of(Emojidex::Data::CollectionChecker)
|
38
35
|
expect(checker.index_only).to be_empty
|
39
36
|
expect(checker.asset_only).to be_empty
|
40
37
|
end
|
41
38
|
|
42
39
|
it 'checks to see if a size of an asset exists' do
|
43
|
-
checker = Emojidex::CollectionChecker.new(col_good, {sizes: [:px64]})
|
40
|
+
checker = Emojidex::Data::CollectionChecker.new(col_good, {sizes: [:px64]})
|
44
41
|
|
45
|
-
expect(checker).to be_an_instance_of(Emojidex::CollectionChecker)
|
42
|
+
expect(checker).to be_an_instance_of(Emojidex::Data::CollectionChecker)
|
46
43
|
expect(checker.index_only.size).to eq(4)
|
47
44
|
expect(checker.asset_only).to be_empty
|
48
45
|
end
|
49
46
|
|
50
47
|
it 'checks for and identifies missing assets' do
|
51
|
-
checker = Emojidex::CollectionChecker.new(col_missing_assets, {sizes: @sizes})
|
48
|
+
checker = Emojidex::Data::CollectionChecker.new(col_missing_assets, {sizes: @sizes})
|
52
49
|
|
53
50
|
expect(checker.asset_only).to be_empty
|
54
51
|
expect(checker.index_only.size).to eq(2)
|
@@ -57,7 +54,7 @@ describe Emojidex::CollectionChecker do
|
|
57
54
|
end
|
58
55
|
|
59
56
|
it 'checks for and identifies missing index entries' do
|
60
|
-
checker = Emojidex::CollectionChecker.new(col_missing_index, {sizes: @sizes})
|
57
|
+
checker = Emojidex::Data::CollectionChecker.new(col_missing_index, {sizes: @sizes})
|
61
58
|
|
62
59
|
expect(checker.index_only).to be_empty
|
63
60
|
expect(checker.asset_only.size).to eq(1)
|
@@ -65,7 +62,7 @@ describe Emojidex::CollectionChecker do
|
|
65
62
|
{purple_heart: ["purple_heart.svg", "px32/purple_heart.png"]})
|
66
63
|
end
|
67
64
|
it 'checks collections against a specified asset directory' do
|
68
|
-
checker = Emojidex::CollectionChecker.new([col_missing_index, col_missing_assets],
|
65
|
+
checker = Emojidex::Data::CollectionChecker.new([col_missing_index, col_missing_assets],
|
69
66
|
{sizes: @sizes, asset_path: col_good.source_path})
|
70
67
|
|
71
68
|
expect(checker.index_only).to be_empty
|
@@ -2,26 +2,31 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
require 'emojidex/defaults'
|
6
|
+
require 'emojidex/data/utf'
|
7
|
+
require 'emojidex/data/extended'
|
8
|
+
|
9
|
+
describe Emojidex::Data::Collection do
|
10
|
+
let(:collection) { Emojidex::Data::Collection.new(nil, './spec/support/sample_collections/good') }
|
11
|
+
before(:each) { clear_tmp_cache }
|
7
12
|
|
8
13
|
describe '.load_local_collection' do
|
9
14
|
it 'loads a local collection' do
|
10
|
-
expect(collection).to be_an_instance_of(Emojidex::Collection)
|
15
|
+
expect(collection).to be_an_instance_of(Emojidex::Data::Collection)
|
11
16
|
end
|
12
17
|
end
|
13
18
|
|
14
19
|
describe '.each' do
|
15
20
|
it 'provides each emoji' do
|
16
21
|
collection.each do |emoji|
|
17
|
-
expect(emoji).to be_an_instance_of(Emojidex::Emoji)
|
22
|
+
expect(emoji).to be_an_instance_of(Emojidex::Data::Emoji)
|
18
23
|
end
|
19
24
|
end
|
20
25
|
end
|
21
26
|
|
22
27
|
describe '.find_by_moji' do
|
23
28
|
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)
|
29
|
+
expect(collection.find_by_moji('👯')).to be_an_instance_of(Emojidex::Data::Emoji)
|
25
30
|
end
|
26
31
|
|
27
32
|
it 'returns nil when the moji code does not exist' do
|
@@ -31,14 +36,14 @@ describe Emojidex::Collection do
|
|
31
36
|
|
32
37
|
describe '.文字検索' do
|
33
38
|
it 'find_by_moji_codeをaliasして文字コードで検索する' do
|
34
|
-
expect(collection.文字検索('👯')).to be_an_instance_of(Emojidex::Emoji)
|
39
|
+
expect(collection.文字検索('👯')).to be_an_instance_of(Emojidex::Data::Emoji)
|
35
40
|
end
|
36
41
|
end
|
37
42
|
|
38
43
|
describe '.find_by_code' do
|
39
44
|
it 'finds and returns an emoji by code' do
|
40
45
|
ss = collection.find_by_code('nut_and_bolt')
|
41
|
-
expect(ss).to be_an_instance_of(Emojidex::Emoji)
|
46
|
+
expect(ss).to be_an_instance_of(Emojidex::Data::Emoji)
|
42
47
|
end
|
43
48
|
|
44
49
|
it 'returns nil when a code does not exist' do
|
@@ -48,53 +53,47 @@ describe Emojidex::Collection do
|
|
48
53
|
|
49
54
|
describe '.find_by_code_ja' do
|
50
55
|
it 'finds and returns an emoji by Japanese code' do
|
51
|
-
expect(collection.find_by_code_ja('ハート(紫)')).to be_an_instance_of(Emojidex::Emoji)
|
56
|
+
expect(collection.find_by_code_ja('ハート(紫)')).to be_an_instance_of(Emojidex::Data::Emoji)
|
52
57
|
end
|
53
58
|
end
|
54
59
|
|
55
60
|
describe '.コード検索' do
|
56
61
|
it 'find_by_code_jaをaliasして日本語の絵文字コードで検索する' do
|
57
|
-
expect(collection.コード検索('ハート(紫)')).to be_an_instance_of(Emojidex::Emoji)
|
62
|
+
expect(collection.コード検索('ハート(紫)')).to be_an_instance_of(Emojidex::Data::Emoji)
|
58
63
|
end
|
59
64
|
end
|
60
65
|
|
61
66
|
describe '.cache!' do
|
62
67
|
it 'caches emoji to local storage cache' do
|
63
|
-
|
64
|
-
collection.
|
65
|
-
expect(
|
68
|
+
collection.cache!(cache_path: tmp_cache_path, formats: [:svg])
|
69
|
+
expect(collection.cache_path).to eq "#{tmp_cache_path}/emoji"
|
70
|
+
expect(collection.vector_source_path).to eq collection.source_path
|
71
|
+
expect(File.exist? "#{collection.vector_source_path}/mouth.svg").to be_truthy
|
66
72
|
expect(File.exist? tmp_cache_path).to be_truthy
|
67
|
-
expect(File.exist?
|
68
|
-
expect(File.exist?
|
69
|
-
|
70
|
-
FileUtils.rm_rf tmp_cache_path # cleanup
|
73
|
+
expect(File.exist? "#{collection.cache_path}/mouth.svg").to be_truthy
|
74
|
+
expect(File.exist? "#{collection.cache_path}/emoji.json").to be_truthy
|
71
75
|
end
|
72
76
|
end
|
73
77
|
|
74
78
|
describe '.cache_index' do
|
75
79
|
it 'caches the index to the specified location' do
|
76
|
-
tmp_cache_path = File.expand_path('../support/tmpcache', __FILE__)
|
77
80
|
FileUtils.mkdir_p(tmp_cache_path)
|
78
81
|
collection.cache_index tmp_cache_path
|
79
82
|
expect(File.exist? tmp_cache_path + '/emoji.json').to be_truthy
|
80
|
-
|
81
|
-
FileUtils.rm_rf tmp_cache_path
|
82
83
|
end
|
83
84
|
end
|
84
85
|
|
85
86
|
describe '.write_index' do
|
86
87
|
it 'writes a cleaned index to the specified location' do
|
87
|
-
tmp_cache_path = File.expand_path('../support/tmpcache', __FILE__)
|
88
88
|
FileUtils.mkdir_p(tmp_cache_path)
|
89
89
|
collection.cache_index tmp_cache_path
|
90
90
|
expect(File.exist? tmp_cache_path + '/emoji.json').to be_truthy
|
91
|
-
|
92
|
-
FileUtils.rm_rf tmp_cache_path
|
93
91
|
end
|
94
92
|
end
|
95
93
|
|
96
94
|
describe '.generate_checksums' do
|
97
95
|
it 'generates checksums for assets' do
|
96
|
+
collection.cache!(cache_path: tmp_cache_path, formats: [:svg, :png], sizes: [:px32])
|
98
97
|
expect(collection.generate_checksums).to be_an_instance_of(Array)
|
99
98
|
expect(collection.emoji.values.first.checksums[:svg]).to be_truthy
|
100
99
|
expect(collection.emoji.values.first.checksum?(:svg)).to be_truthy
|
@@ -107,13 +106,31 @@ describe Emojidex::Collection do
|
|
107
106
|
|
108
107
|
describe '.generate_paths' do
|
109
108
|
it 'generates file paths for each emoji' do
|
109
|
+
collection.cache!(cache_path: tmp_cache_path, formats: [:svg, :png], sizes: [:px32])
|
110
110
|
expect(collection.generate_paths).to be_an_instance_of(Array)
|
111
111
|
expect(collection.emoji.values.first.paths[:svg]).to be_truthy
|
112
112
|
expect(collection.emoji.values.first.path?(:svg)).to be_truthy
|
113
113
|
expect(collection.emoji.values.first.paths[:png][:px32]).to be_truthy
|
114
114
|
expect(collection.emoji.values.first.path?(:png, :px32)).to be_truthy
|
115
115
|
expect(collection.emoji.values.first.paths[:png][:px64]).to be_nil
|
116
|
-
expect(collection.emoji.values.first.path?(:png, :px64)).to be_nil
|
116
|
+
expect(collection.emoji.values.first.path?(:png, :px64)).to be_nil
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
describe 'collections should chain combine' do
|
121
|
+
it 'chain combines' do
|
122
|
+
col = Emojidex::Data::Collection.new
|
123
|
+
col.emoji = {}
|
124
|
+
expect(col.emoji.count).to eq 0
|
125
|
+
|
126
|
+
col << Emojidex::Data::UTF.new
|
127
|
+
expect(col.emoji.count > 0).to be true
|
128
|
+
expect(col.emoji.count).to eq (Emojidex::Data::UTF.new()).emoji.count
|
129
|
+
|
130
|
+
col << Emojidex::Data::Extended.new
|
131
|
+
expect(col.emoji.count > (Emojidex::Data::UTF.new()).emoji.count).to be true
|
132
|
+
expect(col.emoji.count).to eq ((Emojidex::Data::UTF.new()).emoji.count +
|
133
|
+
(Emojidex::Data::Extended.new()).emoji.count)
|
117
134
|
end
|
118
135
|
end
|
119
136
|
end
|
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
|
-
describe Emojidex::Emoji do
|
5
|
+
describe Emojidex::Data::Emoji do
|
6
6
|
let(:emoji) do
|
7
|
-
Emojidex::Emoji.new moji: '🌠', code: 'shooting_star',
|
7
|
+
Emojidex::Data::Emoji.new moji: '🌠', code: 'shooting_star',
|
8
8
|
code_ja: '流れ星', category: 'cosmos',
|
9
9
|
unicode: '1f320', uri: '/dummy/uri'
|
10
10
|
end
|
@@ -1,14 +1,15 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
|
+
require 'emojidex/data/extended'
|
4
5
|
|
5
|
-
describe Emojidex::Extended do
|
6
|
-
let(:ext) { Emojidex::Extended.new }
|
6
|
+
describe Emojidex::Data::Extended do
|
7
|
+
let(:ext) { Emojidex::Data::Extended.new }
|
7
8
|
|
8
9
|
describe '.each' do
|
9
10
|
it 'provides each emoji' do
|
10
11
|
ext.each do |emoji|
|
11
|
-
expect(emoji).to be_an_instance_of(Emojidex::Emoji)
|
12
|
+
expect(emoji).to be_an_instance_of(Emojidex::Data::Emoji)
|
12
13
|
end
|
13
14
|
end
|
14
15
|
end
|
@@ -16,12 +17,12 @@ describe Emojidex::Extended do
|
|
16
17
|
describe 'find_by_code' do
|
17
18
|
it 'finds and returns an emoji by code' do
|
18
19
|
expect(ext.find_by_code('combat_knife'))
|
19
|
-
.to be_an_instance_of(Emojidex::Emoji)
|
20
|
+
.to be_an_instance_of(Emojidex::Data::Emoji)
|
20
21
|
end
|
21
22
|
|
22
23
|
it 'finds and returns an emoji by code, converting spaces to underscores' do
|
23
24
|
expect(ext.find_by_code('combat knife'))
|
24
|
-
.to be_an_instance_of(Emojidex::Emoji)
|
25
|
+
.to be_an_instance_of(Emojidex::Data::Emoji)
|
25
26
|
end
|
26
27
|
|
27
28
|
it 'returns nil when a code does not exist' do
|
@@ -31,20 +32,20 @@ describe Emojidex::Extended do
|
|
31
32
|
|
32
33
|
describe 'find_by_code_ja' do
|
33
34
|
it 'finds and returns an emoji by Japanese code' do
|
34
|
-
expect(ext.find_by_code_ja('
|
35
|
-
.to be_an_instance_of(Emojidex::Emoji)
|
35
|
+
expect(ext.find_by_code_ja('忍者'))
|
36
|
+
.to be_an_instance_of(Emojidex::Data::Emoji)
|
36
37
|
end
|
37
38
|
end
|
38
39
|
|
39
40
|
describe 'コード検索' do
|
40
41
|
it 'find_by_code_jaをaliasして日本語の絵文字コードで検索する' do
|
41
|
-
expect(ext.コード検索('
|
42
|
+
expect(ext.コード検索('忍者')).to be_an_instance_of(Emojidex::Data::Emoji)
|
42
43
|
end
|
43
44
|
end
|
44
45
|
|
45
46
|
describe 'category' do
|
46
47
|
it 'returns a collection of the specificed category' do
|
47
|
-
expect(categorized = ext.category(:tools)).to be_an_instance_of(Emojidex::Collection)
|
48
|
+
expect(categorized = ext.category(:tools)).to be_an_instance_of(Emojidex::Data::Collection)
|
48
49
|
expect(categorized.emoji.count).to be > 1
|
49
50
|
end
|
50
51
|
end
|
@@ -100,8 +101,18 @@ describe Emojidex::Extended do
|
|
100
101
|
|
101
102
|
it 'evaluates regular expressions' do
|
102
103
|
col = ext.search(code: 'emoji(?!.*dex$).*', category: 'symbols')
|
103
|
-
expect(col.find_by_code('emoji')).to be_an_instance_of Emojidex::Emoji
|
104
|
+
expect(col.find_by_code('emoji')).to be_an_instance_of Emojidex::Data::Emoji
|
104
105
|
expect(col.find_by_code('emojidex')).to be_nil
|
105
106
|
end
|
106
107
|
end
|
108
|
+
|
109
|
+
describe 'load_from_server' do
|
110
|
+
it 'loads index from server' do
|
111
|
+
ext.emoji = {}
|
112
|
+
expect(ext.emoji.count == 0).to be true
|
113
|
+
expect(ext.load_from_server).to be true
|
114
|
+
expect(ext.emoji.count > 0).to be true
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
107
118
|
end
|
@@ -1,21 +1,23 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require 'spec_helper'
|
4
|
+
require 'emojidex/data/utf'
|
4
5
|
|
5
|
-
describe Emojidex::UTF do
|
6
|
-
let(:utf) { Emojidex::UTF.new }
|
6
|
+
describe Emojidex::Data::UTF do
|
7
|
+
let(:utf) { Emojidex::Data::UTF.new }
|
8
|
+
before(:each) { clear_tmp_cache }
|
7
9
|
|
8
10
|
describe '.each' do
|
9
11
|
it 'provides each emoji' do
|
10
12
|
utf.each do |emoji|
|
11
|
-
expect(emoji).to be_an_instance_of(Emojidex::Emoji)
|
13
|
+
expect(emoji).to be_an_instance_of(Emojidex::Data::Emoji)
|
12
14
|
end
|
13
15
|
end
|
14
16
|
end
|
15
17
|
|
16
18
|
describe '.find_by_moji' do
|
17
19
|
it 'finds and returns an emoji object by UTF moji code' do
|
18
|
-
expect(utf.find_by_moji('🌠')).to be_an_instance_of(Emojidex::Emoji)
|
20
|
+
expect(utf.find_by_moji('🌠')).to be_an_instance_of(Emojidex::Data::Emoji)
|
19
21
|
end
|
20
22
|
|
21
23
|
it 'returns nil when the moji code does not exist' do
|
@@ -25,14 +27,14 @@ describe Emojidex::UTF do
|
|
25
27
|
|
26
28
|
describe '.文字検索' do
|
27
29
|
it 'find_by_moji_codeをaliasして文字コードで検索する' do
|
28
|
-
expect(utf.文字検索('🌠')).to be_an_instance_of(Emojidex::Emoji)
|
30
|
+
expect(utf.文字検索('🌠')).to be_an_instance_of(Emojidex::Data::Emoji)
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
32
34
|
describe '.find_by_code' do
|
33
35
|
it 'finds and returns an emoji by code' do
|
34
36
|
ss = utf.find_by_code('stars')
|
35
|
-
expect(ss).to be_an_instance_of(Emojidex::Emoji)
|
37
|
+
expect(ss).to be_an_instance_of(Emojidex::Data::Emoji)
|
36
38
|
end
|
37
39
|
|
38
40
|
it 'returns nil when a code does not exist' do
|
@@ -42,13 +44,13 @@ describe Emojidex::UTF do
|
|
42
44
|
|
43
45
|
describe '.find_by_code_ja' do
|
44
46
|
it 'finds and returns an emoji by Japanese code' do
|
45
|
-
expect(utf.find_by_code_ja('流れ星')).to be_an_instance_of(Emojidex::Emoji)
|
47
|
+
expect(utf.find_by_code_ja('流れ星')).to be_an_instance_of(Emojidex::Data::Emoji)
|
46
48
|
end
|
47
49
|
end
|
48
50
|
|
49
51
|
describe '.コード検索' do
|
50
52
|
it 'find_by_code_jaをaliasして日本語の絵文字コードで検索する' do
|
51
|
-
expect(utf.コード検索('流れ星')).to be_an_instance_of(Emojidex::Emoji)
|
53
|
+
expect(utf.コード検索('流れ星')).to be_an_instance_of(Emojidex::Data::Emoji)
|
52
54
|
end
|
53
55
|
end
|
54
56
|
|
@@ -62,25 +64,28 @@ describe Emojidex::UTF do
|
|
62
64
|
|
63
65
|
describe '.cache!' do
|
64
66
|
it 'caches emoji to local storage cache' do
|
65
|
-
|
66
|
-
utf.cache!(cache_path: tmp_cache_path)
|
67
|
-
expect(ENV['EMOJI_CACHE']).to eq(utf.cache_path)
|
67
|
+
utf.cache!(cache_path: tmp_cache_path, formats: [:svg])
|
68
68
|
expect(File.exist? tmp_cache_path).to be_truthy
|
69
|
-
expect(File.exist? tmp_cache_path + '/sushi.svg').to be_truthy
|
70
|
-
expect(File.exist? tmp_cache_path + '/emoji.json').to be_truthy
|
71
|
-
|
72
|
-
FileUtils.rm_rf tmp_cache_path # cleanup
|
69
|
+
expect(File.exist? tmp_cache_path + '/emoji/sushi.svg').to be_truthy
|
70
|
+
expect(File.exist? tmp_cache_path + '/emoji/emoji.json').to be_truthy
|
73
71
|
end
|
74
72
|
end
|
75
73
|
|
76
74
|
describe 'cache_index' do
|
77
75
|
it 'caches the collection index to the specified location' do
|
78
|
-
tmp_cache_path = File.expand_path('../support/tmpcache', __FILE__)
|
79
76
|
FileUtils.mkdir_p(tmp_cache_path)
|
80
77
|
utf.cache_index tmp_cache_path
|
81
78
|
expect(File.exist? tmp_cache_path + '/emoji.json').to be_truthy
|
79
|
+
end
|
80
|
+
end
|
82
81
|
|
83
|
-
|
82
|
+
describe 'load_from_server' do
|
83
|
+
it 'loads index from server' do
|
84
|
+
utf.emoji = {}
|
85
|
+
expect(utf.emoji.count == 0).to be true
|
86
|
+
expect(utf.load_from_server).to be true
|
87
|
+
expect(utf.emoji.count > 0).to be true
|
84
88
|
end
|
85
89
|
end
|
90
|
+
|
86
91
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
require 'emojidex/service/collection'
|
6
|
+
|
7
|
+
describe Emojidex::Service::Collection do
|
8
|
+
describe '.initialize' do
|
9
|
+
it 'defaults to the emoji index with 50 results per page undetailed' do
|
10
|
+
sc = Emojidex::Service::Collection.new
|
11
|
+
expect(sc.emoji.count).to eq 50
|
12
|
+
expect(sc.detailed).to be false
|
13
|
+
expect(sc.endpoint).to eq 'emoji'
|
14
|
+
expect(sc.page).to eq 1
|
15
|
+
expect(sc.source_path).to be nil
|
16
|
+
expect(sc.vector_source_path).to be nil
|
17
|
+
expect(sc.raster_source_path).to be nil
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|