emojidex 0.0.23 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (60) hide show
  1. checksums.yaml +4 -4
  2. data/.coveralls.yml +1 -0
  3. data/.rubocop.yml +3 -0
  4. data/.travis.yml +7 -6
  5. data/Gemfile +0 -2
  6. data/Guardfile +17 -8
  7. data/README.md +54 -17
  8. data/emojidex.gemspec +4 -1
  9. data/lib/emojidex.rb +12 -10
  10. data/lib/emojidex/{categories.rb → data/categories.rb} +3 -4
  11. data/lib/emojidex/{category.rb → data/category.rb} +1 -1
  12. data/lib/emojidex/data/collection.rb +158 -0
  13. data/lib/emojidex/data/collection/asset_information.rb +52 -0
  14. data/lib/emojidex/data/collection/cache.rb +137 -0
  15. data/lib/emojidex/{collection → data/collection}/moji_data.rb +1 -1
  16. data/lib/emojidex/data/collection/static_collection.rb +35 -0
  17. data/lib/emojidex/data/collection_checker.rb +94 -0
  18. data/lib/emojidex/{emoji.rb → data/emoji.rb} +3 -2
  19. data/lib/emojidex/data/emoji/asset_information.rb +45 -0
  20. data/lib/emojidex/data/extended.rb +18 -0
  21. data/lib/emojidex/data/utf.rb +18 -0
  22. data/lib/emojidex/defaults.rb +21 -0
  23. data/lib/emojidex/env_helper.rb +11 -0
  24. data/lib/emojidex/service/collection.rb +67 -0
  25. data/lib/emojidex/service/error.rb +9 -0
  26. data/lib/emojidex/service/indexes.rb +43 -0
  27. data/lib/emojidex/service/search.rb +82 -0
  28. data/lib/emojidex/service/transactor.rb +100 -0
  29. data/lib/emojidex/service/user.rb +233 -0
  30. data/spec/{categories_spec.rb → emojidex/data/categories_spec.rb} +4 -3
  31. data/spec/{collection_checker_spec.rb → emojidex/data/collection_checker_spec.rb} +12 -15
  32. data/spec/{collection_spec.rb → emojidex/data/collection_spec.rb} +40 -23
  33. data/spec/{emoji_spec.rb → emojidex/data/emoji_spec.rb} +2 -2
  34. data/spec/{extended_spec.rb → emojidex/data/extended_spec.rb} +21 -10
  35. data/spec/{utf_spec.rb → emojidex/data/utf_spec.rb} +22 -17
  36. data/spec/emojidex/service/collection_spec.rb +20 -0
  37. data/spec/emojidex/service/error_spec.rb +17 -0
  38. data/spec/emojidex/service/indexes_spec.rb +62 -0
  39. data/spec/emojidex/service/search_spec.rb +87 -0
  40. data/spec/emojidex/service/transactor_spec.rb +11 -0
  41. data/spec/emojidex/service/user_spec.rb +128 -0
  42. data/spec/spec_helper.rb +9 -62
  43. metadata +36 -31
  44. data/lib/emojidex/api/categories.rb +0 -16
  45. data/lib/emojidex/api/emoji.rb +0 -26
  46. data/lib/emojidex/api/search/emoji.rb +0 -16
  47. data/lib/emojidex/client.rb +0 -60
  48. data/lib/emojidex/collection.rb +0 -156
  49. data/lib/emojidex/collection/asset_information.rb +0 -49
  50. data/lib/emojidex/collection/cache.rb +0 -78
  51. data/lib/emojidex/collection_checker.rb +0 -93
  52. data/lib/emojidex/emoji/asset_information.rb +0 -20
  53. data/lib/emojidex/error.rb +0 -15
  54. data/lib/emojidex/extended.rb +0 -19
  55. data/lib/emojidex/service.rb +0 -32
  56. data/lib/emojidex/utf.rb +0 -19
  57. data/spec/api/categories_spec.rb +0 -49
  58. data/spec/api/emoji_spec.rb +0 -89
  59. data/spec/api/search/emoji_spec.rb +0 -30
  60. data/spec/client_spec.rb +0 -24
