emojidex 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/emojidex.gemspec +1 -1
- data/lib/emojidex/service/search.rb +19 -2
- data/lib/emojidex/service/transactor.rb +4 -4
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9a0a7030ddea5f1db4f22841a0abf07236d1092
|
4
|
+
data.tar.gz: 587a65ce35b88e0cc5e6d79f158b7e8c467abcbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cad92f427bf8968bd1dc181bffbdbecd964f11187851f9aeb5ab5039628db47b372f9bf0643e965d520846d4894914a1ba74e853d67017a8c38963048bfe1704
|
7
|
+
data.tar.gz: 3b5c9512c07b1700156cb9813387977b1805e167dd495a2e02f60c20d9f3dbaf2178151dd6a51a57184cd3e8dec86e5e800b89e69bd05c9470ebbc3ffc31caf8
|
data/emojidex.gemspec
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
require_relative '../defaults'
|
2
|
+
require_relative 'transactor'
|
2
3
|
require_relative 'collection'
|
3
4
|
require_relative '../../emojidex'
|
5
|
+
require_relative '../client'
|
4
6
|
|
5
7
|
module Emojidex
|
6
8
|
module Service
|
@@ -60,6 +62,20 @@ module Emojidex
|
|
60
62
|
_do_search(opts)
|
61
63
|
end
|
62
64
|
|
65
|
+
# Looks directly for an emoji with the exact code provided, returning
|
66
|
+
# only the emoji object if found, and nil if not. The find method is unique
|
67
|
+
# in the Search module as it is the only method that doesn't actually search,
|
68
|
+
# it just looks up the code directly.
|
69
|
+
# The only options you can specify are :username and :auth_token for if you
|
70
|
+
# are not initializing a User within the client but still want to return R-18
|
71
|
+
# emoji for users that have them enabled.
|
72
|
+
def self.find(code, opts = {})
|
73
|
+
res = Emojidex::Service::Transactor.get("emoji/#{Emojidex.escape_code(code)}",
|
74
|
+
_check_auth(opts));
|
75
|
+
return nil if res.include? :error
|
76
|
+
Emojidex::Data::Emoji.new(res)
|
77
|
+
end
|
78
|
+
|
63
79
|
private
|
64
80
|
|
65
81
|
def self._sanitize_opts(opts)
|
@@ -70,6 +86,7 @@ module Emojidex
|
|
70
86
|
|
71
87
|
def self._do_search(opts)
|
72
88
|
opts = _sanitize_opts(opts)
|
89
|
+
opts = _check_auth(opts)
|
73
90
|
opts[:endpoint] = 'search/emoji'
|
74
91
|
begin
|
75
92
|
col = Emojidex::Service::Collection.new(opts)
|
@@ -81,8 +98,8 @@ module Emojidex
|
|
81
98
|
|
82
99
|
def self._check_auth(opts)
|
83
100
|
if !(opts.include? :auth_token) && Emojidex::Client.USER.authorized?
|
84
|
-
opts[:username] = Emojidex::Client
|
85
|
-
opts[:auth_token] = Emojidex::Client
|
101
|
+
opts[:username] = Emojidex::Client.USER.username
|
102
|
+
opts[:auth_token] = Emojidex::Client.USER.auth_token
|
86
103
|
end
|
87
104
|
|
88
105
|
opts
|
@@ -11,7 +11,7 @@ module Emojidex
|
|
11
11
|
# API transaction utility
|
12
12
|
class Transactor
|
13
13
|
@@connection = nil
|
14
|
-
|
14
|
+
#@@retries = 10
|
15
15
|
|
16
16
|
@@settings = {
|
17
17
|
api: {
|
@@ -29,7 +29,7 @@ module Emojidex
|
|
29
29
|
|
30
30
|
def self.get(endpoint, params = {})
|
31
31
|
response = connect.get(
|
32
|
-
"#{api_url}#{endpoint}", params)
|
32
|
+
"#{api_url}#{URI.encode(endpoint)}", params)
|
33
33
|
|
34
34
|
_status_raiser(response)
|
35
35
|
_datafy_json(response.body)
|
@@ -59,8 +59,8 @@ module Emojidex
|
|
59
59
|
return @@connection if @@connection
|
60
60
|
@@connection = Faraday.new do |conn|
|
61
61
|
conn.request :url_encoded
|
62
|
-
conn.request :retry, max: @@retries, interval: 0.05, interval_randomness: 0.5,
|
63
|
-
|
62
|
+
#conn.request :retry, max: @@retries, interval: 0.05, interval_randomness: 0.5,
|
63
|
+
# backoff_factor: 2
|
64
64
|
# conn.response :logger
|
65
65
|
conn.use FaradayMiddleware::FollowRedirects, limit: 5
|
66
66
|
conn.adapter :typhoeus #Faraday.default_adapter
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: emojidex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rei Kagetsuki
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -125,7 +125,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
125
|
version: '0'
|
126
126
|
requirements: []
|
127
127
|
rubyforge_project:
|
128
|
-
rubygems_version: 2.
|
128
|
+
rubygems_version: 2.6.11
|
129
129
|
signing_key:
|
130
130
|
specification_version: 4
|
131
131
|
summary: emojidex Ruby tools
|