nostos-target-voyager 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,9 @@
1
+ require 'rails'
2
+
1
3
  module Target
2
4
  module Voyager
3
5
  class Config
4
- attr_accessor :host, :port, :username, :password, :operator, :location
6
+ attr_accessor :db, :sip
5
7
  end
6
8
  end
7
9
  end
8
-
@@ -4,17 +4,19 @@ module Target
4
4
  module Voyager
5
5
  class Railtie < Rails::Railtie
6
6
  config.target_voyager = ActiveSupport::OrderedOptions.new
7
+ config.target_voyager.sip = ActiveSupport::OrderedOptions.new
8
+ config.target_voyager.db = ActiveSupport::OrderedOptions.new
7
9
 
8
10
  initializer "target_voyager.configure" do |app|
9
11
  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]
12
+ config.sip = app.config.target_voyager[:sip]
13
+ config.db = app.config.target_voyager[:db]
16
14
  end
17
15
  end
16
+
17
+ initializer "target_voyager.establish_connection", :after => "target_voyager.configure" do |app|
18
+ VoyagerGem::AR::Base.establish_connection(Target::Voyager.config.db)
19
+ end
18
20
  end
19
21
  end
20
22
  end
@@ -8,7 +8,7 @@ module Target
8
8
  begin
9
9
  @due_date = DateTime.strptime(attributes[:due_date], '%Y%m%d %H%M%S')
10
10
  rescue
11
- @due_date = nil
11
+ @due_date = attributes[:due_date]
12
12
  end
13
13
  end
14
14
 
@@ -1,5 +1,5 @@
1
1
  module Target
2
2
  module Voyager
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -1,7 +1,7 @@
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'
1
+ require 'voyager'
2
+ require 'nostos-target-voyager/railtie'
3
+ require 'nostos-target-voyager/config'
4
+ require 'nostos-target-voyager/record'
5
5
 
6
6
  VoyagerGem = Voyager
7
7
 
@@ -19,8 +19,8 @@ module Target
19
19
  def self.find(id)
20
20
  id = id.to_s unless id.is_a?(String)
21
21
 
22
- VoyagerGem::SipClient.new(config.host, config.port) do |sip|
23
- sip.login(config.username, config.password, config.location) do |response|
22
+ VoyagerGem::SIP::Client.new(config.sip[:host], config.sip[:port]) do |sip|
23
+ sip.login(config.sip[:username], config.sip[:password], config.sip[:location]) do |response|
24
24
  if response[:ok] != '1' # Login failed
25
25
  Rails::logger.error "Failed to sign in to SIP server"
26
26
  return false
@@ -57,8 +57,8 @@ module Target
57
57
  end
58
58
  # Illiad encodes strings in Windows-1252, but Voyager SIP requires all messages be ASCII.
59
59
 
60
- VoyagerGem::SipClient.new(config.host, config.port) do |sip|
61
- sip.login(config.username, config.password, config.location) do |response|
60
+ VoyagerGem::SIP::Client.new(config.sip[:host], config.sip[:port]) do |sip|
61
+ sip.login(config.sip[:username], config.sip[:password], config.sip[:location]) do |response|
62
62
  # First be sure that an item doesn't already exist.
63
63
  sip.item_status(item.id) do |item_status|
64
64
  unless item_status[:AF] == 'Item barcode not found. Please consult library personnel for assistance.'
@@ -69,7 +69,7 @@ module Target
69
69
  :charged => !item_status[:AH].empty?)
70
70
  else
71
71
  # Item doesn't exist
72
- sip.create_bib(config.operator, title, item.id) do |response|
72
+ sip.create_bib(config.sip[:operator], title, item.id) do |response|
73
73
  # Bib/MFHD/Item created. Store values.
74
74
  #
75
75
  # Values must be stored in order to delete the items via SIP.
@@ -86,5 +86,14 @@ module Target
86
86
  end
87
87
  nil
88
88
  end
89
+
90
+ def self.charged
91
+ VoyagerGem::AR::Item.joins(:circ_transaction).includes(:circ_transaction, :bib_text, :barcode).where(:item_type_id => 24).all.map do |item|
92
+ Target::Voyager::Record.new(:id => item.barcode.item_barcode,
93
+ :title => item.bib_item.bib_text.title,
94
+ :due_date => item.circ_transaction.current_due_date,
95
+ :charged => !item.circ_transaction.nil?)
96
+ end
97
+ end
89
98
  end
90
99
  end
@@ -18,5 +18,6 @@ Gem::Specification.new do |s|
18
18
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
- s.add_dependency('voyager-sip')
21
+ s.add_dependency('voyager')
22
+ s.add_dependency('rails')
22
23
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: nostos-target-voyager
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.1
5
+ version: 0.0.2
6
6
  platform: ruby
7
7
  authors:
8
8
  - Brice Stacey
@@ -10,10 +10,10 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-12 00:00:00 Z
13
+ date: 2011-04-15 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: voyager-sip
16
+ name: voyager
17
17
  prerelease: false
18
18
  requirement: &id001 !ruby/object:Gem::Requirement
19
19
  none: false
@@ -23,6 +23,17 @@ dependencies:
23
23
  version: "0"
24
24
  type: :runtime
25
25
  version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: rails
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0"
35
+ type: :runtime
36
+ version_requirements: *id002
26
37
  description: Nostos Target Driver for Voyager ILS
27
38
  email:
28
39
  - bricestacey@gmail.com