emojidex 0.0.7 → 0.0.9
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/.gitignore +11 -10
- data/.rspec +2 -0
- data/.rubocop.yml +11 -0
- data/.travis.yml +17 -0
- data/Gemfile +16 -10
- data/Guardfile +12 -0
- data/README.md +27 -5
- data/Rakefile +6 -32
- data/emoji/categories.json +64 -0
- data/emojidex.gemspec +13 -20
- data/lib/emojidex.rb +9 -4
- data/lib/emojidex/api/categories.rb +16 -0
- data/lib/emojidex/api/emoji.rb +26 -0
- data/lib/emojidex/api/search/emoji.rb +16 -0
- data/lib/emojidex/cache.rb +69 -0
- data/lib/emojidex/categories.rb +32 -0
- data/lib/emojidex/category.rb +14 -0
- data/lib/emojidex/client.rb +60 -0
- data/lib/emojidex/collection.rb +119 -0
- data/lib/emojidex/defaults.rb +13 -0
- data/lib/emojidex/emoji.rb +74 -0
- data/lib/emojidex/error.rb +15 -0
- data/lib/emojidex/extended.rb +15 -0
- data/lib/emojidex/service.rb +32 -0
- data/lib/emojidex/utf.rb +15 -0
- data/spec/api/categories_spec.rb +49 -0
- data/spec/api/emoji_spec.rb +89 -0
- data/spec/api/search/emoji_spec.rb +30 -0
- data/spec/categories_spec.rb +18 -0
- data/spec/client_spec.rb +24 -0
- data/spec/emoji_spec.rb +63 -0
- data/spec/extended_spec.rb +107 -0
- data/spec/spec_helper.rb +64 -0
- data/spec/support/Genshin.svg +126 -0
- data/spec/support/couple_kiss/0.svg +177 -0
- data/spec/support/couple_kiss/1.svg +177 -0
- data/spec/support/couple_kiss/10.svg +293 -0
- data/spec/support/couple_kiss/11.svg +235 -0
- data/spec/support/couple_kiss/12.svg +235 -0
- data/spec/support/couple_kiss/13.svg +235 -0
- data/spec/support/couple_kiss/14.svg +177 -0
- data/spec/support/couple_kiss/15.svg +177 -0
- data/spec/support/couple_kiss/2.svg +177 -0
- data/spec/support/couple_kiss/3.svg +235 -0
- data/spec/support/couple_kiss/4.svg +235 -0
- data/spec/support/couple_kiss/5.svg +235 -0
- data/spec/support/couple_kiss/6.svg +293 -0
- data/spec/support/couple_kiss/7.svg +235 -0
- data/spec/support/couple_kiss/8.svg +235 -0
- data/spec/support/couple_kiss/9.svg +235 -0
- data/spec/support/couple_kiss/animation.json +14 -0
- data/spec/support/fixtures/categories.json +14 -0
- data/spec/support/fixtures/category.json +5 -0
- data/spec/support/fixtures/emoji.json +28 -0
- data/spec/support/fixtures/emoji_detailed.json +41 -0
- data/spec/support/fixtures/search_emoji.json +21 -0
- data/spec/support/fixtures/single_emoji.json +19 -0
- data/spec/support/fixtures/single_emoji_detailed.json +30 -0
- data/spec/support/test1/animation.json +6 -0
- data/spec/support/test2/animation.json +6 -0
- data/spec/support/test3/animation.json +5 -0
- data/spec/utf_spec.rb +66 -0
- metadata +82 -104
- data/app/assets/images/emojidex/.keep +0 -0
- data/app/assets/images/emojidex/glyphicons-halflings-white.png +0 -0
- data/app/assets/images/emojidex/glyphicons-halflings.png +0 -0
- data/app/assets/javascripts/emojidex/application.js +0 -14
- data/app/assets/javascripts/emojidex/bootstrap.min.js +0 -7
- data/app/assets/javascripts/emojidex/cheat_sheet.js +0 -12
- data/app/assets/javascripts/emojidex/poe_pallet.js +0 -71
- data/app/assets/stylesheets/emojidex/application.css +0 -15
- data/app/assets/stylesheets/emojidex/bootstrap-responsive.min.css +0 -9
- data/app/assets/stylesheets/emojidex/bootstrap.min.css +0 -9
- data/app/assets/stylesheets/emojidex/cheat_sheet.css +0 -41
- data/app/controllers/emojidex/application_controller.rb +0 -7
- data/app/controllers/emojidex/cheat_sheet_controller.rb +0 -50
- data/app/helpers/emojidex/application_helper.rb +0 -4
- data/app/helpers/emojidex/cheat_sheet_helper.rb +0 -4
- data/app/views/emojidex/cheat_sheet/index.html.erb +0 -58
- data/app/views/layouts/emojidex/application.html.erb +0 -14
- data/bin/rails +0 -8
- data/config/routes.rb +0 -5
- data/lib/emojidex/engine.rb +0 -5
- data/lib/emojidex/version.rb +0 -3
- data/lib/generators/emojidex/install/install_generator.rb +0 -35
- data/lib/tasks/emojidex_tasks.rake +0 -4
- data/test/controllers/emojidex/cheat_sheet_controller_test.rb +0 -11
- data/test/dummy/README.rdoc +0 -28
- data/test/dummy/Rakefile +0 -6
- data/test/dummy/app/assets/images/.keep +0 -0
- data/test/dummy/app/assets/javascripts/application.js +0 -13
- data/test/dummy/app/assets/stylesheets/application.css +0 -13
- data/test/dummy/app/controllers/application_controller.rb +0 -5
- data/test/dummy/app/controllers/concerns/.keep +0 -0
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/mailers/.keep +0 -0
- data/test/dummy/app/models/.keep +0 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/bin/bundle +0 -3
- data/test/dummy/bin/rails +0 -4
- data/test/dummy/bin/rake +0 -4
- data/test/dummy/config.ru +0 -4
- data/test/dummy/config/application.rb +0 -23
- data/test/dummy/config/boot.rb +0 -5
- data/test/dummy/config/database.yml +0 -25
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -29
- data/test/dummy/config/environments/production.rb +0 -80
- data/test/dummy/config/environments/test.rb +0 -36
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/dummy/config/initializers/inflections.rb +0 -16
- data/test/dummy/config/initializers/mime_types.rb +0 -5
- data/test/dummy/config/initializers/secret_token.rb +0 -12
- data/test/dummy/config/initializers/session_store.rb +0 -3
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -23
- data/test/dummy/config/routes.rb +0 -4
- data/test/dummy/lib/assets/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/public/404.html +0 -58
- data/test/dummy/public/422.html +0 -58
- data/test/dummy/public/500.html +0 -57
- data/test/dummy/public/favicon.ico +0 -0
- data/test/emojidex_test.rb +0 -7
- data/test/helpers/emojidex/cheat_sheet_helper_test.rb +0 -6
- data/test/integration/navigation_test.rb +0 -10
- data/test/test_helper.rb +0 -15
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
module Emojidex
|
|
4
|
+
# Holds a master list of categories
|
|
5
|
+
class Categories
|
|
6
|
+
attr_accessor :categories
|
|
7
|
+
|
|
8
|
+
def initialize(categories_json = nil)
|
|
9
|
+
if categories_json
|
|
10
|
+
load_categories(categories_json)
|
|
11
|
+
else
|
|
12
|
+
load_standard_categories
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def load_categories(json)
|
|
17
|
+
raw = JSON.parse(json, symbolize_names: true)
|
|
18
|
+
raw = raw[:categories]
|
|
19
|
+
|
|
20
|
+
@categories ||= {}
|
|
21
|
+
raw.each do |category_info|
|
|
22
|
+
category = Emojidex::Category.new category_info
|
|
23
|
+
@categories[category.code.to_sym] = category
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def load_standard_categories
|
|
28
|
+
load_categories(IO.read(
|
|
29
|
+
File.expand_path('../../../emoji/categories.json', __FILE__)))
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require 'faraday'
|
|
2
|
+
require 'faraday_middleware'
|
|
3
|
+
|
|
4
|
+
require 'emojidex/api/categories'
|
|
5
|
+
require 'emojidex/api/emoji'
|
|
6
|
+
require 'emojidex/api/search/emoji'
|
|
7
|
+
|
|
8
|
+
module Emojidex
|
|
9
|
+
# get the data from emojidex.com
|
|
10
|
+
class Client
|
|
11
|
+
attr_accessor :api_key, :api_username
|
|
12
|
+
attr_reader :host
|
|
13
|
+
|
|
14
|
+
include Emojidex::API::Categories
|
|
15
|
+
include Emojidex::API::Emoji
|
|
16
|
+
include Emojidex::API::Search::Emoji
|
|
17
|
+
|
|
18
|
+
def initialize(opts = {})
|
|
19
|
+
@api_key = opts[:api_key]
|
|
20
|
+
@api_username = opts[:api_username]
|
|
21
|
+
@host = opts[:host] || 'https://www.emojidex.com/'
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def connection_options
|
|
25
|
+
@connection_options ||= {
|
|
26
|
+
url: @host,
|
|
27
|
+
headers: {
|
|
28
|
+
accept: 'application/json',
|
|
29
|
+
user_agent: user_agent
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def user_agent
|
|
35
|
+
@user_agent ||= 'Emojidex Toolkit Client'
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def get(path, params = {})
|
|
39
|
+
request(:get, path, params)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
private
|
|
43
|
+
|
|
44
|
+
def connection
|
|
45
|
+
@connection ||= Faraday.new connection_options do |conn|
|
|
46
|
+
conn.request :url_encoded
|
|
47
|
+
conn.response :json
|
|
48
|
+
# conn.response :logger
|
|
49
|
+
conn.adapter Faraday.default_adapter
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def request(method, path, params = {})
|
|
54
|
+
response = connection.send(method.to_sym, path, params)
|
|
55
|
+
response.env
|
|
56
|
+
rescue Faraday::Error::ClientError, JSON::ParserError
|
|
57
|
+
raise Emojidex::Error
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
end
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
|
|
3
|
+
require 'json'
|
|
4
|
+
require_relative 'emoji'
|
|
5
|
+
require_relative 'categories'
|
|
6
|
+
require_relative 'cache'
|
|
7
|
+
|
|
8
|
+
module Emojidex
|
|
9
|
+
# listing and search of standard UTF emoji
|
|
10
|
+
class Collection
|
|
11
|
+
include Emojidex::Cache
|
|
12
|
+
attr_accessor :emoji, :categories
|
|
13
|
+
attr_reader :source_path
|
|
14
|
+
# Initialize Collection. You can pass a list of emoji to seed the collection
|
|
15
|
+
def initialize(emoji_list = nil)
|
|
16
|
+
@emoji = {}
|
|
17
|
+
add_emoji(emoji_list) unless emoji_list.nil?
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# Loads an emoji collection on local storage
|
|
21
|
+
def load_local_collection(path)
|
|
22
|
+
@source_path = File.expand_path(path)
|
|
23
|
+
json = IO.read(@source_path + '/emoji.json')
|
|
24
|
+
list = JSON.parse(json, symbolize_names: true)
|
|
25
|
+
add_emoji(list)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# each override to map each functionality to the emoji hash values
|
|
29
|
+
def each
|
|
30
|
+
return @emoji.values.each unless block_given?
|
|
31
|
+
@emoji.values.each { |emoji| yield emoji }
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
# select override to map select functionality to the emoji hash values
|
|
35
|
+
def select
|
|
36
|
+
return @emoji.values.select unless block_given?
|
|
37
|
+
@emoji.values.select { |emoji| yield emoji }
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# Retreives an Emoji object by the actual moji code/character code
|
|
41
|
+
# Will likely only return moji from UTF collection
|
|
42
|
+
def find_by_moji(moji)
|
|
43
|
+
result = nil
|
|
44
|
+
each do |emoji|
|
|
45
|
+
result = emoji if emoji[:moji] == moji
|
|
46
|
+
end
|
|
47
|
+
result
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
alias_method :文字検索, :find_by_moji
|
|
51
|
+
|
|
52
|
+
# Gets the emoji with the specified code
|
|
53
|
+
# Returns the Emoji object or nil if no emoji with that code is found
|
|
54
|
+
def find_by_code(code)
|
|
55
|
+
@emoji[code.gsub(/\s/, '_').to_sym]
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
# Locates emoji by Japanese code (original Japanese emoji name [絵文字名])
|
|
59
|
+
# Only applies to collections that contain JA codes, this function is mapped to
|
|
60
|
+
# find_by_code for all other implementations (such as client)
|
|
61
|
+
def find_by_code_ja(code_ja)
|
|
62
|
+
each do |emoji|
|
|
63
|
+
return emoji if emoji[:code_ja] == code_ja
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
alias_method :コード検索, :find_by_code_ja
|
|
68
|
+
|
|
69
|
+
def search(criteria = {})
|
|
70
|
+
Emojidex::Collection.new _sub_search(@emoji.values.dup, criteria)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Get all emoji from this collection that are part of the specified category
|
|
74
|
+
# Returns a new collection of only emoji in the specified category
|
|
75
|
+
def category(category_code)
|
|
76
|
+
categorized = @emoji.values.select { |moji| moji.category == category_code }
|
|
77
|
+
Emojidex::Collection.new categorized
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
# Check to see if there are emoji in this collection which have the specified categories
|
|
81
|
+
# Returns true if there are emoji for all secified categories within this collection
|
|
82
|
+
def category?(*category_codes)
|
|
83
|
+
(category_codes.uniq - @categories).empty?
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
# Adds emojis to the collection
|
|
87
|
+
# After add categories are updated
|
|
88
|
+
def add_emoji(list)
|
|
89
|
+
list.each do |moji_info|
|
|
90
|
+
if moji_info.instance_of? Emojidex::Emoji
|
|
91
|
+
@emoji[moji_info.code.to_sym] = moji_info.dup
|
|
92
|
+
else
|
|
93
|
+
emoji = Emojidex::Emoji.new moji_info
|
|
94
|
+
@emoji[emoji.code.to_sym] = emoji
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
categorize
|
|
98
|
+
@emoji
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
alias_method :<<, :add_emoji
|
|
102
|
+
|
|
103
|
+
private
|
|
104
|
+
|
|
105
|
+
# Makes a list of all categories which contain emoji in this collection
|
|
106
|
+
def categorize
|
|
107
|
+
@categories = @emoji.values.map { |moji| moji.category }
|
|
108
|
+
@categories.uniq!
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def _sub_search(list, criteria = {})
|
|
112
|
+
cr = criteria.shift
|
|
113
|
+
return list if cr.nil?
|
|
114
|
+
|
|
115
|
+
list = list.select { |moji| moji if moji[cr[0]] =~ /#{cr[1]}/ }
|
|
116
|
+
_sub_search(list, criteria)
|
|
117
|
+
end
|
|
118
|
+
end
|
|
119
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
module Emojidex
|
|
2
|
+
# Global defines for emojidex
|
|
3
|
+
class Defaults
|
|
4
|
+
def self.sizes
|
|
5
|
+
{ ldpi: 9, mdpi: 18, hdpi: 27, xhdpi: 36, px8: 8,
|
|
6
|
+
px16: 16, px32: 32, px64: 64, px128: 128, px256: 256 }
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def self.formats
|
|
10
|
+
[':svg', ':png']
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
#
|
|
2
|
+
# Emojidex::Emoji
|
|
3
|
+
#
|
|
4
|
+
module Emojidex
|
|
5
|
+
# emoji base class
|
|
6
|
+
class Emoji
|
|
7
|
+
attr_accessor :moji, :category, :code, :unicode,
|
|
8
|
+
:tags, :frames, :delays
|
|
9
|
+
|
|
10
|
+
def initialize(details = {})
|
|
11
|
+
@moji = details[:moji]
|
|
12
|
+
@code, @code_ja = details[:code], details[:code_ja]
|
|
13
|
+
@unicode = details[:unicode]
|
|
14
|
+
@category = details[:category] ? details[:category].to_sym : :other
|
|
15
|
+
@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
|
+
@link = details[:link]
|
|
20
|
+
@is_wide = details[:is_wide]
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def to_s
|
|
24
|
+
@moji || ':' + @code + ':'
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def to_json(*args)
|
|
28
|
+
to_hash.to_json(*args)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def to_hash
|
|
32
|
+
hash = {}
|
|
33
|
+
instance_variables.each do |key|
|
|
34
|
+
hash[key.to_s.delete('@')] = instance_variable_get(key)
|
|
35
|
+
end
|
|
36
|
+
hash
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def [](key)
|
|
40
|
+
instance_variable_get(key.to_s.delete(':').insert(0, '@'))
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def []=(key, val)
|
|
44
|
+
instance_variable_set(key.to_s.delete(':').insert(0, '@'), val)
|
|
45
|
+
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
|
+
end
|
|
74
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
load_local_collection Emojidex::Vectors.path + '/extended'
|
|
10
|
+
else
|
|
11
|
+
# TODO load from service
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
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
|
|
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
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
load_local_collection Emojidex::Vectors.path + '/utf'
|
|
10
|
+
else
|
|
11
|
+
# TODO load from service
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
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
|