game_of_thrones_api 0.3.0 → 0.4.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/lib/game_of_thrones_api.rb +11 -12
- data/lib/game_of_thrones_api/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e35ef7f62a8e03e487fc3a0b08fc643411ca6174
|
4
|
+
data.tar.gz: 4b8512e1383f38cecde0eac6c3235467c592e45b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 90ff96e9407265de9666a4de70fefa40f0c9d6bbf8b9701a3148d489da683244429743cb5e57653a24bfd5ae2d60207d061c83de117a6cd81a55e31d4a62ac86
|
7
|
+
data.tar.gz: 6a3af14417c53252a0897fc3be6925def477b6764c1a157b6ee11f2f52b4b49512354d78eb7b17049e985cecbec753459a20d6602584ec18e8bf9d190d6f1f01
|
data/lib/game_of_thrones_api.rb
CHANGED
@@ -24,7 +24,7 @@ module GameOfThronesApi
|
|
24
24
|
response = get("#{BASE_ENDPOINT}/books?page=1&pageSize=50")
|
25
25
|
total_pages = get_page_count(response)
|
26
26
|
|
27
|
-
get_all_records('books', response, total_pages)
|
27
|
+
get_all_records('books', response.parsed_response, total_pages)
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
@@ -40,7 +40,7 @@ module GameOfThronesApi
|
|
40
40
|
response = get("#{BASE_ENDPOINT}/characters?page=1&pageSize=50")
|
41
41
|
total_pages = get_page_count(response)
|
42
42
|
|
43
|
-
get_all_records('characters', response, total_pages)
|
43
|
+
get_all_records('characters', response.parsed_response, total_pages)
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
@@ -56,7 +56,7 @@ module GameOfThronesApi
|
|
56
56
|
response = get("#{BASE_ENDPOINT}/houses?page=1&pageSize=50")
|
57
57
|
total_pages = get_page_count(response)
|
58
58
|
|
59
|
-
get_all_records('houses', response, total_pages)
|
59
|
+
get_all_records('houses', response.parsed_response, total_pages)
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
@@ -89,7 +89,7 @@ module GameOfThronesApi
|
|
89
89
|
def titleize_query(query)
|
90
90
|
split_words =
|
91
91
|
query.split.map.with_index do |word, index|
|
92
|
-
if WORD_PARTICLES.
|
92
|
+
if !WORD_PARTICLES.include?(word) || index.zero?
|
93
93
|
word.capitalize
|
94
94
|
else
|
95
95
|
word
|
@@ -101,14 +101,13 @@ module GameOfThronesApi
|
|
101
101
|
|
102
102
|
# The API results are paginated, just looping through the pages to collect
|
103
103
|
# all the records associated with the category.
|
104
|
-
def get_all_records(category,
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
page
|
109
|
-
|
104
|
+
def get_all_records(category, records, total_pages, page = 1)
|
105
|
+
if total_pages >= page
|
106
|
+
page += 1
|
107
|
+
records += get("#{BASE_ENDPOINT}/#{category}?page=#{page}&pageSize=50").parsed_response
|
108
|
+
get_all_records(category, records, total_pages, page)
|
109
|
+
else
|
110
|
+
records
|
110
111
|
end
|
111
|
-
|
112
|
-
characters
|
113
112
|
end
|
114
113
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: game_of_thrones_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Tam
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
105
|
version: '0'
|
106
106
|
requirements: []
|
107
107
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.
|
108
|
+
rubygems_version: 2.6.8
|
109
109
|
signing_key:
|
110
110
|
specification_version: 4
|
111
111
|
summary: Game of Thrones
|