liblab_the_one 0.2.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +21 -9
- 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: 4a46278376323b078492b7eed5571cbaefbf3b2ffcd85c691ff20206e12c4b5f
|
4
|
+
data.tar.gz: c1e9cb7245773b9ae262a55088e5a28d0ddb263e5386c0148a2219579e38c9e7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8124e96726f1c218b3dee540a7a10211c8306e598298ebe3b5215de8ca8b047e00bad0cf3af1aff46035e983ec8cbf8bb6db5473d1289e6d709809513ac6872d
|
7
|
+
data.tar.gz: dd4bbfe013e808f027fb2b66013760982c189b122ca090870cba55747c128df72eb9ba002b6a67128145fd7bc754e7d1ba085918b73d8649cb1ffbe1dfccf2fd
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -4,7 +4,15 @@ This gem is an API wrapper for (the one api)[https://the-one-api.dev/].
|
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
7
|
-
|
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
|
+
|
15
|
+
Add this line to your application's Gemfile if using Ruby on Rails:
|
8
16
|
|
9
17
|
```ruby
|
10
18
|
gem 'liblab_the_one'
|
@@ -14,9 +22,12 @@ And then execute:
|
|
14
22
|
|
15
23
|
$ bundle install
|
16
24
|
|
17
|
-
Or install it yourself as:
|
25
|
+
Or install it yourself in a ruby environment as:
|
18
26
|
|
19
27
|
$ gem install pex_api
|
28
|
+
|
29
|
+
|
30
|
+
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
31
|
|
21
32
|
## Usage
|
22
33
|
`Liblab::Movie::List.call()` will get a list of movies
|
@@ -31,19 +42,20 @@ Or install it yourself as:
|
|
31
42
|
|
32
43
|
`Liblab::Quote::Get.call(quote_id)` will retrieve an individual quote
|
33
44
|
|
34
|
-
Each class/method will have it's own parameters depending on the type of request and it's expected input parameters.
|
35
45
|
|
36
|
-
|
46
|
+
## Bonus Game: Guess the quote!
|
37
47
|
|
38
|
-
|
48
|
+
Help test and build your Lord of The Rings knowledge.
|
39
49
|
|
40
|
-
|
41
|
-
|
42
|
-
|
50
|
+
Use `Liblab::Quote::GuessTheQuote.call()` to return a random quote with a movie name.
|
51
|
+
|
52
|
+
You can tell people the quote and they have to guess the movie.
|
53
|
+
|
54
|
+
Example response is `{:quote=>"Your bodyguard?", :movie_name=>"The Two Towers"}`
|
43
55
|
|
44
56
|
## Development
|
45
57
|
|
46
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `
|
58
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rspec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
47
59
|
|
48
60
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
49
61
|
|
@@ -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(1..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(1..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 movie_result
|
27
|
+
end
|
28
|
+
else
|
29
|
+
return quote_result
|
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.1
|
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
|