liblab_the_one 0.2.0 → 0.3.0
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/Gemfile.lock +1 -1
- data/README.md +17 -6
- data/lib/liblab/quote/guess_the_quote.rb +34 -0
- data/lib/liblab/version.rb +1 -1
- data/lib/liblab.rb +1 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 26956ba91f4879a09844057d5b0738c308793845c10bf181d2f0772ad534743a
|
4
|
+
data.tar.gz: ffacc57af7e65676ed63a5ec1723273b7134ae4d3a8c9b16c9f46875651b4d7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e98bdb3e2251d0233407bc2738c62ecebc50455fdde8cf37e6bd195f132692ce269df0be97f565c34d4cfa20e8af2ab04331fc3734b0cd0d872cc2fcf70a8d5b
|
7
|
+
data.tar.gz: e461d819b73aaa5faf06888b96891ba4231eac84435b6d92f68086b8828a0b68e131e7f12547061036efa4b1202e7176e81fa778ab173f750e4c8df253ab7fc5
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,6 +4,14 @@ This gem is an API wrapper for (the one api)[https://the-one-api.dev/].
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
+
Install `ruby` and `bundler`
|
8
|
+
|
9
|
+
Add the following environment variables. You can request an `access_token` at https://the-one-api.dev/.
|
10
|
+
|
11
|
+
```
|
12
|
+
LIBLAB_ACCESS_TOKEN=
|
13
|
+
```
|
14
|
+
|
7
15
|
Add this line to your application's Gemfile:
|
8
16
|
|
9
17
|
```ruby
|
@@ -17,6 +25,8 @@ And then execute:
|
|
17
25
|
Or install it yourself as:
|
18
26
|
|
19
27
|
$ gem install pex_api
|
28
|
+
|
29
|
+
After installing you can test by running `irb`, then `require "liblab"` and then running `Liblab::Movie::List.call()` This should return a list of movies.
|
20
30
|
|
21
31
|
## Usage
|
22
32
|
`Liblab::Movie::List.call()` will get a list of movies
|
@@ -31,15 +41,16 @@ Or install it yourself as:
|
|
31
41
|
|
32
42
|
`Liblab::Quote::Get.call(quote_id)` will retrieve an individual quote
|
33
43
|
|
34
|
-
Each class/method will have it's own parameters depending on the type of request and it's expected input parameters.
|
35
44
|
|
36
|
-
|
45
|
+
## Bonus Game: Guess the quote!
|
37
46
|
|
38
|
-
|
47
|
+
Help test and build your Lord of The Rings knowledge.
|
39
48
|
|
40
|
-
|
41
|
-
|
42
|
-
|
49
|
+
Use `Liblab::Quote::GuessTheQuote.call()` to return a random quote with a movie name.
|
50
|
+
|
51
|
+
You can tell people the quote and they have to guess the movie.
|
52
|
+
|
53
|
+
Example response is `{:quote=>"Your bodyguard?", :movie_name=>"The Two Towers"}`
|
43
54
|
|
44
55
|
## Development
|
45
56
|
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Liblab
|
2
|
+
module Quote
|
3
|
+
class GuessTheQuote
|
4
|
+
|
5
|
+
# Example returns {:quote=>"Your bodyguard?", :movie_name=>"The Two Towers"}
|
6
|
+
|
7
|
+
def self.call()
|
8
|
+
page = rand(2)
|
9
|
+
_path = "quote?page=#{page}"
|
10
|
+
|
11
|
+
# Get a random page of quotes
|
12
|
+
quote_result = ::Liblab::Client::Base.new.get(_path)
|
13
|
+
|
14
|
+
if quote_result.code == 200
|
15
|
+
# Get a random quote from returned quotes
|
16
|
+
index = rand(999)
|
17
|
+
quote = JSON.parse(quote_result.body)["docs"][index]
|
18
|
+
movie_result = ::Liblab::Movie::Get.call(quote["movie"])
|
19
|
+
|
20
|
+
if movie_result.code == 200
|
21
|
+
# Get movie name for the selected quote
|
22
|
+
movie = JSON.parse(movie_result.body)["docs"][0]
|
23
|
+
|
24
|
+
return { quote: quote["dialog"], movie_name: movie["name"] }
|
25
|
+
else
|
26
|
+
return { error: "Could not get movie_result", message: movie_result.body }
|
27
|
+
end
|
28
|
+
else
|
29
|
+
return { error: "Could not get quote", message: quote_result.body }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
data/lib/liblab/version.rb
CHANGED
data/lib/liblab.rb
CHANGED
@@ -10,6 +10,7 @@ require_relative "liblab/movie/get"
|
|
10
10
|
require_relative "liblab/movie/get_quotes"
|
11
11
|
require_relative "liblab/quote/list"
|
12
12
|
require_relative "liblab/quote/get"
|
13
|
+
require_relative "liblab/quote/guess_the_quote"
|
13
14
|
|
14
15
|
module Liblab
|
15
16
|
class Error < StandardError; end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: liblab_the_one
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Monty Lennie
|
@@ -50,6 +50,7 @@ files:
|
|
50
50
|
- lib/liblab/movie/get_quotes.rb
|
51
51
|
- lib/liblab/movie/list.rb
|
52
52
|
- lib/liblab/quote/get.rb
|
53
|
+
- lib/liblab/quote/guess_the_quote.rb
|
53
54
|
- lib/liblab/quote/list.rb
|
54
55
|
- lib/liblab/version.rb
|
55
56
|
- sig/liblab.rbs
|