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 +4 -4
- data/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/README.md +41 -11
- data/bin/console +0 -2
- data/lib/owen_wows/client.rb +31 -8
- data/lib/owen_wows/error.rb +1 -1
- data/lib/owen_wows/version.rb +1 -1
- data/lib/owen_wows.rb +0 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8e4eefc0a2ca043c6128f33e83874d5b875b9a5849be866ce56afcc240f1743f
|
4
|
+
data.tar.gz: 71a6089e6c1fbca6cb74f060ca18c72c9f47cbd8b8a7a861c27753060a265266
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a9592fe3f749368f0696607d5fa34f1de88061412d424028008d7c70bbf0a8e2e7fd8f3c1bb2b2d3765f1fb34740ca3464d9f635d5d9bef02cd16081a47960a2
|
7
|
+
data.tar.gz: 1ad2ccd1e9036a6e126fd5ed221817daa6d58c4aded18a5d122cc3812af00259beca7e27ed361633ca03982520a2023b2d928c1245bd9f978d39b1f4848f2a4f
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
# OwenWows
|
2
2
|
|
3
|
-
|
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
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
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/
|
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
data/lib/owen_wows/client.rb
CHANGED
@@ -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 =
|
26
|
-
wows
|
27
|
+
wows = search(results: results)
|
28
|
+
build_list(wows)
|
27
29
|
end
|
28
30
|
|
29
|
-
def
|
30
|
-
|
31
|
-
|
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 =
|
36
|
-
all = wows
|
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
|
data/lib/owen_wows/error.rb
CHANGED
data/lib/owen_wows/version.rb
CHANGED
data/lib/owen_wows.rb
CHANGED