Remove Nameable dependancy and return API data directly

This commit is contained in:
Dan Milne
2019-10-25 15:05:55 +11:00
parent 1ad818b4d7
commit 50c3df89ba
5 changed files with 23 additions and 7 deletions

View File

@@ -1,3 +1,9 @@
## 0.1.0
- Remove Nameable dependancy and return the data as the API returns it.
## 0.0.9
- Fix bug with no contributors in response
## 0.0.8 ## 0.0.8
- Fix a bug when accessing an empty name via Item - Fix a bug when accessing an empty name via Item

View File

@@ -55,10 +55,8 @@ module Paapi
end end
def contributors_of(kind) def contributors_of(kind)
contributors&.select { |e| e['Role'] == kind.to_s.gsub(/([[:alpha:]]+)/).each { |w| w.capitalize } }&.map do |e| kind = kind.to_s.gsub(/([[:alpha:]]+)/) { |w| w.capitalize }
r = e['Name'] contributors.select { |e| e['Role'] == kind }&.map { |e| e.dig('Name') }&.reject {|n| n.to_s.empty?}
Nameable(r) unless r.to_s.empty?
end&.compact
end end
def actors def actors

View File

@@ -1,3 +1,3 @@
module Paapi module Paapi
VERSION = '0.0.8' VERSION = '0.1.0'
end end

View File

@@ -33,5 +33,4 @@ Gem::Specification.new do |spec|
spec.add_dependency 'http', '~> 4' spec.add_dependency 'http', '~> 4'
spec.add_dependency 'aws-sigv4', '~> 1' spec.add_dependency 'aws-sigv4', '~> 1'
spec.add_dependency 'nameable', '~> 1'
end end

View File

@@ -64,6 +64,19 @@ class ItemTest < Minitest::Test
artists: [] artists: []
} }
] ]
},
{
name: 'Bad Contributors',
response: 'get_item_bad_contributor.json',
item_count: 1,
items: [
{
asin: "055357342X",
authors: ['.'],
illustrators: [],
artists: []
}
]
} }
] ]
@@ -77,7 +90,7 @@ class ItemTest < Minitest::Test
tc[:items].each_with_index do |item, idx| tc[:items].each_with_index do |item, idx|
item.keys.each do |exp| item.keys.each do |exp|
assert_equal item[exp], resp.items[idx].send(exp) assert_equal item[exp], resp.items[idx].send(exp), "Dataset: #{tc[:name]}"
end end
end end
end end