blz 0.1.4.20170306 → 0.2.0.20170605
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +1 -4
- data/blz.gemspec +1 -1
- data/data/2017_06_05.tsv.gz +0 -0
- data/lib/blz.rb +9 -10
- data/test/test_bank.rb +52 -17
- metadata +3 -4
- data/data/2015_03_09.tsv.gz +0 -0
- data/data/2015_12_06.tsv.gz +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 583b483d338385dc57d528a92908249de42bcb29
|
4
|
+
data.tar.gz: e3e9638f159ef7b87e083021ca86e40a0e5b3603
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75a886ea53fa801e1832b2564cfa0ecf1ba3a4308a40b19bac7c9c221b24c2b668a4d271976d4983b1e94292a5c4e92a3dbdeb32a52d41913d626e407d08959e
|
7
|
+
data.tar.gz: bc03dd1c2d3bd6dc73956c03d764730996e1f5b1fad95bb6ebbdb43be1985a740ca7d03e3767998b995e190041a87c0ab3325a5ee6ee42ca3a21140f19378970
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
# 0.2.0.20170605, released 2017-05-08
|
2
|
+
|
3
|
+
* BLZ data file for cycle 2017-06-04 to 2017-09-03 added
|
4
|
+
* BLZ data files for 2015 removed
|
5
|
+
* revamped tests, so that manual editing becomes unnecessary
|
6
|
+
|
1
7
|
# 0.1.4.20170306, released 2017-02-06
|
2
8
|
|
3
9
|
* BLZ data file for cycle 2017-03-06 to 2017-06-04 added
|
data/README.md
CHANGED
@@ -78,10 +78,7 @@ files. Currently, this is a 3-monthly manual process of:
|
|
78
78
|
3. Gzip'ing the `.tsv` file (i.e. `gzip -9 yyyy_mm_dd.tsv`, resulting
|
79
79
|
in `data/yyyy_mm_dd.tsv.gz`).
|
80
80
|
|
81
|
-
4.
|
82
|
-
reflect the latest file.
|
83
|
-
|
84
|
-
5. Run the tests (`rake`).
|
81
|
+
4. Run the tests (`rake`).
|
85
82
|
|
86
83
|
Obviously, this process tends to be error prone. A pull request with a
|
87
84
|
Rake task completing these steps would be nice to have.
|
data/blz.gemspec
CHANGED
Binary file
|
data/lib/blz.rb
CHANGED
@@ -10,23 +10,22 @@
|
|
10
10
|
require "date"
|
11
11
|
|
12
12
|
module BLZ
|
13
|
+
def self.convert_file_to_date(f)
|
14
|
+
match = f.match /(?<y>\d{4})_(?<m>\d\d)_(?<d>\d\d)\.tsv\.gz$/
|
15
|
+
Date.new match[:y].to_i, match[:m].to_i, match[:d].to_i
|
16
|
+
end
|
17
|
+
|
13
18
|
def self.find_data_file(now=Date.today)
|
14
19
|
glob = Dir[ File.join(File.dirname(__FILE__), '../data/*.tsv.gz') ].sort
|
15
|
-
|
16
|
-
file2time = proc do |f|
|
17
|
-
match = f.match /(?<y>\d{4})_(?<m>\d\d)_(?<d>\d\d)\.tsv\.gz$/
|
18
|
-
Date.new match[:y].to_i, match[:m].to_i, match[:d].to_i
|
19
|
-
end
|
20
|
-
|
21
|
-
filename = glob.find {|c| now <= file2time[c] } || glob.last
|
20
|
+
file = glob.find {|c| now <= convert_file_to_date(c) } || glob.last
|
22
21
|
|
23
22
|
# sanity check
|
24
|
-
|
25
|
-
|
23
|
+
if now < Date.new(2016, 3, 6) || now > (convert_file_to_date(file) + 90)
|
24
|
+
warn [now]
|
26
25
|
warn '[BLZ] The data provided may not be accurate.'
|
27
26
|
end
|
28
27
|
|
29
|
-
|
28
|
+
file
|
30
29
|
end
|
31
30
|
|
32
31
|
DATA_FILE = find_data_file
|
data/test/test_bank.rb
CHANGED
@@ -2,26 +2,36 @@
|
|
2
2
|
|
3
3
|
require 'blz'
|
4
4
|
require 'test/unit'
|
5
|
+
require 'stringio'
|
5
6
|
|
6
7
|
class TestBank < Test::Unit::TestCase
|
8
|
+
DATA_FILES = Dir[File.join(File.dirname(__FILE__), '../data/*.tsv.gz')].sort
|
9
|
+
|
10
|
+
DATA_FILES.each do |filename|
|
11
|
+
define_method "test_find_file_for_#{File.basename(filename)[0..-8]}" do
|
12
|
+
assert_stderr_no_match "The data provided may not be accurate" do
|
13
|
+
date = BLZ.convert_file_to_date(filename)
|
14
|
+
file = BLZ.find_data_file(date)
|
15
|
+
assert_equal b(filename), b(file)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
7
19
|
|
8
|
-
def
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
file = BLZ.find_data_file(date)
|
24
|
-
assert_equal filename, File.basename(file)
|
20
|
+
def test_find_file_for_past_date
|
21
|
+
assert_stderr_match "The data provided may not be accurate" do
|
22
|
+
file = DATA_FILES.first
|
23
|
+
date = BLZ.convert_file_to_date(file) - 1
|
24
|
+
found = BLZ.find_data_file(date)
|
25
|
+
assert_equal b(file), b(found)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_find_file_for_future_date
|
30
|
+
assert_stderr_match "The data provided may not be accurate" do
|
31
|
+
file = DATA_FILES.last
|
32
|
+
date = BLZ.convert_file_to_date(file) + 91
|
33
|
+
found = BLZ.find_data_file(date)
|
34
|
+
assert_equal b(file), b(found)
|
25
35
|
end
|
26
36
|
end
|
27
37
|
|
@@ -91,4 +101,29 @@ class TestBank < Test::Unit::TestCase
|
|
91
101
|
assert_equal "70150000, Stadtsparkasse München, 80791 München, SSKMDEMMXXX", results[0].to_s
|
92
102
|
end
|
93
103
|
|
104
|
+
# helper
|
105
|
+
|
106
|
+
def assert_stderr_match(msg, &block)
|
107
|
+
serr = redirect_stderr(&block)
|
108
|
+
assert_match msg, serr
|
109
|
+
end
|
110
|
+
|
111
|
+
def assert_stderr_no_match(msg, &block)
|
112
|
+
msg = Regexp.new(Regexp.escape(msg)) unless msg.is_a?(Regexp)
|
113
|
+
serr = redirect_stderr(&block)
|
114
|
+
assert_no_match msg, serr
|
115
|
+
end
|
116
|
+
|
117
|
+
def b(file)
|
118
|
+
File.basename file
|
119
|
+
end
|
120
|
+
|
121
|
+
def redirect_stderr
|
122
|
+
fake_stderr = StringIO.new
|
123
|
+
original_stderr, $stderr = $stderr, fake_stderr
|
124
|
+
yield
|
125
|
+
fake_stderr.string
|
126
|
+
ensure
|
127
|
+
$stderr = original_stderr
|
128
|
+
end
|
94
129
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0.20170605
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oliver Eilhard
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-05-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -78,11 +78,10 @@ files:
|
|
78
78
|
- Rakefile
|
79
79
|
- bin/blz
|
80
80
|
- blz.gemspec
|
81
|
-
- data/2015_03_09.tsv.gz
|
82
|
-
- data/2015_12_06.tsv.gz
|
83
81
|
- data/2016_03_06.tsv.gz
|
84
82
|
- data/2016_09_04.tsv.gz
|
85
83
|
- data/2017_03_06.tsv.gz
|
84
|
+
- data/2017_06_05.tsv.gz
|
86
85
|
- lib/blz.rb
|
87
86
|
- lib/blz/bank.rb
|
88
87
|
- test/test_bank.rb
|
data/data/2015_03_09.tsv.gz
DELETED
Binary file
|
data/data/2015_12_06.tsv.gz
DELETED
Binary file
|