giphyrb 0.1 → 0.1.1
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/README.MD +13 -6
- data/giphyrb.gemspec +3 -1
- data/lib/giphyrb.rb +40 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d219e3e52055561188677535177d1526b5cd04eb
|
4
|
+
data.tar.gz: 6c14791d1ee93b2eeace31726f94473edbcaa3c7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bad7c46279544a65b77076a43105ae91af419159ab1e3531f7e16581393f7bf710aa0bd74f8f8468a3e764b7c5113311aa921f919bac741cf23ce98b49cce8e7
|
7
|
+
data.tar.gz: 6fc5bc7a42372048ae7d7d488d8a771325b70d6107b57d43bb318b3410dbfd995903120a1b38c122f9392aa7a00b56e144b6378fd7a86aeaeeea071b7f478618
|
data/README.MD
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# GiphyRB
|
2
|
+
[](https://badge.fury.io/rb/giphyrb)
|
2
3
|
## Installation
|
3
4
|
|
4
5
|
Add this line to your application's Gemfile:
|
@@ -29,34 +30,40 @@ giphy.trending(limit=5, offset=0, rating='g')
|
|
29
30
|
|
30
31
|
#### Translate
|
31
32
|
````ruby
|
32
|
-
|
33
|
+
giphy.translate(string)
|
33
34
|
=> GiphyRB::Responses::Translate
|
34
35
|
````
|
35
36
|
|
36
37
|
#### Search
|
37
38
|
````ruby
|
38
|
-
|
39
|
+
giphy.search(query, limit=5, offset=0, rating='g', lang=nil)
|
39
40
|
=> GiphyRB::Responses::Search
|
40
41
|
````
|
41
42
|
|
42
43
|
#### Random
|
43
44
|
````ruby
|
44
|
-
|
45
|
+
giphy.random(tag=nil, rating='g')
|
45
46
|
=> GiphyRB::Responses::Random
|
46
47
|
````
|
47
48
|
|
48
49
|
#### GIF by ID
|
49
50
|
````ruby
|
50
|
-
|
51
|
+
giphy.from_id(id)
|
51
52
|
=> GiphyRB::Response
|
52
53
|
````
|
53
54
|
|
54
55
|
#### GIFs by IDs
|
55
56
|
````ruby
|
56
|
-
|
57
|
+
giphy.from_ids(ids=[])
|
57
58
|
=> GiphyRB::Response
|
58
59
|
````
|
59
60
|
|
60
61
|
## License
|
61
62
|
|
62
|
-
See [LICENSE](https://github.com/Whaxion/giphyrb/blob/master/LICENSE) for details.
|
63
|
+
See [LICENSE](https://github.com/Whaxion/giphyrb/blob/master/LICENSE) for details.
|
64
|
+
|
65
|
+
##TODO list
|
66
|
+
|
67
|
+
- Add Sticker API
|
68
|
+
- Document code
|
69
|
+
- Improve user experience (new syntax)
|
data/giphyrb.gemspec
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require_relative 'lib/giphyrb'
|
2
|
+
|
1
3
|
Gem::Specification.new do |s|
|
2
4
|
s.summary = 'Giphy API wrapper'
|
3
5
|
s.description = 'A simple Giphy API Wrapper'
|
@@ -10,5 +12,5 @@ Gem::Specification.new do |s|
|
|
10
12
|
s.license = 'MIT'
|
11
13
|
|
12
14
|
s.name = 'giphyrb'
|
13
|
-
s.version =
|
15
|
+
s.version = GiphyRB::Giphy::VERSION
|
14
16
|
end
|
data/lib/giphyrb.rb
CHANGED
@@ -11,11 +11,22 @@ module GiphyRB
|
|
11
11
|
|
12
12
|
ENDPOINT = 'http://api.giphy.com'
|
13
13
|
API_VERSION = 'v1'
|
14
|
+
VERSION = '0.1.1'
|
14
15
|
|
16
|
+
# Initialize the client
|
15
17
|
def initialize(api_key:true)
|
16
18
|
@api_key = api_key
|
17
19
|
end
|
18
20
|
|
21
|
+
# Search all GIPHY GIFs for a word or phrase. Punctuation will be stripped and ignored. Use a plus or url encode for phrases.
|
22
|
+
# == Arguments
|
23
|
+
# +query+:: Search query term or phrase
|
24
|
+
# +limit+:: The maximum number of records to return (default=5)
|
25
|
+
# +offset+:: An optional results offset. (default=0)
|
26
|
+
# +rating+:: Filters results by specified rating (default=g)
|
27
|
+
# +lang+:: Specify default language for regional content; use a 2-letter ISO 639-1 language code (default=nil)
|
28
|
+
# == Return
|
29
|
+
# Responses::Search
|
19
30
|
def search(query, limit=5, offset=0, rating='g', lang=nil)
|
20
31
|
params = {:q => query, :limit => limit.to_i, :offset => offset.to_i, :rating => rating}
|
21
32
|
params[:lang] = lang unless lang == nil
|
@@ -23,30 +34,58 @@ module GiphyRB
|
|
23
34
|
Responses::Search.new(result, query)
|
24
35
|
end
|
25
36
|
|
37
|
+
# Fetch GIFs currently trending online. Hand curated by the GIPHY editorial team. The data returned mirrors the GIFs showcased on the GIPHY homepage.
|
38
|
+
# == Arguments
|
39
|
+
# +limit+:: The maximum number of records to return (default=5)
|
40
|
+
# +offset+:: An optional results offset. (default=0)
|
41
|
+
# +rating+:: Filters results by specified rating (default=g)
|
42
|
+
# == Return
|
43
|
+
# Responses::Trending
|
26
44
|
def trending(limit=5, offset=0, rating='g')
|
27
45
|
params = {:limit => limit.to_i, :offset => offset.to_i, :rating => rating}
|
28
46
|
result = request'gifs/trending', params
|
29
47
|
Responses::Trending.new(result)
|
30
48
|
end
|
31
49
|
|
50
|
+
# 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
|
+
# == Arguments
|
52
|
+
# +string+:: Search term
|
53
|
+
# == Return
|
54
|
+
# Responses::Translate
|
32
55
|
def translate(string)
|
33
56
|
params = {:s => string}
|
34
57
|
result = request'gifs/translate', params
|
35
|
-
Responses::
|
58
|
+
Responses::Translate.new(result)
|
36
59
|
end
|
37
60
|
|
61
|
+
# Returns a random GIF, limited by tag. Excluding the tag parameter will return a random GIF from the GIPHY catalog.
|
62
|
+
# == Arguments
|
63
|
+
# +tag+:: Filters results by specified tag
|
64
|
+
# +rating+:: Filters results by specified rating (default=g)
|
65
|
+
# == Return
|
66
|
+
# Responses::Random
|
38
67
|
def random(tag=nil, rating='g')
|
39
68
|
params = {:tag => tag, :rating => rating}
|
40
69
|
result = request'gifs/random', params
|
41
70
|
Responses::Random.new(result, tag)
|
42
71
|
end
|
43
72
|
|
73
|
+
# Returns a GIF given that GIF's unique ID.
|
74
|
+
# == Arguments
|
75
|
+
# +id+:: Filters results by specified GIF ID
|
76
|
+
# == Return
|
77
|
+
# Response
|
44
78
|
def from_id(id)
|
45
79
|
params = {}
|
46
80
|
result = request'gifs/' + id.to_s, params
|
47
81
|
Response.new(result)
|
48
82
|
end
|
49
83
|
|
84
|
+
# A multiget version of the get GIF by ID endpoint
|
85
|
+
# == Arguments
|
86
|
+
# +ids+:: Filters results by specified GIF IDs (Array)
|
87
|
+
# == Return
|
88
|
+
# Response
|
50
89
|
def from_ids(ids=[])
|
51
90
|
ids = Array(ids)
|
52
91
|
ids = ids.join ','
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: giphyrb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 0.1.1
|
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-21 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A simple Giphy API Wrapper
|
14
14
|
email:
|