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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2a272a9f94c2e02f952eb657bbb9d8d6862b9f7aee4010a18ee2934fd3ce0488
4
- data.tar.gz: c6c18518484c0bc6a08f815636947e581c2ff38bd1391aef3af6550376134311
3
+ metadata.gz: 26956ba91f4879a09844057d5b0738c308793845c10bf181d2f0772ad534743a
4
+ data.tar.gz: ffacc57af7e65676ed63a5ec1723273b7134ae4d3a8c9b16c9f46875651b4d7a
5
5
  SHA512:
6
- metadata.gz: 3e23d7d4e726e30dfc42d600f2a981eac6be42e04569cce33c82a5f753a3fbbaea75dd1b241674812309f73e62c2c38172d6e9b1386accc8905c1dd06c7bd15d
7
- data.tar.gz: e1d422f96ae681b84644543a0e495bce923d600596e90ad0ca8431c59e75ca7a4e25e40dbe9d3b4cdaedf310c92007dd596b8321e455e0d72ea6bccee6ece590
6
+ metadata.gz: e98bdb3e2251d0233407bc2738c62ecebc50455fdde8cf37e6bd195f132692ce269df0be97f565c34d4cfa20e8af2ab04331fc3734b0cd0d872cc2fcf70a8d5b
7
+ data.tar.gz: e461d819b73aaa5faf06888b96891ba4231eac84435b6d92f68086b8828a0b68e131e7f12547061036efa4b1202e7176e81fa778ab173f750e4c8df253ab7fc5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- liblab_the_one (0.2.0)
4
+ liblab_the_one (0.3.0)
5
5
  rest-client (~> 2.1.0)
6
6
 
7
7
  GEM
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
- ### Setup
45
+ ## Bonus Game: Guess the quote!
37
46
 
38
- Add the following environment variables. The specific values can be found at https://the-one-api.dev/.
47
+ Help test and build your Lord of The Rings knowledge.
39
48
 
40
- ```
41
- LIBLAB_ACCESS_TOKEN=
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Liblab
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
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.2.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