iii 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.
Files changed (5) hide show
  1. data/Rakefile +34 -0
  2. data/iii.rb +307 -0
  3. data/index.html +110 -0
  4. data/test_iii.rb +19 -0
  5. metadata +48 -0
@@ -0,0 +1,34 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+ require 'rake/rdoctask'
4
+ require 'rake/gempackagetask'
5
+ require 'rubygems'
6
+
7
+ task :default => [ :test, :gem, :rdoc ]
8
+
9
+ Rake::TestTask.new("test") { |t|
10
+ t.test_files = FileList['test*.rb']
11
+ }
12
+
13
+ Rake::RDocTask.new { |rdoc|
14
+ rdoc.rdoc_dir = 'doc'
15
+ rdoc.rdoc_files.include('iii.rb')
16
+ }
17
+
18
+ spec = Gem::Specification.new do |s|
19
+ s.name = 'iii'
20
+ s.version = "0.1"
21
+ s.platform = Gem::Platform::RUBY
22
+ s.summary = "A Simplified way to access the Innovative Interfaces Patron API written by Aaron Bedra"
23
+ s.files = Dir.glob("*").delete_if { |item| item.include?("svn") }
24
+ s.require_path = '.'
25
+ s.autorequire = 'iii'
26
+ s.author = "Aaron Bedra"
27
+ s.email = "aaron@aaronbedra.com"
28
+ s.rubyforge_project = "iii"
29
+ s.homepage = "http://rubyforge.org"
30
+ end
31
+ Rake::GemPackageTask.new(spec) do |pkg|
32
+ pkg.need_zip = true
33
+ pkg.need_tar = true
34
+ end
data/iii.rb ADDED
@@ -0,0 +1,307 @@
1
+ require 'rubygems'
2
+ require 'rubyful_soup'
3
+ require 'cgi'
4
+ require 'net/http'
5
+ require 'uri'
6
+
7
+
8
+ class Patron
9
+ attr_accessor :patron, :data
10
+
11
+ def initialize(catalog, barcode)
12
+ catalog = catalog
13
+ barcode = barcode
14
+ @patron = "http://#{catalog}:4500/PATRONAPI/#{barcode}/dump"
15
+
16
+ end
17
+
18
+ def get_data
19
+ url = URI.parse(@patron)
20
+ req = Net::HTTP::Get.new(url.path)
21
+ res = Net::HTTP.start(url.host, url.port) {|http|
22
+ http.request(req)
23
+ }
24
+ soup = BeautifulSoup.new(res.body)
25
+ data = Array.new
26
+ soup.body.contents.each { |t| data.push(t) if !t.is_a? Tag }
27
+ return data
28
+ end
29
+
30
+ def rec_info(data)
31
+ if !data.nil?
32
+ rec_info = data[0]
33
+ return rec_info
34
+ end
35
+ end
36
+
37
+ def exp_date(data)
38
+ if !data.nil?
39
+ exp_date = data[1]
40
+ return exp_date
41
+ end
42
+ end
43
+
44
+ def age_range(data)
45
+ if !data.nil?
46
+ age_range = data[2]
47
+ return age_range
48
+ end
49
+ end
50
+
51
+ def county(data)
52
+ if !data.nil?
53
+ county = data[3]
54
+ return county
55
+ end
56
+ end
57
+
58
+ def sch_dist(data)
59
+ if !data.nil?
60
+ sch_dist = data[4]
61
+ return sch_dist
62
+ end
63
+ end
64
+
65
+ def ptype(data)
66
+ if !data.nil?
67
+ ptype = data[5]
68
+ return ptype
69
+ end
70
+ end
71
+
72
+ def tot_chkout(data)
73
+ if !data.nil?
74
+ tot_chkout = data[6]
75
+ return tot_chkout
76
+ end
77
+ end
78
+
79
+ def tot_renewal(data)
80
+ if !data.nil?
81
+ tot_renewal = data[7]
82
+ return tot_renewal
83
+ end
84
+ end
85
+
86
+ def cur_chkout(data)
87
+ if !data.nil?
88
+ cur_chkout = data[8]
89
+ return cur_chkout
90
+ end
91
+ end
92
+
93
+ def home_libr(data)
94
+ if !data.nil?
95
+ home_libr = data[9]
96
+ return home_libr
97
+ end
98
+ end
99
+
100
+ def pmessage(data)
101
+ if !data.nil?
102
+ pmessage = data[10]
103
+ return pmessage
104
+ end
105
+ end
106
+
107
+ def mblock(data)
108
+ if !data.nil?
109
+ mblock = data[11]
110
+ return mblock
111
+ end
112
+ end
113
+
114
+ def rec_type(data)
115
+ if !data.nil?
116
+ rec_type = data[12]
117
+ return rec_type
118
+ end
119
+ end
120
+
121
+ def record(data)
122
+ if !data.nil?
123
+ record = data[13]
124
+ return record
125
+ end
126
+ end
127
+
128
+ def rec_leng(data)
129
+ if !data.nil?
130
+ rec_leng = data[14]
131
+ return rec_leng
132
+ end
133
+ end
134
+
135
+ def created(data)
136
+ if !data.nil?
137
+ created = data[15]
138
+ return created
139
+ end
140
+ end
141
+
142
+ def updated(data)
143
+ if !data.nil?
144
+ updated = data[16]
145
+ return updated
146
+ end
147
+ end
148
+
149
+ def revisions(data)
150
+ if !data.nil?
151
+ revisions = data[17]
152
+ return revisions
153
+ end
154
+ end
155
+
156
+ def agency(data)
157
+ if !data.nil?
158
+ agency = data[18]
159
+ return agency
160
+ end
161
+ end
162
+
163
+ def cl_rtrnd(data)
164
+ if !data.nil?
165
+ cl_rtrnd = data[19]
166
+ return cl_rtrnd
167
+ end
168
+ end
169
+
170
+ def money_owed(data)
171
+ if !data.nil?
172
+ money_owed = data[20]
173
+ return money_owed
174
+ end
175
+ end
176
+
177
+ def blk_until(data)
178
+ if !data.nil?
179
+ blk_until = data[21]
180
+ return blk_until
181
+ end
182
+ end
183
+
184
+ def cur_itema(data)
185
+ if !data.nil?
186
+ cur_itema = data[22]
187
+ return cur_itema
188
+ end
189
+ end
190
+
191
+ def cur_itemb(data)
192
+ if !data.nil?
193
+ cur_itemb = data[23]
194
+ return cur_itemb
195
+ end
196
+ end
197
+
198
+ def od_penalty(data)
199
+ if !data.nil?
200
+ od_penalty = data[24]
201
+ return od_penalty
202
+ end
203
+ end
204
+
205
+ def ill_reques(data)
206
+ if !data.nil?
207
+ ill_reques = data[25]
208
+ return ill_reques
209
+ end
210
+ end
211
+
212
+ def cur_itemc(data)
213
+ if !data.nil?
214
+ cur_itemc = data[26]
215
+ return cur_itemc
216
+ end
217
+ end
218
+
219
+ def cur_itemd(data)
220
+ if !data.nil?
221
+ cur_itemd = data[27]
222
+ return cur_itemd
223
+ end
224
+ end
225
+
226
+ def circactive(data)
227
+ if !data.nil?
228
+ circactive = data[28]
229
+ return circactive
230
+ end
231
+ end
232
+
233
+ def lang_pref(data)
234
+ if !data.nil?
235
+ lang_pref = data[29]
236
+ return lang_pref
237
+ end
238
+ end
239
+
240
+ def notice_pref(data)
241
+ if !data.nil?
242
+ notice_pref = data[30]
243
+ return notice_pref
244
+ end
245
+ end
246
+
247
+ def cur_regist(data)
248
+ if !data.nil?
249
+ cur_regist = data[31]
250
+ return cur_regist
251
+ end
252
+ end
253
+
254
+ def tot_regist(data)
255
+ if !data.nil?
256
+ tot_regist = data[32]
257
+ return tot_regist
258
+ end
259
+ end
260
+
261
+ def tot_attend(data)
262
+ if !data.nil?
263
+ tot_attend = data[33]
264
+ return tot_attend
265
+ end
266
+ end
267
+
268
+ def patrn_name(data)
269
+ if !data.nil?
270
+ patrn_name = data[34]
271
+ return patrn_name
272
+ end
273
+ end
274
+
275
+ def address(data)
276
+ if !data.nil?
277
+ address = data[35]
278
+ return address
279
+ end
280
+ end
281
+
282
+ def telephone(data)
283
+ if !data.nil?
284
+ telephone = data[36]
285
+ return telephone
286
+ end
287
+ end
288
+
289
+ def p_barcode(data)
290
+ if !data.nil?
291
+ p_barcode = data[37]
292
+ return p_barcode
293
+ end
294
+ end
295
+
296
+ def email_addr(data)
297
+ if !data.nil?
298
+ email_addr = data[38]
299
+ return email_addr
300
+ end
301
+ end
302
+
303
+ def method_missing(method_id, *params)
304
+ request(method_id.id2name.gsub(/_/, '.'), params[0])
305
+ end
306
+
307
+ end
@@ -0,0 +1,110 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
+
3
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
4
+ <head>
5
+ <title>iii.rb</title>
6
+ <style>
7
+ body {
8
+ font-family: arial;
9
+ color: #222;
10
+ margin: 0;
11
+ padding: 1.5em;
12
+ font-size: 0.9em;
13
+ }
14
+ h1 {
15
+ margin: 0;
16
+ }
17
+ h1+p {
18
+ margin-top: 0;
19
+ }
20
+ div {
21
+ border-top: 1px solid #ccc;
22
+ }
23
+ h2 {
24
+ float: left;
25
+ text-transform: uppercase;
26
+ font-size: .8em;
27
+ color: #555;
28
+ margin-top: .8em;
29
+ }
30
+ div p {
31
+ margin-top: .8em;
32
+ margin-left: 9em;
33
+ }
34
+ div pre {
35
+ margin-left: 11em;
36
+ }
37
+ code {
38
+ background-color: #ddd;
39
+ padding: 0em;
40
+ }
41
+ code span {
42
+ color: #707;
43
+ }
44
+ </style>
45
+ </head>
46
+ <body>
47
+ <h1>iii.rb</h1>
48
+ <p><em>An insanely easy Ruby interface to the <a href="http://www.iii.com/">Innovative Interfaces API</a> Aaron Bedra <a href="mailto:aaron@aaronbedra.com">aaron@aaronbedra.com</a>&gt;</em></p>
49
+
50
+ <div>
51
+ <h2>Get it</h2>
52
+ <p>via RubyGems: <code>gem install iii</code><br/>
53
+ ...or download the gem: <a href="pkg/iii-0.1.gem">iii-0.1.gem</a><br/>
54
+ ...or just get the source by itself: <a href="iii.rb">iii.rb</a></p>
55
+ </div>
56
+
57
+ <div>
58
+ <h2>Example</h2>
59
+ <p><pre><code>require 'iii'
60
+
61
+ <span># basics</span>
62
+ patron = Patron.new(catalog, barcode) <span># Create a III Patron specific connection</span>
63
+ data = patron.get_data <span># Retrieves the Patron's account information to an array</span>
64
+ record_info = patron.rec_info(data) <span># Retrieves the Patron's record info</span>
65
+ expiration_date = patron.exp_date(data) <span># Retrieves the Patron's account expiration date</span>
66
+ age_range = patron.age_range(data) <span># Retrieves the Patron's age range type</span>
67
+ county = patron.county(data) <span># Retrieves the Patron's county</span>
68
+ school_district = patron.sch_dist(data) <span># Retrieves the Patron's school district if applicable</span>
69
+ patron_type = patron.ptype(data) <span># Retrieves the Patron's patron type</span>
70
+ total_checkouts = patron.tot_chkout(data) <span># Retrieves the total number of items checked out</span>
71
+ total_renewals = patron.tot_renewal(data) <span># Retrieves the Patron's total renewals</span>
72
+ current_checkouts = patron.cur_chkout(data) <span># Retrieves the number of current items checked out</span>
73
+ home_library = patron.home_libr(data) <span># Retrieves the Patron's home library</span>
74
+ patron_message = patron.pmessage(data) <span># Retrieves the any messages on the patron's account</span>
75
+ block = patron.mblock(data) <span># Retrieves any block information</span>
76
+ record_type = patron.rec_type(data) <span># Retrieves the Patron's record type</span>
77
+ record = patron.record(data) <span># Retrieves the Patron's record information</span>
78
+ record_length = patron.rec_leng(data) <span># Retrieves the Patron's record length</span>
79
+ created = patron.created(data) <span># Retrieves the Patron's account creation date</span>
80
+ updated = patron.updated(data) <span># Retrieves the Patron's account updated date</span>
81
+ revisions = patron.revisions(data) <span># Retrieves the number of revisions on an account</span>
82
+ agency = patron.agency(data) <span># Retrieves agency data</span>
83
+ calls = patron.cl_rtrnd(data) <span># Retrieves call data</span>
84
+ fines = patron.money_owed(data) <span># Retrieves the Patron's fine data</span>
85
+ block_until = patron.blk_until(data) <span># Retrieves extra block information</span>
86
+ itema = patron.cur_itema(data) <span># Retrieves specific item information</span>
87
+ itemb = patron.cur_itemb(data) <span># Retrieves specific item information</span>
88
+ itemc = patron.cur_itemc(data) <span># Retrieves specific item information</span>
89
+ itemd = patron.cur_itemd(data) <span># Retrieves specific item information</span>
90
+ illiad_requests = patron.ill_reques(data) <span># Retrieves illiad request information</span>
91
+ circactive = patron.circactive(data) <span># ???</span>
92
+ locale = patron.lang_pref(data) <span># Retrieves the Patron's language preference</span>
93
+ notice_type = patron.notice_pref(data) <span># Retrieves the Patron's preferred notice type</span>
94
+ current_reg = patron.cur_regist(data) <span># Retrieves the Patron's current event registrations</span>
95
+ total_attendance = patron.tot_attend(data) <span># Retrieves the Patron's total event attendance</span>
96
+ patron_name = patron.patrn_name(data) <span># Retrieves the Patron's name</span>
97
+ address = patron.address(data) <span># Retrieves the Patron's address</span>
98
+ phone = patron.telephone(data) <span># Retrieves the Patron's phone</span>
99
+ barcode = patron.p_barcode(data) <span># Retrieves the Patron's barcode</span>
100
+ email = patron.email_addr(data) <span># Retrieves the Patron's email address</span>
101
+ </code></pre></p>
102
+ </div>
103
+
104
+ <div>
105
+ <h2>License</h2>
106
+ <p><a href="http://www.opensource.org/licenses/mit-license.php">MIT License</a>. Attribution and contribution encouraged.</p>
107
+ </div>
108
+
109
+ </body>
110
+ </html>
@@ -0,0 +1,19 @@
1
+ require 'iii'
2
+ require 'test/unit'
3
+
4
+ class TestIII < Test::Unit::TestCase
5
+
6
+ def setup
7
+ catalog = "catalog.westervillelibrary.org"
8
+ barcode = "2120898545"
9
+ @patron = Patron.new(catalog, barcode)
10
+ end
11
+
12
+ def test_get_data
13
+ data = @patron.get_data
14
+
15
+ assert_not_nil @patron
16
+ assert_not_nil data
17
+ end
18
+
19
+ end
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.11
3
+ specification_version: 1
4
+ name: iii
5
+ version: !ruby/object:Gem::Version
6
+ version: "0.1"
7
+ date: 2006-07-20 00:00:00 -04:00
8
+ summary: A Simplified way to access the Innovative Interfaces Patron API written by Aaron Bedra
9
+ require_paths:
10
+ - .
11
+ email: aaron@aaronbedra.com
12
+ homepage: http://rubyforge.org
13
+ rubyforge_project: iii
14
+ description:
15
+ autorequire: iii
16
+ default_executable:
17
+ bindir: bin
18
+ has_rdoc: false
19
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
20
+ requirements:
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
24
+ version:
25
+ platform: ruby
26
+ signing_key:
27
+ cert_chain:
28
+ authors:
29
+ - Aaron Bedra
30
+ files:
31
+ - iii.rb
32
+ - index.html
33
+ - Rakefile
34
+ - test_iii.rb
35
+ test_files: []
36
+
37
+ rdoc_options: []
38
+
39
+ extra_rdoc_files: []
40
+
41
+ executables: []
42
+
43
+ extensions: []
44
+
45
+ requirements: []
46
+
47
+ dependencies: []
48
+