mirror of
https://github.com/dkam/openlib.git
synced 2025-12-27 18:54:52 +00:00
Dump byebug history file
This commit is contained in:
102
.byebug_history
102
.byebug_history
@@ -1,102 +0,0 @@
|
||||
c
|
||||
resp.status.first
|
||||
resp.status
|
||||
resp.200
|
||||
resp.ok?
|
||||
resp.status.to_i
|
||||
resp.status.first
|
||||
resp.status
|
||||
c
|
||||
n
|
||||
c
|
||||
resp.status
|
||||
resp
|
||||
c
|
||||
view.first.last.dig("preview_url")
|
||||
view.first.last.keys
|
||||
view.first.last
|
||||
c
|
||||
view.first.last.dig(data.to_s)
|
||||
view.first.last.dig(data)
|
||||
view.first.last
|
||||
view
|
||||
data
|
||||
c
|
||||
n
|
||||
@view.info_url
|
||||
n
|
||||
c
|
||||
@view.response
|
||||
@view.response.first.last.keys
|
||||
@view.response.first.last.dig("info_url")
|
||||
@view.response.first.last
|
||||
@view.response.first.last.dig("info_url")
|
||||
@view.response
|
||||
@view
|
||||
@view.info_url
|
||||
@view
|
||||
n
|
||||
c
|
||||
@view.
|
||||
@view
|
||||
c
|
||||
pp JSON.parse(d)
|
||||
JSON.parse(d)
|
||||
d.class
|
||||
puts d
|
||||
pp d
|
||||
puts d
|
||||
d
|
||||
ap d
|
||||
d =URI.open( "https://openlibrary.org/api/books?jscmd=#{format}&format=json&bibkeys=#{id_kind.to_s.upcase}#{id}" ).read
|
||||
n
|
||||
s
|
||||
c
|
||||
id_kind
|
||||
ID_KINDS
|
||||
ID_KINDS.include?(id_kind)
|
||||
id_kind
|
||||
s
|
||||
c
|
||||
n
|
||||
s
|
||||
c
|
||||
n
|
||||
s
|
||||
c
|
||||
@id_kind
|
||||
c
|
||||
s
|
||||
@view
|
||||
c
|
||||
n
|
||||
s
|
||||
c
|
||||
id
|
||||
format
|
||||
d
|
||||
"https://openlibrary.org/api/books?jscmd=#{format}&format=json&bibkeys=#{kind.to_s.upcase}#{id}"
|
||||
n
|
||||
s
|
||||
@view = nil
|
||||
c
|
||||
n
|
||||
@view = nil
|
||||
@view
|
||||
c
|
||||
s
|
||||
c
|
||||
n
|
||||
s
|
||||
c
|
||||
n
|
||||
@view
|
||||
n
|
||||
c
|
||||
d.read
|
||||
d.body
|
||||
ap d
|
||||
d = URI.open( "https://openlibrary.org/api/books?jscmd=#{format}&format=json&bibkeys=#{kind.to_s.upcase}")
|
||||
"https://openlibrary.org/api/books?jscmd=#{format}&format=json&bibkeys=#{kind.to_s.upcase}"
|
||||
n
|
||||
s
|
||||
1
.gitignore
vendored
1
.gitignore
vendored
@@ -6,3 +6,4 @@
|
||||
/pkg/
|
||||
/spec/reports/
|
||||
/tmp/
|
||||
.byebug_history
|
||||
|
||||
90
test/fixtures.rb
Normal file
90
test/fixtures.rb
Normal file
@@ -0,0 +1,90 @@
|
||||
TESTCASES= [
|
||||
isbn: '9780316030571',
|
||||
data: {
|
||||
"ISBN:9780316030571": {
|
||||
"authors": [
|
||||
{
|
||||
"name": "Iain M. Banks",
|
||||
"url": "https://openlibrary.org/authors/OL6924809A/Iain_M._Banks"
|
||||
}
|
||||
],
|
||||
"cover": {
|
||||
"large": "https://covers.openlibrary.org/b/id/2379038-L.jpg",
|
||||
"medium": "https://covers.openlibrary.org/b/id/2379038-M.jpg",
|
||||
"small": "https://covers.openlibrary.org/b/id/2379038-S.jpg"
|
||||
},
|
||||
"ebooks": [
|
||||
{
|
||||
"availability": "borrow",
|
||||
"borrow_url": "https://openlibrary.org/books/OL10426208M/Use_of_Weapons/borrow",
|
||||
"checkedout": false,
|
||||
"formats": {},
|
||||
"preview_url": "https://archive.org/details/useofweapons00bank_0"
|
||||
}
|
||||
],
|
||||
"identifiers": {
|
||||
"goodreads": [
|
||||
"3395563"
|
||||
],
|
||||
"isbn_10": [
|
||||
"0316030570"
|
||||
],
|
||||
"isbn_13": [
|
||||
"9780316030571"
|
||||
],
|
||||
"librarything": [
|
||||
"141"
|
||||
],
|
||||
"openlibrary": [
|
||||
"OL10426208M"
|
||||
]
|
||||
},
|
||||
"key": "/books/OL10426208M",
|
||||
"number_of_pages": 480,
|
||||
"publish_date": "July 28, 2008",
|
||||
"publishers": [
|
||||
{
|
||||
"name": "Orbit"
|
||||
}
|
||||
],
|
||||
"subject_people": [
|
||||
{
|
||||
"name": "Cheradenine Zakalwe",
|
||||
"url": "https://openlibrary.org/subjects/person:cheradenine_zakalwe"
|
||||
},
|
||||
{
|
||||
"name": "Diziet Sma",
|
||||
"url": "https://openlibrary.org/subjects/person:diziet_sma"
|
||||
},
|
||||
{
|
||||
"name": "Skaffen-Amtiskaw",
|
||||
"url": "https://openlibrary.org/subjects/person:skaffen-amtiskaw"
|
||||
}
|
||||
],
|
||||
"subjects": [
|
||||
{
|
||||
"name": "Fiction",
|
||||
"url": "https://openlibrary.org/subjects/fiction"
|
||||
},
|
||||
{
|
||||
"name": "Science Fiction",
|
||||
"url": "https://openlibrary.org/subjects/science_fiction"
|
||||
},
|
||||
{
|
||||
"name": "Science Fiction & Fantasy",
|
||||
"url": "https://openlibrary.org/subjects/science_fiction_&_fantasy"
|
||||
},
|
||||
{
|
||||
"name": "Long Now Manual for Civilization",
|
||||
"url": "https://openlibrary.org/subjects/long_now_manual_for_civilization"
|
||||
},
|
||||
{
|
||||
"name": "Space warfare",
|
||||
"url": "https://openlibrary.org/subjects/space_warfare"
|
||||
}
|
||||
],
|
||||
"title": "Use of Weapons",
|
||||
"url": "https://openlibrary.org/books/OL10426208M/Use_of_Weapons"
|
||||
}
|
||||
}
|
||||
]
|
||||
@@ -1,4 +1,5 @@
|
||||
require "test_helper"
|
||||
require 'byebug'
|
||||
|
||||
class OpenlibTest < Minitest::Test
|
||||
def test_that_it_has_a_version_number
|
||||
@@ -6,6 +7,21 @@ class OpenlibTest < Minitest::Test
|
||||
end
|
||||
|
||||
def test_it_does_something_useful
|
||||
assert false
|
||||
|
||||
TESTCASES.each do |tc|
|
||||
b = Openlib::Book.new(id: tc.dig(:isbn))
|
||||
b.view = tc.dig(:view)
|
||||
b.data = tc.dig(:data)
|
||||
|
||||
assert_equal tc.dig(:data).first.last.dig('authors').map {|e| e.dig('name') }, b.authors
|
||||
assert_equal tc.dig(:data).first.last.dig('title').map {|e| e.dig('name') }, b.title
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
TESTCASES= [
|
||||
isbn: '9780316030571',
|
||||
view: {"ISBN:9780316030571"=>{"bib_key"=>"ISBN:9780316030571", "preview"=>"borrow", "thumbnail_url"=>"https://covers.openlibrary.org/b/id/2379038-S.jpg", "preview_url"=>"https://archive.org/details/useofweapons00bank_0", "info_url"=>"https://openlibrary.org/books/OL10426208M/Use_of_Weapons"}},
|
||||
data: {"ISBN:9780316030571"=>{"publishers"=>[{"name"=>"Orbit"}], "identifiers"=>{"isbn_13"=>["9780316030571"], "openlibrary"=>["OL10426208M"], "isbn_10"=>["0316030570"], "librarything"=>["141"], "goodreads"=>["3395563"]}, "title"=>"Use of Weapons", "url"=>"https://openlibrary.org/books/OL10426208M/Use_of_Weapons", "number_of_pages"=>480, "cover"=>{"small"=>"https://covers.openlibrary.org/b/id/2379038-S.jpg", "large"=>"https://covers.openlibrary.org/b/id/2379038-L.jpg", "medium"=>"https://covers.openlibrary.org/b/id/2379038-M.jpg"}, "subjects"=>[{"url"=>"https://openlibrary.org/subjects/fiction", "name"=>"Fiction"}, {"url"=>"https://openlibrary.org/subjects/science_fiction", "name"=>"Science Fiction"}, {"url"=>"https://openlibrary.org/subjects/science_fiction_&_fantasy", "name"=>"Science Fiction & Fantasy"}, {"url"=>"https://openlibrary.org/subjects/long_now_manual_for_civilization", "name"=>"Long Now Manual for Civilization"}, {"url"=>"https://openlibrary.org/subjects/space_warfare", "name"=>"Space warfare"}], "subject_people"=>[{"url"=>"https://openlibrary.org/subjects/person:cheradenine_zakalwe", "name"=>"Cheradenine Zakalwe"}, {"url"=>"https://openlibrary.org/subjects/person:diziet_sma", "name"=>"Diziet Sma"}, {"url"=>"https://openlibrary.org/subjects/person:skaffen-amtiskaw", "name"=>"Skaffen-Amtiskaw"}], "key"=>"/books/OL10426208M", "authors"=>[{"url"=>"https://openlibrary.org/authors/OL6924809A/Iain_M._Banks", "name"=>"Iain M. Banks"}], "publish_date"=>"July 28, 2008", "ebooks"=>[{"checkedout"=>false, "formats"=>{}, "preview_url"=>"https://archive.org/details/useofweapons00bank_0", "borrow_url"=>"https://openlibrary.org/books/OL10426208M/Use_of_Weapons/borrow", "availability"=>"borrow"}]}}
|
||||
]
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user