ktoblzcheck 1.44.0.beta

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1b8bf15cb12ce936e0eebbcd42e7acbde80848e0
4
+ data.tar.gz: b6fa4cf43a7a0e77818ed3e99ba02fe83e7b7004
5
+ SHA512:
6
+ metadata.gz: 46149af8e24289311bb21b484fea7e247bf2f5ad80519c643f63161f641dfaa6167fbc64655a2758711f110be32c9d1b49b302c0bfebfcb4d1967a3c0bda5a7d
7
+ data.tar.gz: eedbaf5a2892fa5a315da7fdf98ce287bd3014d6d8856a22fa18b3e2d58fe976bc63d7b067428972aa5f6ee64182dc8bef7f697f79a61e049fc6deb091a3baa2
@@ -0,0 +1,25 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *~
19
+ .ruby-*
20
+
21
+ # buildables
22
+ ext/**/Makefile
23
+ ext/**/*.so
24
+ ext/**/*.o
25
+ ext/**/*.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,8 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
4
+ - 2.0.0
5
+ - 1.9.3
6
+ before_install:
7
+ - sudo apt-get update -qq
8
+ - sudo apt-get install -qq ktoblzcheck libktoblzcheck1c2a libktoblzcheck1-dev
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ktoblzcheck.gemspec
4
+ gemspec
@@ -0,0 +1,36 @@
1
+ (c) 2004 Sascha Loetz (sloetz ( a t ) web.de). All rights reserved.
2
+
3
+ Redistribution and use in source and binary forms of this software, with
4
+ or without modification, are permitted provided that the following
5
+ conditions are met:
6
+
7
+ 1. Redistributions of source code must retain any existing copyright
8
+ notice, and this entire permission notice in its entirety,
9
+ including the disclaimer of warranties.
10
+
11
+ 2. Redistributions in binary form must reproduce all prior and current
12
+ copyright notices, this list of conditions, and the following
13
+ disclaimer in the documentation and/or other materials provided
14
+ with the distribution.
15
+
16
+ 3. The name of any author may not be used to endorse or promote
17
+ products derived from this software without their specific prior
18
+ written permission.
19
+
20
+ ALTERNATIVELY, this product may be distributed under the terms of the
21
+ GNU General Public License, in which case the provisions of the GNU
22
+ GPL are required INSTEAD OF the above restrictions. (This clause is
23
+ necessary due to a potential conflict between the GNU GPL and the
24
+ restrictions contained in a BSD-style copyright.)
25
+
26
+ THIS SOFTWARE IS PROVIDED AS IS'' AND ANY EXPRESS OR IMPLIED
27
+ WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
28
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
29
+ IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
30
+ INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31
+ BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
32
+ OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
33
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
34
+ TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
35
+ USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
36
+ DAMAGE.
@@ -0,0 +1,82 @@
1
+ # KtoBlzCheck
2
+
3
+ [![Build Status](https://travis-ci.org/dmke/ktoblzcheck.png?branch=master)](https://travis-ci.org/dmke/ktoblzcheck)
4
+
5
+ `KtoBlzCheck` is a small Ruby extension for Linux (written in C) that provides an interface for
6
+ [`libktoblzcheck`](http://ktoblzcheck.sourceforge.net), a library to check German
7
+ account numbers and bank codes. It further provides a simple query method to find
8
+ bank codes, locations and names
9
+
10
+ Huge chunks of this RubyGem is based on the original Ruby/C implementation
11
+ [rbKtoBlzCheck](https://github.com/krudolph/rbktoblzcheck) by Kim Rudolph.
12
+
13
+ ## Installation
14
+
15
+ You'll need
16
+
17
+ - Ruby v1.9.3 or higher (if you still run Ruby 1.8, use rbKtoBlzCheck)
18
+ - and `libktoblzcheck` (the package name may vary).
19
+
20
+ Add this line to your application's Gemfile:
21
+
22
+ gem 'ktoblzcheck'
23
+
24
+ And then execute:
25
+
26
+ $ bundle
27
+
28
+ Or install it yourself as:
29
+
30
+ $ gem install ktoblzcheck
31
+
32
+ If you get a warning like `Couldn't find header file ktoblzcheck.h`, make sure
33
+ you have `libktoblzcheck` installed. You can either fetch this library from
34
+ [SourceForge](http://ktoblzcheck.sourceforge.net) or install it on Debian/Ubuntu
35
+ with
36
+
37
+ # apt-get install -y libktoblzcheck1c2a libktoblzcheck1-dev
38
+
39
+ You can verify the installation e.g. by calling `locate ktoblzcheck.h`—this should
40
+ point to an existing file.
41
+
42
+ ## Usage
43
+
44
+ require 'ktoblzcheck'
45
+
46
+ @bank_code = "20030700"
47
+ @account_no = "0"
48
+
49
+ puts "Testing Bank Code: #{@bank_code} / Account No. #{@account_no}"
50
+
51
+ KtoBlzCheck.new do |kbc|
52
+ name, location = kbc.find(@bank_code)
53
+ if name
54
+ puts "Bank found! #{name} located in #{location}"
55
+ else
56
+ puts "Bank not found!"
57
+ end
58
+ case kbc.check(@bank_code, @account_no)
59
+ when KtoBlzCheck::ERROR
60
+ puts "Failed, bank code and account number don't match"
61
+ when KtoBlzCheck::OK
62
+ puts "Success, valid combination of bank code and account number"
63
+ when KtoBlzCheck::UNKNOWN
64
+ puts "Unknown."
65
+ when KtoBlzCheck::BANK_NOT_KNOWN
66
+ puts "Unknown bank code"
67
+ else
68
+ puts "Never reached :)"
69
+ end
70
+ end
71
+
72
+ ## License
73
+
74
+ 3-clause BSD or GPL (see `LICENSE.txt`)
75
+
76
+ ## Contributing
77
+
78
+ 1. Fork it
79
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
80
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
81
+ 4. Push to the branch (`git push origin my-new-feature`)
82
+ 5. Create new Pull Request
@@ -0,0 +1,27 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :spec_build do
7
+ Dir.chdir('ext/ktoblzcheck') do
8
+ output = `ruby extconf.rb`
9
+ raise output unless $? == 0
10
+ output = `make`
11
+ raise output unless $? == 0
12
+ end
13
+ end
14
+
15
+ task spec: :spec_build
16
+ task default: :spec
17
+
18
+ task console: :spec_build do
19
+ lib = File.expand_path('../lib', __FILE__)
20
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
21
+
22
+ require 'irb'
23
+ require 'irb/completion'
24
+ require 'ktoblzcheck'
25
+ ARGV.clear
26
+ IRB.start
27
+ end
@@ -0,0 +1,22 @@
1
+ require 'mkmf'
2
+
3
+ if !have_header('ktoblzcheck.h')
4
+ STDERR.puts "Couldn't find header file ktoblzcheck.h. Install library files and try again\n"
5
+ STDERR.puts "Hint: visit http://ktoblzcheck.sourceforge.net to obtain a source distribution tar-ball or check the package archives of your distribution (e.g. for Debian `apt-get install libktoblzcheck1-dev`)"
6
+ exit 1
7
+ end
8
+
9
+ if !have_header('iban.h')
10
+ STDERR.puts "Couldn't find header file iban.h. Install library files and try again\n"
11
+ STDERR.puts "Hint: visit http://ktoblzcheck.sourceforge.net to obtain a source distribution tar-ball or check the package archives of your distribution (e.g. for Debian `apt-get install libktoblzcheck1-dev`)"
12
+ exit 1
13
+ end
14
+
15
+ if !have_library('ktoblzcheck')
16
+ STDERR.puts "Couldn't find link library libktoblzcheck. Install library files and try again\n"
17
+ STDERR.puts "Hint: visit http://ktoblzcheck.sourceforge.net to obtain a source distribution tar-ball or check the package archives of your distribution (e.g. for Debian `apt-get install libktoblzcheck1-dev`)"
18
+ exit 1
19
+ end
20
+
21
+ dir_config('ktoblzcheck')
22
+ create_makefile('ktoblzcheck')
@@ -0,0 +1,345 @@
1
+ /***************************************************************************
2
+ *
3
+ * (c) 2004 Sascha Loetz (sloetz ( a t ) web.de). All rights reserved.
4
+ *
5
+ *
6
+ * Redistribution and use in source and binary forms of this software, with
7
+ * or without modification, are permitted provided that the following
8
+ * conditions are met:
9
+ *
10
+ * 1. Redistributions of source code must retain any existing copyright
11
+ * notice, and this entire permission notice in its entirety,
12
+ * including the disclaimer of warranties.
13
+ *
14
+ * 2. Redistributions in binary form must reproduce all prior and current
15
+ * copyright notices, this list of conditions, and the following
16
+ * disclaimer in the documentation and/or other materials provided
17
+ * with the distribution.
18
+ *
19
+ * 3. The name of any author may not be used to endorse or promote
20
+ * products derived from this software without their specific prior
21
+ * written permission.
22
+ *
23
+ * ALTERNATIVELY, this product may be distributed under the terms of the
24
+ * GNU General Public License, in which case the provisions of the GNU
25
+ * GPL are required INSTEAD OF the above restrictions. (This clause is
26
+ * necessary due to a potential conflict between the GNU GPL and the
27
+ * restrictions contained in a BSD-style copyright.)
28
+ *
29
+ * THIS SOFTWARE IS PROVIDED AS IS'' AND ANY EXPRESS OR IMPLIED
30
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
31
+ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
32
+ * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
33
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
34
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
35
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
36
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
37
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
38
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
39
+ * DAMAGE.
40
+ *************************************************************************
41
+ *
42
+ * This file is part of the ktoblzcheck package available as a gem
43
+ *
44
+ * $Id: ktoblzcheck.c,v 1.1 2004/10/28 19:10:19 vdpsoftware Exp $
45
+ *
46
+ *************************************************************************/
47
+ #include <stdio.h>
48
+ #include <stdlib.h>
49
+ #include <unistd.h>
50
+ #include <ruby.h>
51
+ #include <ktoblzcheck.h>
52
+ #include <iban.h>
53
+
54
+ static VALUE g_error;
55
+ static VALUE g_ktoblzcheck;
56
+ static VALUE g_ktoblzcheck_iban;
57
+ static AccountNumberCheck* g_anc = NULL;
58
+ static IbanCheck* g_ic = NULL;
59
+
60
+ #ifndef RUBY_19
61
+ #ifndef RSTRING_PTR
62
+ #define RSTRING_PTR(v) (RSTRING(v)->ptr)
63
+ #endif
64
+ #endif
65
+
66
+ /*
67
+ * call-seq:
68
+ * kbc.close -> nil
69
+ *
70
+ * Closes the KtoBlzCheck object's handle for `libktoblzcheck`. Must be called
71
+ * to prevent resource leaks if the constructor is not used with block syntax.
72
+ */
73
+ static VALUE
74
+ close_anc(VALUE self) {
75
+ if (NULL != g_anc) {
76
+ AccountNumberCheck_delete(g_anc);
77
+ }
78
+ return Qnil;
79
+ }
80
+
81
+ static VALUE
82
+ close_ic(VALUE self) {
83
+ if (NULL != g_ic) {
84
+ IbanCheck_free(g_ic);
85
+ }
86
+ return Qnil;
87
+ }
88
+
89
+ /*
90
+ * call-seq:
91
+ * KtoBlzCheck.new([datapath]) {|kbc| block } -> nil
92
+ * KtoBlzCheck.new([datapath]) -> kbc
93
+ *
94
+ * Constructs a new KtoBlzCheck object, returns it or passes it to an optional
95
+ * code block. If no block is provided, the user must call `kbc.close` to
96
+ * ensure that all resources are freed after usage.
97
+ *
98
+ * If a parameter is passed to new it is interpreted as the path to the data
99
+ * file to be used by `libktoblzcheck`. When the parameter is omitted, the
100
+ * default file of `libktoblzcheck` is used (usually
101
+ * `/usr/[local/]share/[lib]ktoblzcheck[*]/bankdata.txt`).
102
+ *
103
+ * A `nil` value passed as parameter is ignored.
104
+ */
105
+ static VALUE
106
+ init_anc(int argc, VALUE *argv, VALUE self)
107
+ {
108
+ VALUE dp = Qnil;
109
+
110
+ rb_scan_args(argc, argv, "01", &dp);
111
+
112
+ if (Qnil == dp) {
113
+ /* no parameter given */
114
+ g_anc = AccountNumberCheck_new();
115
+ } else {
116
+ /* a path to a different data path was passed to method */
117
+ Check_Type(dp, T_STRING);
118
+
119
+ /*
120
+ * The libktoblzcheck constructor writes an error message to stderr if the
121
+ * given data filen can not be accessed :(
122
+ * Additionally, we don't get a proper return value which could be used to
123
+ * test for success (it's a C++ constructor that we are calling). Even a
124
+ * successful intialization (i.e. we get a `pointer != NULL` from
125
+ * `AccountNumberCheck_new_file` doesn't mean that the opened file is a
126
+ * valid data file).
127
+ *
128
+ * We do basic access checking ourselves and hope for the best :)
129
+ */
130
+
131
+ if (0 != access(RSTRING_PTR(dp), R_OK)) {
132
+ rb_raise(g_error, "Can't access file %s", RSTRING_PTR(dp));
133
+ }
134
+ g_anc = AccountNumberCheck_new_file(RSTRING_PTR(dp));
135
+ }
136
+
137
+ /* did we successfully obtain an AccountNumberCheck handle? */
138
+
139
+ if (NULL == g_anc) {
140
+ rb_raise(g_error, "Couldn't initialize libktoblzcheck");
141
+ return Qnil;
142
+ }
143
+
144
+ if (rb_block_given_p()) {
145
+ return rb_ensure(rb_yield, self, close_anc, self);
146
+ } else {
147
+ return self;
148
+ }
149
+ }
150
+
151
+ static VALUE
152
+ init_ic(int argc, VALUE *argv, VALUE self)
153
+ {
154
+ VALUE dp = Qnil;
155
+
156
+ rb_scan_args(argc, argv, "01", &dp);
157
+
158
+ if (Qnil == dp) {
159
+ /* no parameter given */
160
+ g_ic = IbanCheck_new(NULL);
161
+ } else {
162
+ /* a path to a different data path was passed to method */
163
+ Check_Type(dp, T_STRING);
164
+
165
+ if (0 != access(RSTRING_PTR(dp), R_OK)) {
166
+ rb_raise(g_error, "Can't access file %s", RSTRING_PTR(dp));
167
+ }
168
+ g_ic = IbanCheck_new(RSTRING_PTR(dp));
169
+ }
170
+
171
+ /* did we successfully obtain an AccountNumberCheck handle? */
172
+ if (NULL == g_ic) {
173
+ rb_raise(g_error, "Couldn't initialize libktoblzcheck");
174
+ return Qnil;
175
+ }
176
+
177
+ if (rb_block_given_p()) {
178
+ return rb_ensure(rb_yield, self, close_ic, self);
179
+ } else {
180
+ return self;
181
+ }
182
+ }
183
+
184
+ /*
185
+ * call-seq:
186
+ * kbc.check(bank_code, account_no) -> fixnum
187
+ *
188
+ * Checks if `bank_code` and `account_no` form a valid combination. The
189
+ * returned Fixnum indicates the result. The following constants can be
190
+ * used test the result:
191
+ *
192
+ * KtoBlzCheck::OK #=> valid combination of bank code and account number
193
+ * KtoBlzCheck::ERROR #=> !OK
194
+ * KtoBlzCheck::UNKNOWN #=> no verification possible for unknown reason
195
+ * KtoBlzCheck::BANK_NOT_KNOWN #=> bank code not known
196
+ *
197
+ * If `bank_code` and `account_no` are not of type String, a TypeError is raised.
198
+ */
199
+ static VALUE
200
+ check_acn(VALUE self, VALUE blz, VALUE account)
201
+ {
202
+ AccountNumberCheck_Result res;
203
+ Check_Type(blz, T_STRING);
204
+ Check_Type(account, T_STRING);
205
+
206
+ res = AccountNumberCheck_check(g_anc, RSTRING_PTR(blz), RSTRING_PTR(account));
207
+ return INT2FIX(res);
208
+ }
209
+
210
+ static VALUE
211
+ check_ic(VALUE self, VALUE iban, VALUE country)
212
+ {
213
+ IbanCheck_Result res;
214
+ Check_Type(iban, T_STRING);
215
+ Check_Type(country, T_STRING);
216
+
217
+ res = IbanCheck_check_str(g_ic, RSTRING_PTR(iban), RSTRING_PTR(country));
218
+ return INT2FIX(res);
219
+ }
220
+
221
+ /*
222
+ * call-seq:
223
+ * kbc.num_records -> fixnum
224
+ *
225
+ * Returns the number of entries in the currently used data file for
226
+ * `libktoblzcheck`.
227
+ */
228
+ static VALUE
229
+ num_records(VALUE self)
230
+ {
231
+ return INT2FIX(AccountNumberCheck_bankCount(g_anc));
232
+ }
233
+
234
+ /*
235
+ * call-seq:
236
+ * kbc.find(bank_code) -> array
237
+ *
238
+ * Looks up bank name and bank location (city) for the bank identified by
239
+ * `bank_code`.
240
+ *
241
+ * Returns an array with the bank's name (index 0) and the bank's location
242
+ * (index 1). The returned array is empty if no bank is found for the given
243
+ * bank code.
244
+ */
245
+ static VALUE
246
+ find_info(VALUE self, VALUE blz)
247
+ {
248
+ VALUE ret = rb_ary_new2(2);
249
+ const AccountNumberCheck_Record* cr;
250
+
251
+ Check_Type(blz, T_STRING);
252
+
253
+ cr = AccountNumberCheck_findBank(g_anc, RSTRING_PTR(blz));
254
+
255
+ if (NULL != cr) {
256
+ rb_ary_push(ret, rb_str_new2(AccountNumberCheck_Record_bankName(cr)));
257
+ rb_ary_push(ret, rb_str_new2(AccountNumberCheck_Record_location(cr)));
258
+ }
259
+
260
+ return ret;
261
+ }
262
+
263
+ /*
264
+ * call-seq:
265
+ * KtoBlzCheck.bankdata_dir -> string
266
+ *
267
+ * Returns the directory where the bankdata file is stored, usually
268
+ * `/usr/[local/]share/[lib]ktoblzcheck[*]/`.
269
+ */
270
+ static VALUE
271
+ bankdata_dir()
272
+ {
273
+ return rb_str_new2(AccountNumberCheck_bankdata_dir());
274
+ }
275
+
276
+ /*
277
+ * call-seq:
278
+ * KtoBlzCheck.encoding -> string
279
+ *
280
+ * Returns the character encoding that is used when strings are returned. So
281
+ * far this has been `ISO-8859-15` (up to and including version 1.11), but at
282
+ * some point in the future it might change into `UTF-8`.
283
+ *
284
+ * For Ruby scripts, this value has little to no relevance, except you want to
285
+ * mess with `KtoBlzCheck.bankdata_dir`.
286
+ */
287
+ static VALUE
288
+ encoding()
289
+ {
290
+ return rb_str_new2(AccountNumberCheck_stringEncoding());
291
+ }
292
+
293
+ /*
294
+ * Document-class: KtoBlzCheck
295
+ *
296
+ * A collection of methods around German bank account checks.
297
+ */
298
+
299
+ /*
300
+ * Document-class: KtoBlzCheck::Error
301
+ *
302
+ * Error thrown, when the underlying `libktoblzcheck` fails to complete a task.
303
+ */
304
+
305
+ /*
306
+ * Ruby extension stuff
307
+ */
308
+ void
309
+ Init_ktoblzcheck()
310
+ {
311
+ g_ktoblzcheck = rb_define_class("KtoBlzCheck", rb_cObject);
312
+ g_error = rb_define_class_under(g_ktoblzcheck, "Error", rb_eStandardError);
313
+
314
+ rb_define_singleton_method(g_ktoblzcheck, "bankdata_dir", bankdata_dir, 0);
315
+ rb_define_singleton_method(g_ktoblzcheck, "encoding", encoding, 0);
316
+
317
+ rb_define_const(g_ktoblzcheck, "VERSION", rb_str_new2(AccountNumberCheck_libraryVersion()));
318
+
319
+ rb_define_const(g_ktoblzcheck, "OK", INT2FIX(0));
320
+ rb_define_const(g_ktoblzcheck, "UNKNOWN", INT2FIX(1));
321
+ rb_define_const(g_ktoblzcheck, "ERROR", INT2FIX(2));
322
+ rb_define_const(g_ktoblzcheck, "BANK_NOT_KNOWN", INT2FIX(3));
323
+
324
+ rb_define_method(g_ktoblzcheck, "initialize", init_anc, -1);
325
+ rb_define_method(g_ktoblzcheck, "check", check_acn, 2);
326
+ rb_define_method(g_ktoblzcheck, "num_records", num_records, 0);
327
+ rb_define_method(g_ktoblzcheck, "close", close_anc, 0);
328
+ rb_define_method(g_ktoblzcheck, "find", find_info, 1);
329
+
330
+ g_ktoblzcheck_iban = rb_define_class_under(g_ktoblzcheck, "IBAN", rb_cObject);
331
+
332
+ rb_define_const(g_ktoblzcheck_iban, "VERSION", rb_str_new2(AccountNumberCheck_libraryVersion())); /* yup. */
333
+
334
+ rb_define_const(g_ktoblzcheck_iban, "OK", INT2FIX(0));
335
+ rb_define_const(g_ktoblzcheck_iban, "TOO_SHORT", INT2FIX(1));
336
+ rb_define_const(g_ktoblzcheck_iban, "PREFIX_NOT_FOUND", INT2FIX(2));
337
+ rb_define_const(g_ktoblzcheck_iban, "WRONG_LENGTH", INT2FIX(3));
338
+ rb_define_const(g_ktoblzcheck_iban, "COUNTRY_NOT_FOUND", INT2FIX(4));
339
+ rb_define_const(g_ktoblzcheck_iban, "WRONG_COUNTRY", INT2FIX(5));
340
+ rb_define_const(g_ktoblzcheck_iban, "BAD_CHECKSUM", INT2FIX(6));
341
+
342
+ rb_define_method(g_ktoblzcheck_iban, "initialize", init_ic, -1);
343
+ rb_define_method(g_ktoblzcheck_iban, "check", check_ic, 2);
344
+ rb_define_method(g_ktoblzcheck_iban, "close", close_ic, 0);
345
+ }
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "ktoblzcheck"
7
+ spec.version = "1.44.0.beta"
8
+ spec.authors = ["Sascha Loetz", "Kim Rudolph", "Dominik Menke"]
9
+ spec.email = ["kim.rudolph@web.de", "dom@digineo.de"]
10
+ spec.description =
11
+ spec.summary = %q{ktoblzcheck is an interface for libktoblzcheck, a library to check German account numbers and bank codes. See http://ktoblzcheck.sourceforge.net for details.}
12
+ spec.homepage = "http://github.com/dmke/ktoblzcheck"
13
+ spec.license = "GPL"
14
+
15
+ spec.files = `git ls-files`.split($/)
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["ext", "lib"]
19
+ spec.extensions = ["ext/ktoblzcheck/extconf.rb"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.3"
22
+ spec.add_development_dependency "rake"
23
+ spec.add_development_dependency "rspec"
24
+ end
@@ -0,0 +1,100 @@
1
+ # encoding: UTF-8
2
+
3
+ require 'ktoblzcheck/ktoblzcheck'
4
+ require 'pathname'
5
+
6
+ class KtoBlzCheck
7
+ RESULT_CODES = {
8
+ OK => 'OK',
9
+ UNKNOWN => 'unknown validation algorithm',
10
+ ERROR => 'account and bank do not match',
11
+ BANK_NOT_KNOWN => 'bank is unknown'
12
+ }
13
+
14
+ # A simple data structure to hold basic bank information.
15
+ #
16
+ # @param blz "Bankleitzahl, BLZ", German bank identification number
17
+ # @param mid checksum method id (is only internally used)
18
+ # @param name bank name
19
+ # @param location bank location
20
+ class Bank < Struct.new(:blz, :mid, :name, :location)
21
+ # @returns string representation
22
+ def to_s
23
+ [blz, name, location].join(', ')
24
+ end
25
+
26
+ # Check whether BLZ, name or location matches against query parameter.
27
+ #
28
+ # @param [Regexp] query
29
+ # @returns A truthy value, if match was positive
30
+ def matches?(query)
31
+ [blz, name, location].any?{|e| e =~ query }
32
+ end
33
+ end
34
+
35
+ # an exhaustive list of banks.
36
+ KNOWN_BANKS = begin
37
+ known = []
38
+ Pathname.new(bankdata_dir).children.select{|c|
39
+ c.basename.to_s =~ /^bankdata.*\.txt$/
40
+ }.sort.last.open("r:#{encoding}:#{__ENCODING__}") do |f|
41
+ f.readlines.each do |l|
42
+ known << Bank.new(*l.strip.split("\t"))
43
+ end
44
+ end
45
+ known
46
+ end
47
+
48
+ # Query the known banks and search for the given particle.
49
+ #
50
+ # @param [#to_s] query a particle to match against BLZ, bank name or bank location.
51
+ # @param [int|nil] limit maximum result length (default to 10), `nil` disables limit.
52
+ # @returns [Array] query result list
53
+ def self.search(query, limit=10)
54
+ candidates = []
55
+ q = Regexp.new Regexp.escape(query), Regexp::IGNORECASE
56
+
57
+ KNOWN_BANKS.each do |b|
58
+ break if candidates.size > limit
59
+ candidates << b.to_s if b.matches?(q)
60
+ end
61
+
62
+ candidates
63
+ end
64
+
65
+ def self.check(blz, kto)
66
+ res = nil
67
+ new {|e| res = e.check(blz.to_s, kto.to_s) }
68
+ res
69
+ end
70
+
71
+ def self.check!(blz, kto)
72
+ res = check(blz, kto)
73
+ return true if res == OK
74
+ raise KtoBlzCheck::Error, RESULT_CODES[res]
75
+ end
76
+
77
+ class IBAN
78
+ RESULT_CODES = {
79
+ OK => 'IBAN is ok',
80
+ TOO_SHORT => 'IBAN is too short',
81
+ PREFIX_NOT_FOUND => 'unknown IBAN country prefix',
82
+ WRONG_LENGTH => 'wrong length of IBAN',
83
+ COUNTRY_NOT_FOUND => 'country for IBAN not found',
84
+ WRONG_COUNTRY => 'IBAN prefix does not match for country',
85
+ BAD_CHECKSUM => 'bad checksum'
86
+ }
87
+
88
+ def self.check(iban)
89
+ res = nil
90
+ new {|e| res = e.check(iban.gsub(/\s+/, ''), iban[0,2].upcase) }
91
+ res
92
+ end
93
+
94
+ def self.check!(iban)
95
+ res = check(iban)
96
+ return true if res == OK
97
+ raise KtoBlzCheck::Error, RESULT_CODES[res]
98
+ end
99
+ end
100
+ end
@@ -0,0 +1,162 @@
1
+ # extracted from http://www.bundesbank.de/Redaktion/DE/Downloads/Kerngeschaeftsfelder/Unbarer_Zahlungsverkehr/pruefzifferberechnungsmethoden.pdf
2
+ # updated version from 09/2013
3
+ #
4
+ # notation: checksum method -> example account numbers
5
+ ok:
6
+ '00': ['9290701', '539290858', '1501824', '1501832']
7
+ '06': ['94012341', '5073321010']
8
+ '10': ['12345008', '87654008']
9
+ '17': ['0446786040']
10
+ '19': ['0240334000', '0200520016']
11
+ '24': ['138301', '1306118605', '3307118608', '9307118603']
12
+ '25': ['521382181']
13
+ '26': ['0520309001', '1111118111', '0005501024']
14
+ '27': ['2847169488']
15
+ '28': ['19999000', '9130000201']
16
+ '29': ['3145863029']
17
+ '31': ['1000000524', '1000000583']
18
+ '32': ['9141405', '1709107983', '0122116979', '0121114867', '9030101192', '9245500460']
19
+ '33': ['48658', '84956']
20
+ '34': ['9913000700', '9914001000']
21
+ '35': ['0000108443', '0000107451', '0000102921', '0000102349', '0000101709', '0000101599']
22
+ '36': ['113178', '146666']
23
+ '37': ['624315', '632500']
24
+ '38': ['191919', '1100660']
25
+ '39': ['200205', '10019400']
26
+ '40': ['1258345', '3231963']
27
+ '41': ['4013410024', '4016660195', '0166805317', '4019310079', '4019340829', '4019151002']
28
+ '42': ['59498', '59510']
29
+ '43': ['6135244', '9516893476']
30
+ '44': ['889006', '2618040504']
31
+ '45': ['0994681254', '0000012340', '1000199999', '0100114240']
32
+ '46': ['0235468612', '0837890901', '1041447600']
33
+ '47': ['1018000', '1003554450']
34
+ '50': ['4000005001', '4444442001']
35
+ '51': ['0001156071', '0001156136', '0001156078', '0001234567', '340968', '201178', '1009588', '0000156071', '101356073', '0199100002', '0099100010', '2599100002', '0199100004', '2599100003', '3199204090']
36
+ '54': ['4964137395', '4900010987', '64137395', '00010987']
37
+ '56': ['0290545005', '9718304037']
38
+ '57': ['7500021766', '9400001734', '7800028282', '8100244186', '3251080371', '3891234567', '7777778800', '5001050352', '5045090090', '1909700805', '9322111030', '7400060823']
39
+ '58': ['1800881120', '9200654108', '1015222224', '3703169668']
40
+ '61': ['2063099200', '0260760481']
41
+ '62': ['5029076701']
42
+ '63': ['123456600', '0001234566']
43
+ '64': ['1206473010', '5016511020']
44
+ '65': ['1234567400', '1234567590']
45
+ '66': ['100154508', '101154508', '100154516', '101154516']
46
+ '68': ['8889654328', '987654324', '987654328']
47
+ '69': ['9721134869', '1234567900', '1234567006']
48
+ '71': ['7101234007']
49
+ '73': ['0003503398', '0001340967', '0003503391', '0001340968', '0003503392', '0001340966', '123456']
50
+ '74': ['1016', '26260', '242243', '242248', '18002113', '1821200043']
51
+ '76': ['0006543200', '9012345600', '7876543100']
52
+ '77': ['10338', '13844', '65354', '69258']
53
+ '78': ['7581499', '9999999981']
54
+ '79': ['3230012688', '4230028872', '5440001898', '6330001063', '7000149349', '8000003577', '1550167850', '9011200140']
55
+ '80': ['340968', '370966']
56
+ '81': ['0646440', '1359100']
57
+ '82': ['123897', '3199500501']
58
+ '83': ['0001156071', '0001156136', '0000156078', '0000156071', '0099100002']
59
+ '84': ['240699', '350982', '461059', '240692', '350985', '461052', '240961', '350984', '461054']
60
+ '85': ['0001156071', '0001156136', '0000156078', '0000156071', '3199100002']
61
+ '86': ['340968', '1001171', '1009588', '123897', '340960']
62
+ '87': ['0000000406', '0000051768', '0010701590', '0010720185', '0000100005', '0000393814', '0000950360', '3199500501']
63
+ '88': ['2525259', '1000500', '90013000', '92525253', '99913003']
64
+ '89': ['1098506', '32028008', '218433000']
65
+ '90': ['0001975641', '0001988654', '0000863530', '0000784451', '0000654321', '0000824491', '0000677747', '0000840507', '0000996663', '0000666034', '0099100002']
66
+ '91': ['2974118000', '5281741000', '9952810000', '2974117000', '5281770000', '9952812000', '8840019000', '8840050000', '8840087000', '8840045000', '8840012000', '8840055000', '8840080000']
67
+ '93': ['6714790000', '0000671479', '1277830000', '0000127783', '1277910000', '0000127791', '3067540000', '0000306754']
68
+ '94': ['6782533003']
69
+ '95': ['0068007003', '0847321750', '6450060494', '6454000003']
70
+ '96': ['0000000208', '0101115152', '0301204301']
71
+ '97': ['24010019']
72
+ '98': ['9619439213', '3009800016', '9619509976', '5989800173', '9619319999', '6719430018']
73
+ '99': ['0068007003', '0847321750']
74
+ 'A0': ['521003287', '54500', '3287', '18761', '28290']
75
+ 'A1': ['0010030005', '0010030997', '1010030054']
76
+ 'A2': ['3456789012']
77
+ 'A3': ['1234567897', '0123456782', '9876543210', '1234567890', '0123456789']
78
+ 'A4': ['0004711173', '0007093330', '0004711172', '0007093335', '1199503010', '8499421235', '0000862342', '8997710000', '0664040000', '0000905844', '5030101099', '0001123458', '1299503117']
79
+ 'A5': ['9941510001', '9961230019', '9380027210', '9932290910', '0000251437', '0007948344', '0000159590', '0000051640']
80
+ 'A6': ['17', '55300030', '150178033', '600003555', '900291823']
81
+ 'A7': ['19010008', '19010438', '19010660', '19010876', '209010892']
82
+ 'A8': ['7436661', '7436670', '1359100', '7436660', '7436678', '0003503398', '0001340967']
83
+ 'A9': ['5043608', '86725', '504360', '822035', '32577083']
84
+ 'B0': ['1197423162', '1000000606', '1000000406', '1035791538', '1126939724', '1197423460']
85
+ 'B1': ['1434253150', '2746315471', '7414398260', '8347251693']
86
+ 'B2': ['0020012357', '0080012345', '0926801910', '1002345674', '8000990054', '9000481805']
87
+ 'B3': ['1000000060', '0000000140', '0000000019', '1002798417', '8409915001', '9635000101', '9730200100']
88
+ 'B4': ['9941510001', '9961230019', '9380027210', '9932290910', '0000251437', '0007948344', '0000051640']
89
+ 'B5': ['0159006955', '2000123451', '1151043216', '9000939033', '0123456782', '0130098767', '1045000252']
90
+ 'B6': ['9110000000', '0269876545', '487310018']
91
+ 'B7': ['0700001529', '0730000019', '0001001008', '0001057887', '0001007222', '0810011825', '0800107653', '0005922372']
92
+ 'B8': ['0734192657', '6932875274', '3145863029', '2938692523']
93
+ 'B9': ['87920187', '41203755', '81069577', '61287958', '58467232', '7125633', '1253657', '4353631']
94
+ 'C0': ['43001500', '48726458', '0082335729', '0734192657', '6932875274']
95
+ 'C1': ['0446786040', '0478046940', '0701625830', '0701625840', '0882095630', '5432112349', '5543223456', '5654334563', '5765445670', '5876556788']
96
+ 'C2': ['2394871426', '4218461950', '7352569148', '5127485166', '8738142564']
97
+ 'C3': ['9294182', '4431276', '19919', '9000420530', '9000010006', '9000577650']
98
+ 'C4': ['0000000019', '0000292932', '0000094455', '9000420530', '9000010006', '9000577650']
99
+ 'C5': ['0000301168', '0000302554', '0300020050', '0300566000', '1000061378', '1000061412', '4450164064', '4863476104', '5000000028', '5000000391', '6450008149', '6800001016', '9000100012', '9000210017', '3060188103', '3070402023']
100
+ 'C6': ['0000065516', '0203178249', '1031405209', '1082012201', '2003455189', '2004001016', '3110150986', '3068459207', '5035105948', '5286102149', '4012660028', '4100235626', '6028426119', '6861001755', '7008199027', '7002000023', '8526080015', '8711072264', '9000430223', '9000781153']
101
+ 'C7': ['3500022', '38150900', '600103660', '39101181', '94012341', '5073321010']
102
+ 'C8': ['3456789019', '5678901231', '3456789012', '0022007130', '0123456789', '0552071285']
103
+ 'C9': ['3456789019', '5678901231', '0123456789']
104
+ 'D0': ['6100272324', '6100273479']
105
+ 'D1': ['0082012203', '1452683581', '2129642505', '3002000027', '4230001407', '5000065514', '6001526215', '7126502149', '9000430223']
106
+ 'D2': ['189912137', '235308215', '4455667784', '1234567897', '51181008', '71214205']
107
+ 'D3': ['1600169591', '1600189151', '1800084079', '6019937007', '6021354007', '6030642006']
108
+ 'D4': ['1112048219', '2024601814', '3000005012', '4143406984', '5926485111', '6286304975', '7900256617', '8102228628', '9002364588']
109
+ 'D5': ['5999718138', '1799222116', '0099632004', '0004711173', '0007093330', '0000127787', '0004711172', '0007093335', '0000100062', '0000100088']
110
+ 'D6': ['3409', '585327', '1650513', '3601671056', '4402001046', '6100268241', '7001000681', '9000111105', '9001291005']
111
+ 'D7': ['0500018205', '0230103715', '0301000434', '0330035104', '0420001202', '0134637709', '0201005939', '0602006999']
112
+ 'D8': ['1403414848', '6800000439', '6899999954']
113
+ 'D9': ['1234567897', '0123456782', '9876543210', '1234567890', '0123456789', '1100132044', '1100669030']
114
+ 'E0': ['1234568013', '1534568010', '2610015', '8741013011']
115
+ error:
116
+ '51': ['0001156078', '0000156079', '0001234566', '0012345678', '0023456783', '0076543211', '0123412345', '67493647', '0199100004', '2599100003', '0099345678', '0099345678', '0099100110', '0199100040']
117
+ '57': ['5302707782', '6412121212', '1813499124', '2206735010']
118
+ '73': ['0003503391', '0001340966', '0003503392', '0001340966', '121212', '987654321']
119
+ '74': ['1011', '26265', '18002118', '6160000024']
120
+ '84': ['240965', '350980', '461053', '240965', '350980', '461053', '240965', '350980', '461053']
121
+ '90': ['0001924592', '0000654321', '0000901568', '0000997664', '0000863536', '0000820487', '0000820484', '0000654328', '0000726393', '0000677742', '0000726391', '0000924591', '0099100007']
122
+ '91': ['8840017000', '8840023000', '8840041000', '8840014000', '8840026000', '8840045000', '8840011000', '8840025000', '8840062000', '840010000', '8840057000']
123
+ 'A1': ['0110030005', '0010030998', '0000030005']
124
+ 'A2': ['1234567890', '0123456789']
125
+ 'A3': ['9876543210', '1234567890', '6543217890', '0543216789', '6543217890', '0543216789']
126
+ 'A4': ['0004711172', '8623420004', '0001123458', '8623420000', '0001123458', '1299503117', '6099702031', '0000399443', '0000553313']
127
+ 'A5': ['9941510002', '9961230020', '0000251438', '0007948345']
128
+ 'A6': ['305888', '200071280']
129
+ 'A7': ['19010660', '19010876', '209010892', '209010893', '209010893']
130
+ 'A8': ['7436660', '7436678', '7436666', '7436677', '0003503391', '0001340966']
131
+ 'A9': ['504360', '822035', '32577083', '86724', '86724', '292497', '30767208']
132
+ 'B0': ['8137423260', '600000606', '51234309', '1000000405', '1035791539', '8035791532', '535791830', '51234901']
133
+ 'B1': ['7414398260', '8347251693', '0123456789', '2345678901', '5678901234', '0123456789', '2345678901', '5678901234']
134
+ 'B2': ['0020012399', '0080012347', '0080012370', '0932100027', '3310123454', '8000990057', '8011000126', '9000481800', '9980480111']
135
+ 'B3': ['0002799899', '1000000111', '9635100101', '9730300100']
136
+ 'B4': ['9941510002', '9961230020', '0000251438', '0007948345', '0000159590']
137
+ 'B5': ['7414398260', '8347251693', '1151043211', '2345678901', '5678901234', '9000293707', '0159004165', '0023456787', '0056789018', '3045000333']
138
+ 'B6': ['9111000000', '0269456780', '467310018', '477310018']
139
+ 'B7': ['0001057886', '0003815570', '0005620516', '0740912243', '0893524479']
140
+ 'B8': ['3145863029', '2938692523', '0132572975', '5432198760', '9070873333', '5011654366', '9000412340', '9310305011', '0132572975', '5432198760', '9070873333', '9000412340', '9310305011']
141
+ 'B9': ['88034023', '43025432', '86521362', '61256523', '54352684', '2356412', '5435886', '9435414']
142
+ 'C0': ['82335729', '29837521', '0132572975', '3038752371']
143
+ 'C1': ['0446786240', '0478046340', '0701625730', '0701625440', '0882095130', '5432112341', '5543223458', '5654334565', '5765445672', '5876556780']
144
+ 'C2': ['5127485166', '8738142564', '0328705282', '9024675131', '0328705282', '9024675131']
145
+ 'C3': ['17002', '123451', '122448', '9000734028', '9000733227', '9000731120']
146
+ 'C4': ['0000000017', '0000292933', '0000094459', '9000726558', '9001733457', '9000732000']
147
+ 'C5': ['0000302589', '0000507336', '0302555000', '0302589000', '00061457', '1000061498', '4864446015', '4865038012', '5000001028', '5000001075', '6450008150', '6542812818', '9000110012', '9000300310', '3081000783', '3081308871']
148
+ 'C6': ['0525111212', '0091423614', '1082311275', '1000118821', '2004306518', '2016001206', '3462816371', '3622548632', '4232300158', '4000456126', '5002684526', '5564123850', '6295473774', '6640806317', '7000062022', '7006003027', '8348300002', '8654216984', '9000641509', '9000260986']
149
+ 'C7': ['94012341', '5073321010', '1234517892', '987614325']
150
+ 'C8': ['3456789012', '0123456789', '1234567890', '9012345678', '0123456789', '1234567890', '9012345678', '1234567890', '9012345678']
151
+ 'C9': ['3456789012', '0123456789', '1234567890', '9012345678', '1234567890', '9012345678']
152
+ 'D0': ['6100272885', '6100273377', '6100274012']
153
+ 'D1': ['0000260986', '1062813622', '2256412314', '3012084101', '4006003027', '5814500990', '6128462594', '7000062035', '8003306026', '9000641509']
154
+ 'D2': ['4455667784', '1234567897', '51181008', '71214205', '6414241', '179751314', '51181008', '71214205', '6414241', '179751314', '6414241', '179751314']
155
+ 'D3': ['1600166307', '1600176485', '1600201934', '6025017009', '6028267003', '6019835001']
156
+ 'D4': ['0359432843', '1000062023', '2204271250', '3051681017', '4000123456', '5212744564', '6286420010', '7859103459', '8003306026', '9916524534']
157
+ 'D5': ['3299632008', '1999204293', '0399242139', '0004711172', '8623420004', '0001123458', '8623410000', '0001123458', '0000100084', '0000100085']
158
+ 'D6': ['33394', '595795', '16400501', '3615071237', '6039267013', '6039316014', '04017653', '9002720007', '9017483524']
159
+ 'D7': ['0501006102', '0231307867', '0301005331', '0330034104', '0420001302', '0135638809', '0202005939', '0601006977']
160
+ 'D8': ['3012084101', '1062813622', '0000260986']
161
+ 'D9': ['9876543210', '1234567890', '6543217890', '0543216789', '6543217890', '0543216789', '1100789043', '1100914032']
162
+ 'E0': ['1234769013', '2710014', '9741015011']
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe KtoBlzCheck::IBAN do
4
+ context 'definitions' do
5
+ context 'of instance methods' do
6
+ subject { KtoBlzCheck::IBAN.new }
7
+ after(:all) { subject.close }
8
+
9
+ it { should respond_to :check }
10
+ it { should respond_to :close }
11
+ end
12
+
13
+ context 'of constant' do
14
+ [
15
+ :VERSION,
16
+ :OK,
17
+ :TOO_SHORT,
18
+ :PREFIX_NOT_FOUND,
19
+ :WRONG_LENGTH,
20
+ :COUNTRY_NOT_FOUND,
21
+ :WRONG_COUNTRY,
22
+ :BAD_CHECKSUM
23
+ ].each do |c|
24
+ it c.to_s do
25
+ KtoBlzCheck::IBAN.const_get(c).should be
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,85 @@
1
+ require 'spec_helper'
2
+ require 'yaml'
3
+
4
+ def mid2blz(mid)
5
+ bank = KtoBlzCheck::KNOWN_BANKS.select{|b| b.mid == mid }.first
6
+ bank.blz unless bank.nil?
7
+ end
8
+
9
+ def fixtures
10
+ @fixtures ||= YAML.load_file('spec/fixtures.yml')
11
+ end
12
+
13
+ describe KtoBlzCheck do
14
+ context 'definitions' do
15
+ context 'of class methods' do
16
+ subject { KtoBlzCheck }
17
+
18
+ it { should respond_to :bankdata_dir }
19
+ it { should respond_to :encoding }
20
+ end
21
+
22
+ context 'of instance methods' do
23
+ subject { KtoBlzCheck.new }
24
+ after(:all) { subject.close }
25
+
26
+ it { should respond_to :check }
27
+ it { should respond_to :num_records }
28
+ it { should respond_to :close }
29
+ it { should respond_to :find }
30
+ end
31
+
32
+ context 'of constant' do
33
+ [
34
+ :VERSION,
35
+ :KNOWN_BANKS,
36
+ :OK,
37
+ :UNKNOWN,
38
+ :ERROR,
39
+ :BANK_NOT_KNOWN
40
+ ].each do |c|
41
+ it c.to_s do
42
+ KtoBlzCheck.const_get(c).should be
43
+ end
44
+ end
45
+ end
46
+ end
47
+
48
+ context 'general behavior' do
49
+ it 'has a valid bankdata directory' do
50
+ dir = KtoBlzCheck.bankdata_dir
51
+ Pathname(dir).should be_exist # language, anyone? :-)
52
+ end
53
+
54
+ it 'has all banks parsed' do
55
+ KtoBlzCheck::KNOWN_BANKS.size.should == KtoBlzCheck.new.num_records
56
+ end
57
+ end
58
+
59
+ # some additional tests
60
+ if ENV['CHECK_SAMPLE_DATA'] == 'true'
61
+ context 'fixture validation' do
62
+ subject { KtoBlzCheck.new }
63
+ after(:each) { subject.close }
64
+
65
+ fixtures.each do |e, data|
66
+ expectation = case e
67
+ when 'ok' then KtoBlzCheck::OK
68
+ when 'error' then KtoBlzCheck::ERROR
69
+ end
70
+
71
+ data.each do |mid, account_numbers|
72
+ blz = mid2blz(mid)
73
+ next if blz.nil?
74
+ account_numbers.each do |acc|
75
+ it "blz #{blz}, acc. #{acc}" do
76
+ subject.check(blz, acc).should == expectation
77
+ end
78
+ end
79
+ end
80
+
81
+ end # each fixture set
82
+ end # context
83
+ end # if
84
+
85
+ end
@@ -0,0 +1,3 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../ext', __FILE__)
2
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3
+ require 'ktoblzcheck'
metadata ADDED
@@ -0,0 +1,112 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ktoblzcheck
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.44.0.beta
5
+ platform: ruby
6
+ authors:
7
+ - Sascha Loetz
8
+ - Kim Rudolph
9
+ - Dominik Menke
10
+ autorequire:
11
+ bindir: bin
12
+ cert_chain: []
13
+ date: 2014-02-11 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: bundler
17
+ requirement: !ruby/object:Gem::Requirement
18
+ requirements:
19
+ - - "~>"
20
+ - !ruby/object:Gem::Version
21
+ version: '1.3'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - "~>"
27
+ - !ruby/object:Gem::Version
28
+ version: '1.3'
29
+ - !ruby/object:Gem::Dependency
30
+ name: rake
31
+ requirement: !ruby/object:Gem::Requirement
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ type: :development
37
+ prerelease: false
38
+ version_requirements: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: '0'
43
+ - !ruby/object:Gem::Dependency
44
+ name: rspec
45
+ requirement: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ">="
48
+ - !ruby/object:Gem::Version
49
+ version: '0'
50
+ type: :development
51
+ prerelease: false
52
+ version_requirements: !ruby/object:Gem::Requirement
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ description: ktoblzcheck is an interface for libktoblzcheck, a library to check German
58
+ account numbers and bank codes. See http://ktoblzcheck.sourceforge.net for details.
59
+ email:
60
+ - kim.rudolph@web.de
61
+ - dom@digineo.de
62
+ executables: []
63
+ extensions:
64
+ - ext/ktoblzcheck/extconf.rb
65
+ extra_rdoc_files: []
66
+ files:
67
+ - ".gitignore"
68
+ - ".rspec"
69
+ - ".travis.yml"
70
+ - Gemfile
71
+ - LICENSE.txt
72
+ - README.md
73
+ - Rakefile
74
+ - ext/ktoblzcheck/extconf.rb
75
+ - ext/ktoblzcheck/ktoblzcheck.c
76
+ - ktoblzcheck.gemspec
77
+ - lib/ktoblzcheck.rb
78
+ - spec/fixtures.yml
79
+ - spec/iban_spec.rb
80
+ - spec/ktoblzcheck_spec.rb
81
+ - spec/spec_helper.rb
82
+ homepage: http://github.com/dmke/ktoblzcheck
83
+ licenses:
84
+ - GPL
85
+ metadata: {}
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - ext
90
+ - lib
91
+ required_ruby_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ">="
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">"
99
+ - !ruby/object:Gem::Version
100
+ version: 1.3.1
101
+ requirements: []
102
+ rubyforge_project:
103
+ rubygems_version: 2.2.0
104
+ signing_key:
105
+ specification_version: 4
106
+ summary: ktoblzcheck is an interface for libktoblzcheck, a library to check German
107
+ account numbers and bank codes. See http://ktoblzcheck.sourceforge.net for details.
108
+ test_files:
109
+ - spec/fixtures.yml
110
+ - spec/iban_spec.rb
111
+ - spec/ktoblzcheck_spec.rb
112
+ - spec/spec_helper.rb