@@ -1,20 +0,0 @@
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
@@ -1,15 +0,0 @@
1
- module Emojidex
2
- # emojidex error class
3
- class Error < StandardError
4
- attr_reader :wrapped_exception
5
-
6
- def initialize(exception = $ERROR_INFO)
7
- @wrapped_exception = exception
8
- if exception.respond_to?(:message)
9
- super(exception.message)
10
- else
11
- super(exception.to_s)
12
- end
13
- end
14
- end
15
- end
@@ -1,19 +0,0 @@
1
- require_relative 'collection'
2
-
3
- module Emojidex
4
- # listing and search of extended emoji from the emojidex set
5
- class Extended < Collection
6
- def initialize
7
- super
8
- if defined? Emojidex::Vectors
9
- @vector_source_path = Emojidex::Vectors.path + '/extended/'
10
- load_local_collection @vector_source_path
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
17
- end
18
- end
19
- end
@@ -1,32 +0,0 @@
1
- require_relative 'collection'
2
- require_relative 'client'
3
-
4
- module Emojidex
5
- # listing and search of emoji from the online service/emojidex.com
6
- class Service < Collection
7
- attr_accessor :client
8
- def initialize(emoji_list = nil, client_opts = {})
9
- super emoji_list
10
- @client = Emojidex::Client.new client_opts
11
- end
12
-
13
- # sends an API search, adding results with add_emoji
14
- # returns a collection, and adds results to the @emoji array
15
- def search(criteria = {})
16
- # TODO: *NOTE try and replicate regex search functionality by passing regex to server
17
- end
18
-
19
- # directly retrieves the emoji with the given code
20
- def find_by_code(code)
21
- # TODO: perform a query on emojidex API
22
- end
23
-
24
- # emoji on the emojidex service make no language distinctions
25
- # find_by_code_ja is simply remapped to find_by_code
26
- def find_by_code_ja(code)
27
- find_by_code(code)
28
- end
29
-
30
- # TODO: override or add caching functionality to retrieve sized png or svg from service
31
- end
32
- end
data/lib/emojidex/utf.rb DELETED
@@ -1,19 +0,0 @@
1
- require_relative 'collection'
2
-
3
- module Emojidex
4
- # listing and search of standard UTF emoji
5
- class UTF < Collection
6
- def initialize
7
- super
8
- if defined? Emojidex::Vectors
9
- @vector_source_path = Emojidex::Vectors.path + '/utf/'
10
- load_local_collection @vector_source_path
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
17
- end
18
- end
19
- end
@@ -1,49 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Emojidex::API::Categories do
4
-
5
- subject { Emojidex::Client.new(host: 'http://localhost') }
6
- let!(:api_url) { 'http://localhost/api/v1' }
7
-
8
- describe '#categories' do
9
- before do
10
- stub_get("#{api_url}/categories.json")
11
- .to_return(
12
- body: fixture('categories.json'),
13
- headers: { content_type: 'application/json' }
14
- )
15
- end
16
-
17
- it 'requests the correct resource' do
18
- subject.categories
19
- expect(a_get("#{api_url}/categories.json")).to have_been_made
20
- end
21
-
22
- it 'returns the requested categories' do
23
- categories = subject.categories
24
- expect(categories).to be_an Array
25
- expect(categories.first).to be_a Hash
26
- end
27
- end
28
-
29
- describe '#category' do
30
- before do
31
- stub_get("#{api_url}/categories/category.json")
32
- .to_return(
33
- body: fixture('category.json'),
34
- headers: { content_type: 'application/json' }
35
- )
36
- end
37
-
38
- it 'requests the correct resource' do
39
- subject.category
40
- expect(a_get("#{api_url}/categories/category.json")).to have_been_made
41
- end
42
-
43
- it 'returns the requested category' do
44
- category = subject.category
45
- expect(category).to be_a Hash
46
- end
47
- end
48
-
49
- end
@@ -1,89 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Emojidex::API::Emoji do
4
- subject { Emojidex::Client.new(host: 'http://localhost') }
5
- let!(:api_url) { 'http://localhost/api/v1' }
6
-
7
- describe '#emoji' do
8
- before do
9
- stub_get("#{api_url}/emoji.json")
10
- .to_return(
11
- body: fixture('emoji.json'),
12
- headers: { content_type: 'application/json' }
13
- )
14
- end
15
-
16
- it 'requests the correct resource' do
17
- subject.emoji
18
- expect(a_get("#{api_url}/emoji.json")).to have_been_made
19
- end
20
-
21
- it 'returns the requested emoji' do
22
- emoji = subject.emoji
23
- expect(emoji).to be_an Array
24
- expect(emoji.first).to be_a Hash
25
- end
26
- end
27
-
28
- describe '#emoji_detailed' do
29
- before do
30
- stub_get("#{api_url}/emoji/detailed.json")
31
- .to_return(
32
- body: fixture('emoji_detailed.json'),
33
- headers: { content_type: 'application/json' }
34
- )
35
- end
36
-
37
- it 'requests the correct resource' do
38
- subject.emoji_detailed
39
- expect(a_get("#{api_url}/emoji/detailed.json")).to have_been_made
40
- end
41
-
42
- it 'returns the requested emoji' do
43
- emoji = subject.emoji_detailed
44
- expect(emoji).to be_an Array
45
- expect(emoji.first).to be_a Hash
46
- end
47
- end
48
-
49
- describe '#single_emoji' do
50
- before do
51
- stub_get("#{api_url}/emoji/emoji.json")
52
- .to_return(
53
- body: fixture('single_emoji.json'),
54
- headers: { content_type: 'application/json' }
55
- )
56
- end
57
-
58
- it 'requests the correct resource' do
59
- subject.single_emoji
60
- expect(a_get("#{api_url}/emoji/emoji.json")).to have_been_made
61
- end
62
-
63
- it 'returns the requested emoji' do
64
- emoji = subject.single_emoji
65
- expect(emoji).to be_a Hash
66
- end
67
- end
68
-
69
- describe '#single_emoji_detailed' do
70
- before do
71
- stub_get("#{api_url}/emoji/1/detailed.json")
72
- .to_return(
73
- body: fixture('single_emoji_detailed.json'),
74
- headers: { content_type: 'application/json' }
75
- )
76
- end
77
-
78
- it 'requests the correct resource' do
79
- subject.single_emoji_detailed
80
- expect(a_get("#{api_url}/emoji/1/detailed.json")).to have_been_made
81
- end
82
-
83
- it 'returns the requested emoji' do
84
- emoji = subject.single_emoji_detailed
85
- expect(emoji).to be_a Hash
86
- end
87
- end
88
-
89
- end
@@ -1,30 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Emojidex::API::Search::Emoji do
4
- subject { Emojidex::Client.new(host: 'http://localhost') }
5
- let!(:api_url) { 'http://localhost/api/v1' }
6
-
7
- describe '#emoji' do
8
- before do
9
- stub_get("#{api_url}/search/emoji.json")
10
- .with(query: { 'q[code_cont]' => 't' })
11
- .to_return(
12
- body: fixture('search_emoji.json'),
13
- headers: { content_type: 'application/json' }
14
- )
15
- end
16
-
17
- it 'requests the correct resource' do
18
- subject.emoji_code_cont('t')
19
- expect(a_get("#{api_url}/search/emoji.json")
20
- .with(query: { 'q[code_cont]' => 't' })).to have_been_made
21
- end
22
-
23
- it 'returns the requested search' do
24
- results = subject.emoji_code_cont('t')
25
- expect(results).to be_an Array
26
- expect(results.first).to be_a Hash
27
- end
28
- end
29
-
30
- end
data/spec/client_spec.rb DELETED
@@ -1,24 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Emojidex::Client do
4
-
5
- describe 'initialize' do
6
- it 'sets default host' do
7
- client = Emojidex::Client.new
8
- expect(client.host).to eq 'https://www.emojidex.com/'
9
- end
10
-
11
- it 'sets custom host' do
12
- client = Emojidex::Client.new(host: 'example.com')
13
- expect(client.host).to eq 'example.com'
14
- end
15
- end
16
-
17
- describe 'user_agent' do
18
- it 'sets user_agent' do
19
- client = Emojidex::Client.new
20
- expect(client.user_agent).to eq 'Emojidex Toolkit Client'
21
- end
22
- end
23
-
24
- end