liblab_the_one 0.1.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: 741e0a412dd8d819491fdf28c9f39f34a55a82ed0ef46e09a451146892e4e110
4
- data.tar.gz: 708aa4fc97a346afe379f2442e74e1c01d3a680476b701469357d3394daf28d5
3
+ metadata.gz: 26956ba91f4879a09844057d5b0738c308793845c10bf181d2f0772ad534743a
4
+ data.tar.gz: ffacc57af7e65676ed63a5ec1723273b7134ae4d3a8c9b16c9f46875651b4d7a
5
5
  SHA512:
6
- metadata.gz: 6ee78d19db8cd207d26fc4e291d4e7c29a03d46a143a35f098d684a448aa3a82f41d2e54f647c385062e921ad3e578dcdab7f8c18a54dce7baceaf23cd6dee2d
7
- data.tar.gz: 1e91ddc7dc02c8950dfb4b347246dd4204ba315b8e59ba2f68d29f6ddd3bdf26f302266b6124f6d7021d9396feb84a4ee0773d7fc2c715483a99e841d6369119
6
+ metadata.gz: e98bdb3e2251d0233407bc2738c62ecebc50455fdde8cf37e6bd195f132692ce269df0be97f565c34d4cfa20e8af2ab04331fc3734b0cd0d872cc2fcf70a8d5b
7
+ data.tar.gz: e461d819b73aaa5faf06888b96891ba4231eac84435b6d92f68086b8828a0b68e131e7f12547061036efa4b1202e7176e81fa778ab173f750e4c8df253ab7fc5
data/Gemfile.lock CHANGED
@@ -1,15 +1,13 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- liblab_the_one (0.1.0)
5
- pry (~> 0.14.2)
4
+ liblab_the_one (0.3.0)
6
5
  rest-client (~> 2.1.0)
7
6
 
8
7
  GEM
9
8
  remote: https://rubygems.org/
10
9
  specs:
11
10
  ast (2.4.2)
12
- coderay (1.1.3)
13
11
  diff-lcs (1.5.0)
14
12
  domain_name (0.5.20190701)
15
13
  unf (>= 0.0.5, < 1.0.0)
@@ -17,7 +15,6 @@ GEM
17
15
  http-cookie (1.0.5)
18
16
  domain_name (~> 0.5)
19
17
  json (2.6.3)
20
- method_source (1.0.0)
21
18
  mime-types (3.4.1)
22
19
  mime-types-data (~> 3.2015)
23
20
  mime-types-data (3.2023.0218.1)
@@ -25,9 +22,6 @@ GEM
25
22
  parallel (1.23.0)
26
23
  parser (3.2.2.1)
27
24
  ast (~> 2.4.1)
28
- pry (0.14.2)
29
- coderay (~> 1.1)
30
- method_source (~> 1.0)
31
25
  rainbow (3.1.1)
32
26
  rake (13.0.6)
33
27
  regexp_parser (2.8.0)
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
 
data/design.md ADDED
@@ -0,0 +1,19 @@
1
+ # Liblab one API SDK design
2
+
3
+ This is a `ruby gem` implementation. The gem was bootstrapped with `Bundler`.
4
+
5
+ The file structure follows standard file structure design stated by https://guides.rubygems.org/make-your-own-gem/. and https://bundler.io/guides/creating_gem.html
6
+
7
+ There is an `https helper class` to help with error handling.
8
+
9
+ `client/base` handles the actual api request preparation and calling.
10
+
11
+ There is a configuration file to allow for the `access token` to be added via an environment variable.
12
+
13
+ There is a custom `logging` system to debug requests.
14
+
15
+ `Rspec` was used for automated testing and tests all implemented endpoints and possible failures.
16
+
17
+ Each class contains a command for an endpoint request. This follows a `service object` approach with a `call` method to trigger the request. https://www.toptal.com/ruby-on-rails/rails-service-objects-tutorial
18
+
19
+ `Pagination` was also implemented for quotes list.
@@ -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.1.0"
4
+ VERSION = "0.3.0"
5
5
  end
data/lib/liblab.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "pry"
4
3
  require_relative "liblab/version"
5
4
  require_relative "liblab/configuration"
6
5
  require_relative "liblab/https"
@@ -11,6 +10,7 @@ require_relative "liblab/movie/get"
11
10
  require_relative "liblab/movie/get_quotes"
12
11
  require_relative "liblab/quote/list"
13
12
  require_relative "liblab/quote/get"
13
+ require_relative "liblab/quote/guess_the_quote"
14
14
 
15
15
  module Liblab
16
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.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Monty Lennie
@@ -24,20 +24,6 @@ dependencies:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 2.1.0
27
- - !ruby/object:Gem::Dependency
28
- name: pry
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: 0.14.2
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: 0.14.2
41
27
  description: Allows easy connection to liblab API
42
28
  email:
43
29
  - montylennie@gmail.com
@@ -54,6 +40,7 @@ files:
54
40
  - LICENSE.txt
55
41
  - README.md
56
42
  - Rakefile
43
+ - design.md
57
44
  - lib/liblab.rb
58
45
  - lib/liblab/client/base.rb
59
46
  - lib/liblab/configuration.rb
@@ -63,6 +50,7 @@ files:
63
50
  - lib/liblab/movie/get_quotes.rb
64
51
  - lib/liblab/movie/list.rb
65
52
  - lib/liblab/quote/get.rb
53
+ - lib/liblab/quote/guess_the_quote.rb
66
54
  - lib/liblab/quote/list.rb
67
55
  - lib/liblab/version.rb
68
56
  - sig/liblab.rbs