nostos-source-illiad 0.0.2 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
data/README.md
CHANGED
@@ -12,20 +12,26 @@ Add the following to your Gemfile and run `bundle install`
|
|
12
12
|
|
13
13
|
## Configuration
|
14
14
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
:
|
23
|
-
:
|
24
|
-
:
|
25
|
-
:
|
26
|
-
|
27
|
-
|
28
|
-
|
15
|
+
You can interactively configure the Illiad source driver by running `rails generate source_illiad:install`. This will prompt you for the necessariy values.
|
16
|
+
|
17
|
+
You can manually configure the Illiad source drive in `config/source_illiad.rb`:
|
18
|
+
|
19
|
+
number_of_days_to_poll: 14
|
20
|
+
|
21
|
+
db:
|
22
|
+
adapter: 'sqlserver'
|
23
|
+
dataserver: ''
|
24
|
+
username: ''
|
25
|
+
password: ''
|
26
|
+
|
27
|
+
webcirc:
|
28
|
+
url: 'http://HOSTNAME/illiad/WebCirc/Logon.aspx'
|
29
|
+
username: ''
|
30
|
+
password: ''
|
31
|
+
|
32
|
+
`dataserver` is the name for your server as defined in freetds.conf. `number_of_days_to_poll` is how many days you want to poll into the past. This number must be greater than how often you run Nostos in order to stay synchronized. I recommend polling 2-3 days in the past at most. Your WebCirc URL may be different, though the above should hold true for most OCLC hosted servers.
|
33
|
+
|
34
|
+
The `db` variable will actually be passed directly to `ActiveRecord#establish_connection` so you can define any additional parameters as necessary.
|
29
35
|
|
30
36
|
# Author
|
31
37
|
|
data/lib/nostos-source-illiad.rb
CHANGED
@@ -1,16 +1,13 @@
|
|
1
1
|
# Source::Illiad, Nostos Source Driver for Illiad
|
2
2
|
|
3
|
-
require 'nostos-source-illiad/railtie.rb'
|
3
|
+
require 'nostos-source-illiad/railtie.rb' if defined?(Rails)
|
4
4
|
require 'nostos-source-illiad/config.rb'
|
5
5
|
require 'nostos-source-illiad/record.rb'
|
6
6
|
require 'illiad'
|
7
7
|
require 'illiad/transaction.rb'
|
8
|
+
require 'nostos-source-illiad/generators/source_illiad_generator.rb'
|
8
9
|
|
9
10
|
|
10
|
-
# activerecord-illiad-adapter is named Illiad, so we must rename it to avoid
|
11
|
-
# naming conflict.
|
12
|
-
IlliadAR = Illiad
|
13
|
-
|
14
11
|
module Source
|
15
12
|
module Illiad
|
16
13
|
def self.config
|
@@ -22,7 +19,7 @@ module Source
|
|
22
19
|
end
|
23
20
|
|
24
21
|
def self.find(id)
|
25
|
-
|
22
|
+
::Illiad::AR::Transaction.find(id).to_record
|
26
23
|
end
|
27
24
|
|
28
25
|
# Poll Illiad for new transactions to process. The strategy is to find
|
@@ -50,7 +47,7 @@ module Source
|
|
50
47
|
Transactions.RequestType = 'Loan'
|
51
48
|
SQL
|
52
49
|
|
53
|
-
|
50
|
+
::Illiad::AR::Transaction.find_by_sql(sql).map {|t| t.to_record}
|
54
51
|
end
|
55
52
|
end
|
56
53
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
|
3
|
+
module SourceIlliad
|
4
|
+
class InstallGenerator < Rails::Generators::Base
|
5
|
+
def configure
|
6
|
+
# Ask General Questions
|
7
|
+
puts "General Configuration:"
|
8
|
+
number_of_days_to_poll = ask('How many days in the past would you like to poll Illiad? [7]')
|
9
|
+
number_of_days_to_poll = 7 if number_of_days_to_poll.blank?
|
10
|
+
|
11
|
+
# Ask DB Questions
|
12
|
+
puts "Database Configuration:"
|
13
|
+
puts "The following fields are required to establish a connection with your Illiad server."
|
14
|
+
db = {}
|
15
|
+
db[:dataserver] = ask('dataserver (the name for your server as defined in freetds.conf): ')
|
16
|
+
db[:username] = ask('username (the database server user): ')
|
17
|
+
db[:password] = ask('password (the user password): ')
|
18
|
+
|
19
|
+
# Ask WebCirc Questions
|
20
|
+
puts "WebCirc Configuration:"
|
21
|
+
webcirc = {}
|
22
|
+
webcirc[:url] = ask('URL: ')
|
23
|
+
webcirc[:username] = ask('Username: ')
|
24
|
+
webcirc[:password] = ask('Password: ')
|
25
|
+
|
26
|
+
# Configure application settings
|
27
|
+
create_file File.join(Rails.root, 'config', 'source_illiad.yml'), <<CONFIG
|
28
|
+
# Source Illiad Configuration
|
29
|
+
|
30
|
+
# This is the number of days into the past you would like to poll.
|
31
|
+
# This value must be greater than how often you run your daily cron job.
|
32
|
+
number_of_days_to_poll: #{number_of_days_to_poll}
|
33
|
+
|
34
|
+
# Database
|
35
|
+
db:
|
36
|
+
adapter: 'sqlserver'
|
37
|
+
dataserver: '#{db[:dataserver]}'
|
38
|
+
username: '#{db[:username]}'
|
39
|
+
password: '#{db[:password]}'
|
40
|
+
|
41
|
+
# Web Circulation
|
42
|
+
webcirc:
|
43
|
+
url: '#{webcirc[:url]}'
|
44
|
+
username: '#{webcirc[:username]}'
|
45
|
+
password: '#{webcirc[:password]}'
|
46
|
+
CONFIG
|
47
|
+
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -5,16 +5,21 @@ module Source
|
|
5
5
|
class Railtie < Rails::Railtie
|
6
6
|
config.source_illiad = ActiveSupport::OrderedOptions.new
|
7
7
|
|
8
|
+
|
8
9
|
initializer "source_illiad.configure" do |app|
|
9
|
-
|
10
|
-
config.number_of_days_to_poll = app.config.source_illiad[:number_of_days_to_poll]
|
11
|
-
config.db = app.config.source_illiad[:db]
|
12
|
-
config.webcirc = app.config.source_illiad[:webcirc]
|
13
|
-
end
|
14
|
-
end
|
10
|
+
config_file = File.join(Rails.root, 'config', 'source_illiad.yml')
|
15
11
|
|
16
|
-
|
17
|
-
|
12
|
+
# Only run configuration if config/source_illiad.yml exists
|
13
|
+
if File.exists?(config_file)
|
14
|
+
CONFIG = YAML::load(File.open(config_file))
|
15
|
+
Source::Illiad.configure do |config|
|
16
|
+
config.number_of_days_to_poll = CONFIG["number_of_days_to_poll"]
|
17
|
+
config.db = CONFIG["db"]
|
18
|
+
config.webcirc = CONFIG["webcirc"]
|
19
|
+
end
|
20
|
+
|
21
|
+
::Illiad::AR::Base.establish_connection(Source::Illiad.config.db)
|
22
|
+
end
|
18
23
|
end
|
19
24
|
end
|
20
25
|
end
|
@@ -15,7 +15,7 @@ module Source
|
|
15
15
|
|
16
16
|
def charged?(force = false)
|
17
17
|
if force then
|
18
|
-
t =
|
18
|
+
t = ::Illiad::AR::Transaction.find(@id)
|
19
19
|
@due_date = t.due_date
|
20
20
|
@charged = t.charged?
|
21
21
|
end
|
@@ -28,12 +28,12 @@ module Source
|
|
28
28
|
agent = Mechanize.new# { |a| a.log = Logger.new(STDERR) }
|
29
29
|
|
30
30
|
# Load Illiad Web Circulation
|
31
|
-
page = agent.get(Source::Illiad.config.webcirc[
|
31
|
+
page = agent.get(Source::Illiad.config.webcirc['url'])
|
32
32
|
|
33
33
|
# Select, fill in, and submit the logon form.
|
34
34
|
page = page.form('formLogon') do |f|
|
35
|
-
f.TextBoxUsername = Source::Illiad.config.webcirc[
|
36
|
-
f.TextBoxPassword = Source::Illiad.config.webcirc[
|
35
|
+
f.TextBoxUsername = Source::Illiad.config.webcirc['username']
|
36
|
+
f.TextBoxPassword = Source::Illiad.config.webcirc['password']
|
37
37
|
end.click_button
|
38
38
|
|
39
39
|
# Mechanize::ResponseCodeError - 500 => Net::HTTPInternalServerError:
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: nostos-source-illiad
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.4
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Brice Stacey
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-04-
|
13
|
+
date: 2011-04-21 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: illiad
|
@@ -51,6 +51,7 @@ files:
|
|
51
51
|
- lib/illiad/transaction.rb
|
52
52
|
- lib/nostos-source-illiad.rb
|
53
53
|
- lib/nostos-source-illiad/config.rb
|
54
|
+
- lib/nostos-source-illiad/generators/source_illiad_generator.rb
|
54
55
|
- lib/nostos-source-illiad/railtie.rb
|
55
56
|
- lib/nostos-source-illiad/record.rb
|
56
57
|
- lib/nostos-source-illiad/version.rb
|