giphyrb 0.1.1 → 0.2
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 +1 -0
- data/README.MD +3 -4
- data/giphyrb.gemspec +1 -1
- data/lib/giphyrb.rb +65 -32
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3269d612a4d65ab52aee537e67361d5c6442ccc8
|
4
|
+
data.tar.gz: 4a2e1a9c3bec82d830a1840675de27842d9fe47b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d29b2607aa8d52d8365e6c4a23a7bee4a8b8cf93a298bf630bf7581d2da4c72ef79f1e291e7a39c204340dbe6aecce13726e4e87c23bf90a4c58f29bcc97f1d
|
7
|
+
data.tar.gz: ad6fc01e3b4d2af3f21839a9df5b6ae860c10d8138dc63cc45dfeaae2e063f92cb9464997276b806bc4b0330315e8f2d2be20eac24afbf7025b0bc97b5238f28
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/README.MD
CHANGED
@@ -62,8 +62,7 @@ giphy.from_ids(ids=[])
|
|
62
62
|
|
63
63
|
See [LICENSE](https://github.com/Whaxion/giphyrb/blob/master/LICENSE) for details.
|
64
64
|
|
65
|
-
##TODO list
|
65
|
+
## TODO list
|
66
66
|
|
67
|
-
- Add
|
68
|
-
-
|
69
|
-
- Improve user experience (new syntax)
|
67
|
+
- Add Stickers packs
|
68
|
+
- Improve user experience (new syntax)
|
data/giphyrb.gemspec
CHANGED
@@ -2,7 +2,7 @@ require_relative 'lib/giphyrb'
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.summary = 'Giphy API wrapper'
|
5
|
-
s.description =
|
5
|
+
s.description = GiphyRB::Giphy::DESCRIPTION
|
6
6
|
s.authors = ['Whaxion']
|
7
7
|
s.email = ['whaxion@gmail.com']
|
8
8
|
s.homepage = 'http://github.com/whaxion/giphyrb'
|
data/lib/giphyrb.rb
CHANGED
@@ -11,7 +11,8 @@ module GiphyRB
|
|
11
11
|
|
12
12
|
ENDPOINT = 'http://api.giphy.com'
|
13
13
|
API_VERSION = 'v1'
|
14
|
-
VERSION = '0.
|
14
|
+
VERSION = '0.2'
|
15
|
+
DESCRIPTION ='A simple Giphy API Wrapper supporting Stickers API (except Stickers pack)'
|
15
16
|
|
16
17
|
# Initialize the client
|
17
18
|
def initialize(api_key:true)
|
@@ -19,14 +20,12 @@ module GiphyRB
|
|
19
20
|
end
|
20
21
|
|
21
22
|
# Search all GIPHY GIFs for a word or phrase. Punctuation will be stripped and ignored. Use a plus or url encode for phrases.
|
22
|
-
#
|
23
|
-
#
|
24
|
-
#
|
25
|
-
#
|
26
|
-
#
|
27
|
-
#
|
28
|
-
# == Return
|
29
|
-
# Responses::Search
|
23
|
+
# @param query [String] Search query term or phrase
|
24
|
+
# @param limit [Int] The maximum number of records to return (default=5)
|
25
|
+
# @param offset [Int] An optional results offset. (default=0)
|
26
|
+
# @param rating [String] Filters results by specified rating (default=g)
|
27
|
+
# @param lang [String] Specify default language for regional content; use a 2-letter ISO 639-1 language code (default=nil)
|
28
|
+
# @return [Responses::Search]
|
30
29
|
def search(query, limit=5, offset=0, rating='g', lang=nil)
|
31
30
|
params = {:q => query, :limit => limit.to_i, :offset => offset.to_i, :rating => rating}
|
32
31
|
params[:lang] = lang unless lang == nil
|
@@ -35,12 +34,10 @@ module GiphyRB
|
|
35
34
|
end
|
36
35
|
|
37
36
|
# Fetch GIFs currently trending online. Hand curated by the GIPHY editorial team. The data returned mirrors the GIFs showcased on the GIPHY homepage.
|
38
|
-
#
|
39
|
-
#
|
40
|
-
#
|
41
|
-
#
|
42
|
-
# == Return
|
43
|
-
# Responses::Trending
|
37
|
+
# @param limit [Int] The maximum number of records to return (default=5)
|
38
|
+
# @param offset [Int] An optional results offset. (default=0)
|
39
|
+
# @param rating [String] Filters results by specified rating (default=g)
|
40
|
+
# @return [Responses::Trending]
|
44
41
|
def trending(limit=5, offset=0, rating='g')
|
45
42
|
params = {:limit => limit.to_i, :offset => offset.to_i, :rating => rating}
|
46
43
|
result = request'gifs/trending', params
|
@@ -48,10 +45,8 @@ module GiphyRB
|
|
48
45
|
end
|
49
46
|
|
50
47
|
# The translate API draws on search, but uses the GIPHY special sauce to handle translating from one vocabulary to another. In this case, words and phrases to GIFs.
|
51
|
-
#
|
52
|
-
#
|
53
|
-
# == Return
|
54
|
-
# Responses::Translate
|
48
|
+
# @param string [String] Search term
|
49
|
+
# @return [Responses::Translate]
|
55
50
|
def translate(string)
|
56
51
|
params = {:s => string}
|
57
52
|
result = request'gifs/translate', params
|
@@ -59,11 +54,9 @@ module GiphyRB
|
|
59
54
|
end
|
60
55
|
|
61
56
|
# Returns a random GIF, limited by tag. Excluding the tag parameter will return a random GIF from the GIPHY catalog.
|
62
|
-
#
|
63
|
-
#
|
64
|
-
#
|
65
|
-
# == Return
|
66
|
-
# Responses::Random
|
57
|
+
# @param tag [String] Filters results by specified tag
|
58
|
+
# @param rating [String] Filters results by specified rating (default=g)
|
59
|
+
# @return [Responses::Random]
|
67
60
|
def random(tag=nil, rating='g')
|
68
61
|
params = {:tag => tag, :rating => rating}
|
69
62
|
result = request'gifs/random', params
|
@@ -71,10 +64,8 @@ module GiphyRB
|
|
71
64
|
end
|
72
65
|
|
73
66
|
# Returns a GIF given that GIF's unique ID.
|
74
|
-
#
|
75
|
-
#
|
76
|
-
# == Return
|
77
|
-
# Response
|
67
|
+
# @param id [String] Filters results by specified GIF ID
|
68
|
+
# @return [Response]
|
78
69
|
def from_id(id)
|
79
70
|
params = {}
|
80
71
|
result = request'gifs/' + id.to_s, params
|
@@ -82,10 +73,8 @@ module GiphyRB
|
|
82
73
|
end
|
83
74
|
|
84
75
|
# A multiget version of the get GIF by ID endpoint
|
85
|
-
#
|
86
|
-
#
|
87
|
-
# == Return
|
88
|
-
# Response
|
76
|
+
# @param ids [Array<String>] Filters results by specified GIF IDs
|
77
|
+
# @return [Response]
|
89
78
|
def from_ids(ids=[])
|
90
79
|
ids = Array(ids)
|
91
80
|
ids = ids.join ','
|
@@ -94,6 +83,50 @@ module GiphyRB
|
|
94
83
|
Response.new(result)
|
95
84
|
end
|
96
85
|
|
86
|
+
# Replicates the functionality and requirements of the classic GIPHY search, but returns animated stickers rather than GIFs.
|
87
|
+
# @param query [String] Search query term or phrase
|
88
|
+
# @param limit [Int] The maximum number of records to return (default=5)
|
89
|
+
# @param offset [Int] An optional results offset. (default=0)
|
90
|
+
# @param rating [String] Filters results by specified rating (default=g)
|
91
|
+
# @param lang [String] Specify default language for regional content; use a 2-letter ISO 639-1 language code (default=nil)
|
92
|
+
# @return [Responses::Search]
|
93
|
+
def sticker_search(query, limit=5, offset=0, rating='g', lang=nil)
|
94
|
+
params = {:q => query, :limit => limit.to_i, :offset => offset.to_i, :rating => rating}
|
95
|
+
params[:lang] = lang unless lang == nil
|
96
|
+
result = request'stickers/search', params
|
97
|
+
Responses::Search.new(result, query)
|
98
|
+
end
|
99
|
+
|
100
|
+
# Fetch Stickers currently trending online. Hand curated by the GIPHY editorial team.
|
101
|
+
# @param limit [Int] The maximum number of records to return (default=5)
|
102
|
+
# @param offset [Int] An optional results offset. (default=0)
|
103
|
+
# @param rating [String] Filters results by specified rating (default=g)
|
104
|
+
# @return [Responses::Trending]
|
105
|
+
def sticker_trending(limit=5, offset=0, rating='g')
|
106
|
+
params = {:limit => limit.to_i, :offset => offset.to_i, :rating => rating}
|
107
|
+
result = request'stickers/trending', params
|
108
|
+
Responses::Trending.new(result)
|
109
|
+
end
|
110
|
+
|
111
|
+
# The translate API draws on search, but uses the GIPHY special sauce to handle translating from one vocabulary to another. In this case, words and phrases to GIFs.
|
112
|
+
# @param string [String] Search term
|
113
|
+
# @return [Responses::Translate]
|
114
|
+
def sticker_translate(string)
|
115
|
+
params = {:s => string}
|
116
|
+
result = request'stickers/translate', params
|
117
|
+
Responses::Translate.new(result)
|
118
|
+
end
|
119
|
+
|
120
|
+
# Returns a random Sticker, limited by tag. Excluding the tag parameter will return a random Sticker from the GIPHY catalog.
|
121
|
+
# @param tag [String] Filters results by specified tag
|
122
|
+
# @param rating [String] Filters results by specified rating (default=g)
|
123
|
+
# @return [Responses::Random]
|
124
|
+
def sticker_random(tag=nil, rating='g')
|
125
|
+
params = {:tag => tag, :rating => rating}
|
126
|
+
result = request'stickers/random', params
|
127
|
+
Responses::Random.new(result, tag)
|
128
|
+
end
|
129
|
+
|
97
130
|
private
|
98
131
|
|
99
132
|
def request(url, params)
|
metadata
CHANGED
@@ -1,22 +1,23 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: giphyrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: '0.2'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Whaxion
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-22 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: A simple Giphy API Wrapper
|
13
|
+
description: A simple Giphy API Wrapper supporting Stickers API (except Stickers pack)
|
14
14
|
email:
|
15
15
|
- whaxion@gmail.com
|
16
16
|
executables: []
|
17
17
|
extensions: []
|
18
18
|
extra_rdoc_files: []
|
19
19
|
files:
|
20
|
+
- ".gitignore"
|
20
21
|
- LICENSE
|
21
22
|
- README.MD
|
22
23
|
- giphyrb.gemspec
|