owen_wows 0.1.0 → 0.2.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: 350daf847c4234fbc11cc470da764020347617de9c26b2d29443efbbb2abe9dc
4
- data.tar.gz: b40c1531ff4040bb03267767d5e6b16081ebb7c212bc3ca0df230d51ee444f01
3
+ metadata.gz: 8e4eefc0a2ca043c6128f33e83874d5b875b9a5849be866ce56afcc240f1743f
4
+ data.tar.gz: 71a6089e6c1fbca6cb74f060ca18c72c9f47cbd8b8a7a861c27753060a265266
5
5
  SHA512:
6
- metadata.gz: d11f8230b47724624e4ec59c3a00fccfa7b14e7c17dfec050b8f110854124bf1f97fec3b2b34900f0bcd3ec424592fa02b4744c9380196548473902a87c53a11
7
- data.tar.gz: 3a8760dd7587565c222fef963cd5cad85aebbcb07b009bf90b4c8fd561c28d388ac50f2e7104cf9cd8d28c8f0ef0b895412053f552c95ba71d5eb4f65c9dfeba
6
+ metadata.gz: a9592fe3f749368f0696607d5fa34f1de88061412d424028008d7c70bbf0a8e2e7fd8f3c1bb2b2d3765f1fb34740ca3464d9f635d5d9bef02cd16081a47960a2
7
+ data.tar.gz: 1ad2ccd1e9036a6e126fd5ed221817daa6d58c4aded18a5d122cc3812af00259beca7e27ed361633ca03982520a2023b2d928c1245bd9f978d39b1f4848f2a4f
data/.gitignore CHANGED
@@ -13,3 +13,4 @@
13
13
  # system / ide files
14
14
  .idea/
15
15
  .ruby-version
16
+ *.gem
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- owen_wows (0.1.0)
4
+ owen_wows (0.2.0)
5
5
  faraday (= 2.2.0)
6
6
  hashie (= 5.0.0)
7
7
 
data/README.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # OwenWows
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/owen_wows`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ This is a Ruby API wrapper for the [Owen Wilson Random Wow API](https://owen-wilson-wow-api.herokuapp.com/).
6
4
 
7
5
  ## Installation
8
6
 
@@ -22,13 +20,45 @@ Or install it yourself as:
22
20
 
23
21
  ## Usage
24
22
 
25
- ```azure
26
- client = OwenWows::Client.new()
27
- client.wows
28
- client.random_wow
29
- client.movies
30
- client.directors
31
- ```
23
+ require 'owen_wows;
24
+ wows = OwenWows::Client.new
25
+
26
+ # get a random wow
27
+ wows.random_wow
28
+
29
+ # list all wows
30
+ wows.list
31
+
32
+ Each call returns an array of `OwenWows::Wow` objects.
33
+
34
+ Some filter options:
35
+
36
+ # from year
37
+ wows.from_year("2000")
38
+
39
+ # with director
40
+ wows.with_director("wes anderson")
41
+
42
+ # wows in movie
43
+ wows.in_movie("Cars")
44
+
45
+ # by default, movie is an exact search
46
+ # specify exact: false to string search
47
+ wows.in_movie("Cars", exact: false)
48
+
49
+ You can specify the maximum number of results returned in any filter by passing a `results` argument.
50
+
51
+ wows.in_movie("Cars", exact: false, results: 10)
52
+
53
+ Otherwise, you can search by any combination of parameters.
54
+
55
+ wows.search(movie: "Cars", year: "2000")
56
+
57
+ Get lists of movies and directors.
58
+
59
+ wows.movies
60
+ wows.directors
61
+
32
62
 
33
63
  ## Development
34
64
 
@@ -38,7 +68,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
38
68
 
39
69
  ## Contributing
40
70
 
41
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/owen_wows.
71
+ Bug reports and pull requests are welcome on GitHub at https://github.com/iubkud/owen_wows.
42
72
 
43
73
  ## License
44
74
 
data/bin/console CHANGED
@@ -11,7 +11,5 @@ require "owen_wows"
11
11
  # require "pry"
12
12
  # Pry.start
13
13
 
14
- client = OwenWows::Client.new()
15
-
16
14
  require "irb"
17
15
  IRB.start(__FILE__)
@@ -3,6 +3,8 @@
3
3
  require "faraday"
4
4
  require "owen_wows/wow"
5
5
  module OwenWows
6
+ # Class for handling the API connection to the
7
+ # Owen Wilson Random Wow API
6
8
  class Client
7
9
  BASE_URL = "https://owen-wilson-wow-api.herokuapp.com/wows/"
8
10
  CURRENT_MOVIE_COUNT = 91
@@ -22,23 +24,38 @@ module OwenWows
22
24
  end
23
25
 
24
26
  def list(results: CURRENT_MOVIE_COUNT)
25
- wows = connection.get("random", { results: results }).body
26
- wows.map { |wow| OwenWows::Wow.new(wow) }
27
+ wows = search(results: results)
28
+ build_list(wows)
27
29
  end
28
30
 
29
- def with_director(director)
30
- wows = connection.get("random", { director: director }).body
31
- wows.map { |wow| OwenWows::Wow.new(wow) }
31
+ def random_wow
32
+ wow = search
33
+ build_list(wow)
34
+ end
35
+
36
+ def with_director(director, results: CURRENT_MOVIE_COUNT)
37
+ wows = search(director: director, results: results)
38
+ build_list(wows)
39
+ end
40
+
41
+ def from_year(year, results: CURRENT_MOVIE_COUNT)
42
+ wows = search(year: year, results: results)
43
+ build_list(wows)
32
44
  end
33
45
 
34
46
  def in_movie(movie, exact: true, results: CURRENT_MOVIE_COUNT)
35
- wows = connection.get("random", { movie: movie, results: results }).body
36
- all = wows.map { |wow| OwenWows::Wow.new(wow) }
47
+ wows = search(movie: movie, results: results)
48
+ all = build_list(wows)
37
49
  return all unless exact
38
50
 
39
51
  all.select { |wow| wow["movie"] == movie }
40
52
  end
41
53
 
54
+ def search(**kwargs)
55
+ wows = connection.get("random", **kwargs).body
56
+ build_list(wows)
57
+ end
58
+
42
59
  def all_movies
43
60
  connection.get("movies").body
44
61
  end
@@ -46,5 +63,11 @@ module OwenWows
46
63
  def all_directors
47
64
  connection.get("directors").body
48
65
  end
66
+
67
+ private
68
+
69
+ def build_list(wows)
70
+ wows.map { |wow| OwenWows::Wow.new(wow) }
71
+ end
49
72
  end
50
- end
73
+ end
@@ -2,4 +2,4 @@
2
2
 
3
3
  module OwenWows
4
4
  class Error < StandardError; end
5
- end
5
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OwenWows
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/owen_wows.rb CHANGED
@@ -5,5 +5,4 @@ require_relative "owen_wows/version"
5
5
  module OwenWows
6
6
  autoload :Client, "owen_wows/client"
7
7
  autoload :Error, "owen_wows/error"
8
-
9
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: owen_wows
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Barry