abebooks 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +22 -0
- data/README.md +32 -0
- data/lib/abebooks.rb +10 -0
- data/lib/abebooks/request.rb +21 -0
- data/lib/abebooks/response.rb +10 -0
- data/lib/abebooks/version.rb +3 -0
- data/test/test_abebooks.rb +20 -0
- metadata +109 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 68e1a79a9d142816ef3ef3bc226440c027623888
|
4
|
+
data.tar.gz: 213e9a98f2b1bd6235e3284c9a548aac02e69800
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: db0a85f02d4b6ea2c5cbb8770131c75286be7e8f112f94469e4aead2c26765e7e688651c5a7c2bd04555e4aacd624be1f99afbcd59e0ba02eec42457ec23f687
|
7
|
+
data.tar.gz: 36233fd9f3046e176a6027db987751db69e3e0e95db5594a80e4cb380158d2df1afa854790de70c54d8ab4c4a0cfb6804e5723d798e90e8089b9ed7aeaa16b64
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Diego Marquez
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# Abebooks
|
2
|
+
|
3
|
+
**Abebooks** is a Ruby wrapper to the [Abebooks SWS API][1].
|
4
|
+
|
5
|
+
## Usage
|
6
|
+
|
7
|
+
Create a request:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
req = Abebooks.new(client_key)
|
11
|
+
```
|
12
|
+
|
13
|
+
Run a query:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
params = { author: 'Foucault' }
|
17
|
+
res = req.get(query: params)
|
18
|
+
```
|
19
|
+
|
20
|
+
Parse the response into a Ruby Hash:
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
res.to_h
|
24
|
+
```
|
25
|
+
|
26
|
+
Or pass its body into a custom parser:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
MyParser.new(res.body)
|
30
|
+
```
|
31
|
+
|
32
|
+
[1]: http://www.abebooks.com/docs/AffiliateProgram/WebServices/end-user-guide.pdf
|
data/lib/abebooks.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'excon'
|
2
|
+
require 'abebooks/response'
|
3
|
+
|
4
|
+
module Abebooks
|
5
|
+
class Request
|
6
|
+
def initialize(client_key = ENV['ABEBOOKS_CLIENT_KEY'])
|
7
|
+
@client_key = client_key
|
8
|
+
end
|
9
|
+
|
10
|
+
def get(opts)
|
11
|
+
opts.fetch(:query).update('clientkey' => @client_key)
|
12
|
+
Response.new(connection.get(opts))
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def connection
|
18
|
+
Excon.new('http://search2.abebooks.com/search', expects: 200)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
require 'minitest/pride'
|
3
|
+
require_relative '../lib/abebooks'
|
4
|
+
|
5
|
+
class TestAbebooks < Minitest::Unit::TestCase
|
6
|
+
def setup
|
7
|
+
Excon.defaults[:mock] = true
|
8
|
+
Excon.stub({}, { body: '<foo>bar</foo>' })
|
9
|
+
end
|
10
|
+
|
11
|
+
def teardown
|
12
|
+
Excon.stubs.clear
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_fetches_parsable_response
|
16
|
+
req = Abebooks::Request.new
|
17
|
+
res = req.get(query: {})
|
18
|
+
refute_empty res.to_h
|
19
|
+
end
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: abebooks
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Diego Marquez
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-25 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: multi_xml
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.5.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.5.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: excon
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- marquez.diego.e@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- LICENSE
|
77
|
+
- README.md
|
78
|
+
- lib/abebooks.rb
|
79
|
+
- lib/abebooks/request.rb
|
80
|
+
- lib/abebooks/response.rb
|
81
|
+
- lib/abebooks/version.rb
|
82
|
+
- test/test_abebooks.rb
|
83
|
+
homepage: https://github.com/diegomarquez/abebooks
|
84
|
+
licenses:
|
85
|
+
- MIT
|
86
|
+
metadata: {}
|
87
|
+
post_install_message:
|
88
|
+
rdoc_options: []
|
89
|
+
require_paths:
|
90
|
+
- lib
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
92
|
+
requirements:
|
93
|
+
- - ">="
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '1.9'
|
96
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ">="
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
requirements: []
|
102
|
+
rubyforge_project:
|
103
|
+
rubygems_version: 2.2.2
|
104
|
+
signing_key:
|
105
|
+
specification_version: 4
|
106
|
+
summary: A Ruby wrapper to the Abebooks SWS API
|
107
|
+
test_files:
|
108
|
+
- test/test_abebooks.rb
|
109
|
+
has_rdoc:
|