From 50c3df89ba30d936980d2d831ad1038e24e08332 Mon Sep 17 00:00:00 2001 From: Dan Milne Date: Fri, 25 Oct 2019 15:05:55 +1100 Subject: [PATCH] Remove Nameable dependancy and return API data directly --- CHANGELOG.md | 6 ++++++ lib/paapi/item.rb | 6 ++---- lib/paapi/version.rb | 2 +- paapi.gemspec | 1 - test/item_test.rb | 15 ++++++++++++++- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 91dccbd..68bf069 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 - Fix a bug when accessing an empty name via Item diff --git a/lib/paapi/item.rb b/lib/paapi/item.rb index b60077f..5fb2f6b 100644 --- a/lib/paapi/item.rb +++ b/lib/paapi/item.rb @@ -55,10 +55,8 @@ module Paapi end def contributors_of(kind) - contributors&.select { |e| e['Role'] == kind.to_s.gsub(/([[:alpha:]]+)/).each { |w| w.capitalize } }&.map do |e| - r = e['Name'] - Nameable(r) unless r.to_s.empty? - end&.compact + kind = kind.to_s.gsub(/([[:alpha:]]+)/) { |w| w.capitalize } + contributors.select { |e| e['Role'] == kind }&.map { |e| e.dig('Name') }&.reject {|n| n.to_s.empty?} end def actors diff --git a/lib/paapi/version.rb b/lib/paapi/version.rb index bf3e099..182e0dd 100644 --- a/lib/paapi/version.rb +++ b/lib/paapi/version.rb @@ -1,3 +1,3 @@ module Paapi - VERSION = '0.0.8' + VERSION = '0.1.0' end diff --git a/paapi.gemspec b/paapi.gemspec index f79bb7b..98773e6 100644 --- a/paapi.gemspec +++ b/paapi.gemspec @@ -33,5 +33,4 @@ Gem::Specification.new do |spec| spec.add_dependency 'http', '~> 4' spec.add_dependency 'aws-sigv4', '~> 1' - spec.add_dependency 'nameable', '~> 1' end diff --git a/test/item_test.rb b/test/item_test.rb index 3a1b785..39de9fe 100644 --- a/test/item_test.rb +++ b/test/item_test.rb @@ -64,6 +64,19 @@ class ItemTest < Minitest::Test 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| 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