nostos-target-voyager 0.0.1
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.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +30 -0
- data/Rakefile +2 -0
- data/lib/nostos-target-voyager/config.rb +8 -0
- data/lib/nostos-target-voyager/railtie.rb +20 -0
- data/lib/nostos-target-voyager/record.rb +37 -0
- data/lib/nostos-target-voyager/version.rb +5 -0
- data/lib/nostos-target-voyager.rb +90 -0
- data/nostos-target-voyager.gemspec +22 -0
- metadata +74 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# Nostos Target Driver: Voyager ILS
|
2
|
+
|
3
|
+
This is a Voyager target driver for Nostos.
|
4
|
+
|
5
|
+
See [Nostos](https://github.com/bricestacey/nostos) for more information.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add the following to your Gemfile and run `bundle install`
|
10
|
+
|
11
|
+
gem 'nostos-target-voyager'
|
12
|
+
|
13
|
+
## Configuration
|
14
|
+
|
15
|
+
In `config/application.rb` add the following options:
|
16
|
+
|
17
|
+
config.target_voyager.host = ''
|
18
|
+
config.target_voyager.port =
|
19
|
+
config.target_voyager.username = ''
|
20
|
+
config.target_voyager.password = ''
|
21
|
+
config.target_voyager.operator = ''
|
22
|
+
config.target_voyager.location = ''
|
23
|
+
|
24
|
+
Note that `username` and `location` is the operator id and location code used to sign into the SIP server (or Circulation module). `operator` is the operator id used for creating items. Theoretically they should be identical, however it is not required.
|
25
|
+
|
26
|
+
For more information on how to configure your Voyager system for SIP see the manual _Voyager 7.2 Interface to Self Check Modules Using 3M SIP User's Guide, November 2009_
|
27
|
+
|
28
|
+
# Author
|
29
|
+
|
30
|
+
Nostos was written by [Brice Stacey](https://github.com/bricestacey)
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'rails'
|
2
|
+
|
3
|
+
module Target
|
4
|
+
module Voyager
|
5
|
+
class Railtie < Rails::Railtie
|
6
|
+
config.target_voyager = ActiveSupport::OrderedOptions.new
|
7
|
+
|
8
|
+
initializer "target_voyager.configure" do |app|
|
9
|
+
Target::Voyager.configure do |config|
|
10
|
+
config.host = app.config.target_voyager[:host]
|
11
|
+
config.port = app.config.target_voyager[:port]
|
12
|
+
config.username = app.config.target_voyager[:username]
|
13
|
+
config.password = app.config.target_voyager[:password]
|
14
|
+
config.operator = app.config.target_voyager[:operator]
|
15
|
+
config.location = app.config.target_voyager[:location]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module Target
|
2
|
+
module Voyager
|
3
|
+
class Record
|
4
|
+
def initialize(attributes = {})
|
5
|
+
@id = attributes[:id]
|
6
|
+
@title = attributes[:title]
|
7
|
+
@charged = attributes[:charged]
|
8
|
+
begin
|
9
|
+
@due_date = DateTime.strptime(attributes[:due_date], '%Y%m%d %H%M%S')
|
10
|
+
rescue
|
11
|
+
@due_date = nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
attr_reader :id, :title, :due_date
|
16
|
+
|
17
|
+
def charged?(force = false)
|
18
|
+
if force then
|
19
|
+
r = Target::Voyager.find(@id)
|
20
|
+
@charged = r.charged
|
21
|
+
@due_date = r.due_date
|
22
|
+
end
|
23
|
+
|
24
|
+
@charged
|
25
|
+
end
|
26
|
+
|
27
|
+
private
|
28
|
+
|
29
|
+
attr_reader :charged
|
30
|
+
attr_writer :id, :title, :charged
|
31
|
+
|
32
|
+
def due_date=(date)
|
33
|
+
@due_date = DateTime.strptime(date, '%Y%m%d %H%M%S')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
require 'nostos-target-voyager/railtie.rb'
|
2
|
+
require 'nostos-target-voyager/config.rb'
|
3
|
+
require 'nostos-target-voyager/record.rb'
|
4
|
+
require 'voyager-sip'
|
5
|
+
|
6
|
+
VoyagerGem = Voyager
|
7
|
+
|
8
|
+
module Target
|
9
|
+
module Voyager
|
10
|
+
def self.config
|
11
|
+
@@config ||= Target::Voyager::Config.new
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.configure
|
15
|
+
yield self.config
|
16
|
+
end
|
17
|
+
|
18
|
+
# Target Interface
|
19
|
+
def self.find(id)
|
20
|
+
id = id.to_s unless id.is_a?(String)
|
21
|
+
|
22
|
+
VoyagerGem::SipClient.new(config.host, config.port) do |sip|
|
23
|
+
sip.login(config.username, config.password, config.location) do |response|
|
24
|
+
if response[:ok] != '1' # Login failed
|
25
|
+
Rails::logger.error "Failed to sign in to SIP server"
|
26
|
+
return false
|
27
|
+
end
|
28
|
+
|
29
|
+
if response[:ok] == '1' # Login successful
|
30
|
+
sip.item_status(id) do |item_status|
|
31
|
+
return nil unless item_status[:AF] == 'Item Info retrieved successfully.'
|
32
|
+
|
33
|
+
if item_status[:circ_status] == '04' || item_status[:circ_status] == '05'
|
34
|
+
target = Target::Voyager::Record.new(:id => id, :title => item_status[:AJ], :charged => true, :due_date => item_status[:AH])
|
35
|
+
else
|
36
|
+
target = Target::Voyager::Record.new(:id => id, :title => item_status[:AJ], :charged => false, :due_date => nil)
|
37
|
+
end
|
38
|
+
|
39
|
+
return target
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
nil
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.create(item = {})
|
49
|
+
return nil if item.id.nil? || item.title.nil?
|
50
|
+
|
51
|
+
# Title should truncate to 32 characters and append "/ *12345*"
|
52
|
+
title = "#{item.title[0..31]} / *#{item.id}*"
|
53
|
+
|
54
|
+
# Illiad encodes strings in Windows-1252, but Voyager SIP requires all messages be ASCII.
|
55
|
+
if item.class.to_s == 'Source::Illiad'
|
56
|
+
title = Iconv.iconv('ASCII//IGNORE', 'Windows-1252', title).join
|
57
|
+
end
|
58
|
+
# Illiad encodes strings in Windows-1252, but Voyager SIP requires all messages be ASCII.
|
59
|
+
|
60
|
+
VoyagerGem::SipClient.new(config.host, config.port) do |sip|
|
61
|
+
sip.login(config.username, config.password, config.location) do |response|
|
62
|
+
# First be sure that an item doesn't already exist.
|
63
|
+
sip.item_status(item.id) do |item_status|
|
64
|
+
unless item_status[:AF] == 'Item barcode not found. Please consult library personnel for assistance.'
|
65
|
+
# Item already exists
|
66
|
+
return Target::Voyager::Record.new(:id => item.id,
|
67
|
+
:title => item_status[:AJ],
|
68
|
+
:due_date => item_status[:AH],
|
69
|
+
:charged => !item_status[:AH].empty?)
|
70
|
+
else
|
71
|
+
# Item doesn't exist
|
72
|
+
sip.create_bib(config.operator, title, item.id) do |response|
|
73
|
+
# Bib/MFHD/Item created. Store values.
|
74
|
+
#
|
75
|
+
# Values must be stored in order to delete the items via SIP.
|
76
|
+
# Note: Voyager does not return mfhd_id.
|
77
|
+
Rails::logger.info "Successfully created item with barcode #{item.id}"
|
78
|
+
return Target::Voyager::Record.new(:id => item.id,
|
79
|
+
:title => title,
|
80
|
+
:due_date => nil,
|
81
|
+
:charged => false)
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
nil
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "nostos-target-voyager/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "nostos-target-voyager"
|
7
|
+
s.version = Target::Voyager::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Brice Stacey"]
|
10
|
+
s.email = ["bricestacey@gmail.com"]
|
11
|
+
s.homepage = "https://github.com/bricestacey/nostos-target-voyager"
|
12
|
+
s.summary = %q{Nostos Target Driver for Voyager ILS}
|
13
|
+
s.description = %q{Nostos Target Driver for Voyager ILS}
|
14
|
+
|
15
|
+
s.rubyforge_project = "nostos-target-voyager"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
s.add_dependency('voyager-sip')
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: nostos-target-voyager
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Brice Stacey
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
|
13
|
+
date: 2011-04-12 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: voyager-sip
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
type: :runtime
|
25
|
+
version_requirements: *id001
|
26
|
+
description: Nostos Target Driver for Voyager ILS
|
27
|
+
email:
|
28
|
+
- bricestacey@gmail.com
|
29
|
+
executables: []
|
30
|
+
|
31
|
+
extensions: []
|
32
|
+
|
33
|
+
extra_rdoc_files: []
|
34
|
+
|
35
|
+
files:
|
36
|
+
- .gitignore
|
37
|
+
- Gemfile
|
38
|
+
- README.md
|
39
|
+
- Rakefile
|
40
|
+
- lib/nostos-target-voyager.rb
|
41
|
+
- lib/nostos-target-voyager/config.rb
|
42
|
+
- lib/nostos-target-voyager/railtie.rb
|
43
|
+
- lib/nostos-target-voyager/record.rb
|
44
|
+
- lib/nostos-target-voyager/version.rb
|
45
|
+
- nostos-target-voyager.gemspec
|
46
|
+
homepage: https://github.com/bricestacey/nostos-target-voyager
|
47
|
+
licenses: []
|
48
|
+
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
|
52
|
+
require_paths:
|
53
|
+
- lib
|
54
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
56
|
+
requirements:
|
57
|
+
- - ">="
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: "0"
|
60
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
61
|
+
none: false
|
62
|
+
requirements:
|
63
|
+
- - ">="
|
64
|
+
- !ruby/object:Gem::Version
|
65
|
+
version: "0"
|
66
|
+
requirements: []
|
67
|
+
|
68
|
+
rubyforge_project: nostos-target-voyager
|
69
|
+
rubygems_version: 1.7.2
|
70
|
+
signing_key:
|
71
|
+
specification_version: 3
|
72
|
+
summary: Nostos Target Driver for Voyager ILS
|
73
|
+
test_files: []
|
74
|
+
|