koha 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/koha.rb +2 -1
- data/lib/koha/api_methods/biblio.rb +6 -0
- data/lib/koha/client.rb +1 -1
- data/lib/koha/version.rb +1 -1
- data/spec/api/client_spec.rb +7 -0
- data/spec/spec_helper.rb +0 -1
- metadata +4 -4
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Koha [![Build Status](https://travis-ci.org/cfitz/koha.png?branch=master)](https://travis-ci.org/cfitz/koha) [![Code Climate](https://codeclimate.com/github/cfitz/koha.png)](https://codeclimate.com/github/cfitz/koha)
|
1
|
+
# Koha [![Build Status](https://travis-ci.org/cfitz/koha.rb.png?branch=master)](https://travis-ci.org/cfitz/koha.rb) [![Code Climate](https://codeclimate.com/github/cfitz/koha.rb.png)](https://codeclimate.com/github/cfitz/koha.rb)
|
2
2
|
|
3
3
|
A simple ruby wrapper for the Koha ILS RESTFUL API.
|
4
4
|
|
data/lib/koha.rb
CHANGED
@@ -12,8 +12,9 @@ module Koha
|
|
12
12
|
class << self
|
13
13
|
def version; VERSION end
|
14
14
|
|
15
|
-
def connect *args
|
15
|
+
def connect url = 'http://localhost/cgi-bin/koha/rest.pl/', *args
|
16
16
|
opts = Hash === args[-1] ? args[-1] : {}
|
17
|
+
opts[:url] = url
|
17
18
|
Client.new Koha::Connection.new, opts
|
18
19
|
end
|
19
20
|
end
|
@@ -13,6 +13,12 @@ module Koha::Biblio
|
|
13
13
|
JSON.parse(get "biblio/#{biblionumber}/items", opts)
|
14
14
|
end
|
15
15
|
|
16
|
+
# this just finds the items based on a biblionumber
|
17
|
+
def find_items(opts = {})
|
18
|
+
opts[:params] ||= {}
|
19
|
+
opts[:params][:biblionumbers] = opts[:biblionumbers].join(",") if opts[:biblionumbers]
|
20
|
+
JSON.parse(get"items", opts)
|
21
|
+
end
|
16
22
|
|
17
23
|
# wrapper to check if a biblio is holdable
|
18
24
|
# take a koha biblio number and standard client opts
|
data/lib/koha/client.rb
CHANGED
@@ -29,7 +29,7 @@ class Koha::Client
|
|
29
29
|
end
|
30
30
|
|
31
31
|
# Create the get, post, and head methods
|
32
|
-
%W(get post put delete).each do |meth|
|
32
|
+
%W(get post put delete head).each do |meth|
|
33
33
|
class_eval <<-RUBY
|
34
34
|
def #{meth} path, opts = {}, &block
|
35
35
|
send_request path, opts.merge(:method => :#{meth}), &block
|
data/lib/koha/version.rb
CHANGED
data/spec/api/client_spec.rb
CHANGED
@@ -146,6 +146,13 @@ describe "Koha::Client" do
|
|
146
146
|
client.biblio_holdable?("1").should be_true
|
147
147
|
WebMock.should have_requested(:get, "http://localhost/koha/biblio/1/holdable")
|
148
148
|
end
|
149
|
+
|
150
|
+
it "should find the items for #find_items" do
|
151
|
+
stub_request(:get, "http://localhost/koha/items?biblionumbers=1,666,23").to_return(:status => 200, :body =>
|
152
|
+
"{\"1\":{\"fakeitemnumber\":{\"fake\":\"itemdata\"}},\"666\":{\"fakeitemnumber\":{\"fake\":\"itemdata\"}},\"23\":{\"fakeitemnumber\":{\"fake\":\"itemdata\"}}}" )
|
153
|
+
client.find_items(:biblionumbers => [1,666,23]).should be_true
|
154
|
+
WebMock.should have_requested(:get, "http://localhost/koha/items?biblionumbers=1,666,23")
|
155
|
+
end
|
149
156
|
|
150
157
|
# show how to use a borrowername
|
151
158
|
it "should call the biblio holdable items for #biblio_items_holdable?" do
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: koha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: simplecov
|
@@ -167,7 +167,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
167
167
|
version: '0'
|
168
168
|
segments:
|
169
169
|
- 0
|
170
|
-
hash:
|
170
|
+
hash: 3995804532362947245
|
171
171
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
172
172
|
none: false
|
173
173
|
requirements:
|
@@ -176,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
176
|
version: '0'
|
177
177
|
segments:
|
178
178
|
- 0
|
179
|
-
hash:
|
179
|
+
hash: 3995804532362947245
|
180
180
|
requirements: []
|
181
181
|
rubyforge_project:
|
182
182
|
rubygems_version: 1.8.25
|