olibrary 0.1.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 +7 -0
- data/.gitignore +9 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/README.rdoc +238 -0
- data/Rakefile +4 -0
- data/lib/olibrary/client/authors.rb +10 -0
- data/lib/olibrary/client/books.rb +31 -0
- data/lib/olibrary/client/editions.rb +10 -0
- data/lib/olibrary/client/history.rb +9 -0
- data/lib/olibrary/client/login.rb +10 -0
- data/lib/olibrary/client/recent.rb +9 -0
- data/lib/olibrary/client/save.rb +18 -0
- data/lib/olibrary/client/search.rb +50 -0
- data/lib/olibrary/client.rb +31 -0
- data/lib/olibrary/data.rb +76 -0
- data/lib/olibrary/details.rb +53 -0
- data/lib/olibrary/errors.rb +6 -0
- data/lib/olibrary/request.rb +109 -0
- data/lib/olibrary/version.rb +3 -0
- data/lib/olibrary/view.rb +51 -0
- data/lib/olibrary.rb +21 -0
- data/openlibrary.gemspec +29 -0
- data/spec/client_spec.rb +256 -0
- data/spec/fixtures/author.json +12 -0
- data/spec/fixtures/book.json +59 -0
- data/spec/fixtures/book_by_isbn.json +1 -0
- data/spec/fixtures/book_by_lccn.json +1 -0
- data/spec/fixtures/book_by_oclc.json +1 -0
- data/spec/fixtures/editions.json +354 -0
- data/spec/fixtures/free_search.json +7841 -0
- data/spec/fixtures/history.json +261 -0
- data/spec/fixtures/recent.json +16807 -0
- data/spec/fixtures/save_after_change.json +42 -0
- data/spec/fixtures/save_before_change.json +42 -0
- data/spec/fixtures/search.json +7933 -0
- data/spec/openlibrary_spec.rb +69 -0
- data/spec/spec_helper.rb +56 -0
- metadata +179 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
|
|
3
|
+
describe 'Olibrary' do
|
|
4
|
+
it 'should return correct version string' do
|
|
5
|
+
expect(Olibrary.version).to eq("Olibrary version #{Olibrary::VERSION}")
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
describe 'Olibrary::View' do
|
|
10
|
+
before do
|
|
11
|
+
@book_view = Olibrary::View.new
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
subject { @book_view }
|
|
15
|
+
|
|
16
|
+
it { is_expected.not_to respond_to(:some_random_thing) }
|
|
17
|
+
|
|
18
|
+
it { is_expected.to respond_to(:bib_key) }
|
|
19
|
+
it { is_expected.to respond_to(:info_url) }
|
|
20
|
+
it { is_expected.to respond_to(:preview) }
|
|
21
|
+
it { is_expected.to respond_to(:preview_url) }
|
|
22
|
+
it { is_expected.to respond_to(:thumbnail_url) }
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe 'Olibrary::Data' do
|
|
26
|
+
before do
|
|
27
|
+
@book_data = Olibrary::Data.new
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
subject { @book_data }
|
|
31
|
+
|
|
32
|
+
it { is_expected.not_to respond_to(:some_random_thing) }
|
|
33
|
+
|
|
34
|
+
it { is_expected.to respond_to(:url) }
|
|
35
|
+
it { is_expected.to respond_to(:title) }
|
|
36
|
+
it { is_expected.to respond_to(:subtitle) }
|
|
37
|
+
it { is_expected.to respond_to(:authors) }
|
|
38
|
+
it { is_expected.to respond_to(:identifiers) }
|
|
39
|
+
it { is_expected.to respond_to(:classifications) }
|
|
40
|
+
it { is_expected.to respond_to(:subjects) }
|
|
41
|
+
it { is_expected.to respond_to(:subject_places) }
|
|
42
|
+
it { is_expected.to respond_to(:subject_people) }
|
|
43
|
+
it { is_expected.to respond_to(:subject_times) }
|
|
44
|
+
it { is_expected.to respond_to(:publishers) }
|
|
45
|
+
it { is_expected.to respond_to(:publish_places) }
|
|
46
|
+
it { is_expected.to respond_to(:publish_date) }
|
|
47
|
+
it { is_expected.to respond_to(:excerpts) }
|
|
48
|
+
it { is_expected.to respond_to(:links) }
|
|
49
|
+
it { is_expected.to respond_to(:cover) }
|
|
50
|
+
it { is_expected.to respond_to(:ebooks) }
|
|
51
|
+
it { is_expected.to respond_to(:pages) }
|
|
52
|
+
it { is_expected.to respond_to(:weight) }
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
describe 'Olibrary::Details' do
|
|
56
|
+
before do
|
|
57
|
+
@book_details = Olibrary::Details.new
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
subject { @book_details }
|
|
61
|
+
|
|
62
|
+
it { is_expected.not_to respond_to(:some_random_thing) }
|
|
63
|
+
|
|
64
|
+
it { is_expected.to respond_to(:info_url) }
|
|
65
|
+
it { is_expected.to respond_to(:bib_key) }
|
|
66
|
+
it { is_expected.to respond_to(:preview_url) }
|
|
67
|
+
it { is_expected.to respond_to(:thumbnail_url) }
|
|
68
|
+
it { is_expected.to respond_to(:details) }
|
|
69
|
+
end
|
data/spec/spec_helper.rb
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
$:.unshift File.expand_path("../..", __FILE__)
|
|
2
|
+
|
|
3
|
+
require 'olibrary'
|
|
4
|
+
require 'rspec'
|
|
5
|
+
require 'rest-client'
|
|
6
|
+
require 'webmock'
|
|
7
|
+
require 'webmock/rspec'
|
|
8
|
+
|
|
9
|
+
RSpec.configure do |config|
|
|
10
|
+
config.color = true
|
|
11
|
+
config.formatter = 'documentation'
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def stub_get(path, fixture_name)
|
|
15
|
+
stub_request(:get, api_url(path)).
|
|
16
|
+
with(headers: {
|
|
17
|
+
'Accept'=>'application/json'
|
|
18
|
+
}).
|
|
19
|
+
to_return(
|
|
20
|
+
status: 200,
|
|
21
|
+
body: fixture(fixture_name),
|
|
22
|
+
headers: {}
|
|
23
|
+
)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def stub_put(path, fixture_name, comment)
|
|
27
|
+
stub_request(:put, api_url(path)).
|
|
28
|
+
with(
|
|
29
|
+
body: fixture(fixture_name),
|
|
30
|
+
headers: {
|
|
31
|
+
'Accept' => 'application/json',
|
|
32
|
+
'Content-Type' => 'application/json',
|
|
33
|
+
'Opt' => '"http://openlibrary.org/dev/docs/api"; ns=42',
|
|
34
|
+
'42-comment' => comment,
|
|
35
|
+
'Cookie' => 'cookie',
|
|
36
|
+
'User-Agent' => 'Ruby'
|
|
37
|
+
}).
|
|
38
|
+
to_return(
|
|
39
|
+
status: 200,
|
|
40
|
+
body: fixture(fixture_name),
|
|
41
|
+
headers: {}
|
|
42
|
+
)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def fixture_path(file=nil)
|
|
46
|
+
path = File.expand_path("../fixtures", __FILE__)
|
|
47
|
+
file.nil? ? path : File.join(path, file)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def fixture(file)
|
|
51
|
+
File.read(fixture_path(file))
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def api_url(path)
|
|
55
|
+
"#{Olibrary::Request::API_URL}#{path}"
|
|
56
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: olibrary
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.1.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Yosef Serkez
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2022-03-16 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: rspec
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 3.11.0
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 3.11.0
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: webmock
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - "~>"
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: 3.14.0
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - "~>"
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: 3.14.0
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: hashie
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: 5.0.0
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: 5.0.0
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: json
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - ">="
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: 2.6.1
|
|
62
|
+
type: :runtime
|
|
63
|
+
prerelease: false
|
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
65
|
+
requirements:
|
|
66
|
+
- - ">="
|
|
67
|
+
- !ruby/object:Gem::Version
|
|
68
|
+
version: 2.6.1
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: rest-client
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - "~>"
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: 2.1.0
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - "~>"
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: 2.1.0
|
|
83
|
+
- !ruby/object:Gem::Dependency
|
|
84
|
+
name: activesupport
|
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
|
86
|
+
requirements:
|
|
87
|
+
- - "~>"
|
|
88
|
+
- !ruby/object:Gem::Version
|
|
89
|
+
version: 7.0.2.3
|
|
90
|
+
type: :runtime
|
|
91
|
+
prerelease: false
|
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
93
|
+
requirements:
|
|
94
|
+
- - "~>"
|
|
95
|
+
- !ruby/object:Gem::Version
|
|
96
|
+
version: 7.0.2.3
|
|
97
|
+
description: openlibrary.org API Interface
|
|
98
|
+
email:
|
|
99
|
+
- yosefserkez@gmail.com
|
|
100
|
+
executables: []
|
|
101
|
+
extensions: []
|
|
102
|
+
extra_rdoc_files: []
|
|
103
|
+
files:
|
|
104
|
+
- ".gitignore"
|
|
105
|
+
- ".ruby-gemset"
|
|
106
|
+
- ".ruby-version"
|
|
107
|
+
- Gemfile
|
|
108
|
+
- README.rdoc
|
|
109
|
+
- Rakefile
|
|
110
|
+
- lib/olibrary.rb
|
|
111
|
+
- lib/olibrary/client.rb
|
|
112
|
+
- lib/olibrary/client/authors.rb
|
|
113
|
+
- lib/olibrary/client/books.rb
|
|
114
|
+
- lib/olibrary/client/editions.rb
|
|
115
|
+
- lib/olibrary/client/history.rb
|
|
116
|
+
- lib/olibrary/client/login.rb
|
|
117
|
+
- lib/olibrary/client/recent.rb
|
|
118
|
+
- lib/olibrary/client/save.rb
|
|
119
|
+
- lib/olibrary/client/search.rb
|
|
120
|
+
- lib/olibrary/data.rb
|
|
121
|
+
- lib/olibrary/details.rb
|
|
122
|
+
- lib/olibrary/errors.rb
|
|
123
|
+
- lib/olibrary/request.rb
|
|
124
|
+
- lib/olibrary/version.rb
|
|
125
|
+
- lib/olibrary/view.rb
|
|
126
|
+
- openlibrary.gemspec
|
|
127
|
+
- spec/client_spec.rb
|
|
128
|
+
- spec/fixtures/author.json
|
|
129
|
+
- spec/fixtures/book.json
|
|
130
|
+
- spec/fixtures/book_by_isbn.json
|
|
131
|
+
- spec/fixtures/book_by_lccn.json
|
|
132
|
+
- spec/fixtures/book_by_oclc.json
|
|
133
|
+
- spec/fixtures/editions.json
|
|
134
|
+
- spec/fixtures/free_search.json
|
|
135
|
+
- spec/fixtures/history.json
|
|
136
|
+
- spec/fixtures/recent.json
|
|
137
|
+
- spec/fixtures/save_after_change.json
|
|
138
|
+
- spec/fixtures/save_before_change.json
|
|
139
|
+
- spec/fixtures/search.json
|
|
140
|
+
- spec/openlibrary_spec.rb
|
|
141
|
+
- spec/spec_helper.rb
|
|
142
|
+
homepage: https://github.com/4till2/olibrary
|
|
143
|
+
licenses: []
|
|
144
|
+
metadata: {}
|
|
145
|
+
post_install_message:
|
|
146
|
+
rdoc_options: []
|
|
147
|
+
require_paths:
|
|
148
|
+
- lib
|
|
149
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
150
|
+
requirements:
|
|
151
|
+
- - ">="
|
|
152
|
+
- !ruby/object:Gem::Version
|
|
153
|
+
version: '0'
|
|
154
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
155
|
+
requirements:
|
|
156
|
+
- - ">="
|
|
157
|
+
- !ruby/object:Gem::Version
|
|
158
|
+
version: '0'
|
|
159
|
+
requirements: []
|
|
160
|
+
rubygems_version: 3.3.7
|
|
161
|
+
signing_key:
|
|
162
|
+
specification_version: 4
|
|
163
|
+
summary: Ruby Interface for the openlibrary.org API
|
|
164
|
+
test_files:
|
|
165
|
+
- spec/client_spec.rb
|
|
166
|
+
- spec/fixtures/author.json
|
|
167
|
+
- spec/fixtures/book.json
|
|
168
|
+
- spec/fixtures/book_by_isbn.json
|
|
169
|
+
- spec/fixtures/book_by_lccn.json
|
|
170
|
+
- spec/fixtures/book_by_oclc.json
|
|
171
|
+
- spec/fixtures/editions.json
|
|
172
|
+
- spec/fixtures/free_search.json
|
|
173
|
+
- spec/fixtures/history.json
|
|
174
|
+
- spec/fixtures/recent.json
|
|
175
|
+
- spec/fixtures/save_after_change.json
|
|
176
|
+
- spec/fixtures/save_before_change.json
|
|
177
|
+
- spec/fixtures/search.json
|
|
178
|
+
- spec/openlibrary_spec.rb
|
|
179
|
+
- spec/spec_helper.rb
|