-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathREADME
172 lines (125 loc) · 5.52 KB
/
README
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
Ruby KtoBlzCheck
================
rbKtoBlzCheck is a small Ruby extension for Linux (written in C) that provides
an interface for libktoblzcheck, a library to check German account numbers and
bank codes. See http://ktoblzcheck.sourceforge.net for details.
Install instructions
--------------------
Just install the gem with the following command:
$ gem install ktoblzcheck
Common errors:
--------------
* ruby extconf.rb fails with
"Couldn't find header file..." or
"Couldn't find link library..."
=> Make sure the ktoblzcheck library and header files are correctly installed.
=> Consult the file mkmf.log for details of build time checks
=> Hint: If you've build and installed the ktoblzcheck library from source, make sure
the install locations of the library files are listed in /etc/ld.so.conf and you've run
`ldconfig`
* compile errors
Nothing to mention here: the code compiles without warning on Linux 2.6.7,
glibc-2.3.2, gcc version 3.3.4 (Debian 1:3.3.4-7) with ruby 1.8.2
(2004-07-29) [i386-linux].
Dependencies:
-------------
- Ruby >= 1.8
- libktoblzcheck (obviously :)
The ktoblzcheck package can be downloaded from
http://ktoblzcheck.sourceforge.net/ as source distribution tar-ball or RPM.
Debian has a package named 'libktoblzcheck1-dev' available in testing and
unstable, simply apt-get install it.
Other platforms:
----------------
As I have no suitable non-Linux systems to mess around with, I have no idea
whether this Ruby extension compiles and/or runs correctly on other platforms.
I guess, there should be no problems on BSDish systems. While the C-code should
be quiet portable, I'm not sure if linking works correctly on Microsoft (R)
Windows (R).
Comments on problems with OSes other than Linux are always welcome.
License:
--------
BSD-style, see LICENSE
This project is based on the work of Sascha Loetz (blog.cadego.de, info@cadego(dot)de).
Ruby Interface:
===============
Example:
-----------------------------------------------------------------------
require 'ktoblzcheck'
$bc="20030700"
$an="0"
puts "Testing Bank Code: #{$bc} / Account No. #{$an}"
KtoBlzCheck.new do |kbc|
name,location=kbc.find($bc)
if name
puts "Bank found! #{name} located in #{location}"
else
puts "Bank not found!"
end
case kbc.check($bc,$an)
when KtoBlzCheck::ERROR
puts "Failed, bank code and account number don't match"
when KtoBlzCheck::OK
puts "Success, valid combination of bank code and account number"
when KtoBlzCheck::UNKNOWN
puts "Unknown."
when KtoBlzCheck::BANK_NOT_KNOWN
puts "Unknown bank code"
else
puts "Never reached :)"
end
end
-----------------------------------------------------------------------
For more code examples refer to the rbkbc program and the test-*.rb files
provided with this distribution.
Interface documentation:
========================
-----------------------------------------------------------------------
KtoBlzCheck.new [ |block| ] -> obj
KtoBlzCheck.new(datafilepath) [ |block| ] -> obj
-----------------------------------------------------------------------
Constructs a new KtoBlzCheck object, returns it or passes it to an
optional code block. If no block is provided, the user must call
KtoBlzCheck#close to ensure that all resources are freed
after usage.
If a parameter is passed to new it is interpreted as the path to the
data file to be used by libktoblzcheck. When the parameter is omitted,
the default file of libktoblzcheck is used
(usually /usr/[local/]share/[lib]ktoblzcheck[*]/bankdata.txt).
A nil value passed as parameter is ignored.
-----------------------------------------------------------------------
-----------------------------------------------------------------------
KtoBlzCheck#close
-----------------------------------------------------------------------
Closes the KtoBlzCheck object's handle for libktoblzcheck. Must be
called to prevent resource leaks if KtoBlzCheck#new is not used with
block syntax.
-----------------------------------------------------------------------
-----------------------------------------------------------------------
KtoBlzCheck#num_records -> aFixnum
-----------------------------------------------------------------------
Returns the number of entries in the currently used data file for
libktoblzcheck.
-----------------------------------------------------------------------
-----------------------------------------------------------------------
KtoBlzCheck#check(bank_code, account_no) -> aFixnum
-----------------------------------------------------------------------
Checks if bank_code and account_no form a valid combination. The
returned Fixnum indicates the result. The following constants can be
used test the result:
KtoBlzCheck::OK -> valid combination of bank code and account number
KtoBlzCheck::ERROR -> !OK
KtoBlzCheck::UNKNOWN -> no verification possible for unknown reason
KtoBlzCheck::BANK_NOT_KNOWN -> bank code not known
If bank_code and account_no are not of type String a TypeError is
raised.
-----------------------------------------------------------------------
-----------------------------------------------------------------------
KtoBlzCheck#find(bank_code) -> anArray
-----------------------------------------------------------------------
Looks up bank name and bank location (city) for the bank identified
by bank_code.
Returns an array with the bank's name (index 0) and the bank's location
(index 1). The returned array is empty if no bank is found for the given
bank code.
-----------------------------------------------------------------------