beid_parser 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/beid_parser/beid.rb +11 -5
- data/lib/beid_parser/version.rb +1 -1
- metadata +2 -2
data/lib/beid_parser/beid.rb
CHANGED
@@ -5,8 +5,11 @@ class BeidParser::Beid
|
|
5
5
|
:card_number,:chip_number,:validity_date_begin,:validity_date_end,
|
6
6
|
:delivery_municipality,:street_and_number,:zip,:municipality,
|
7
7
|
:certificates
|
8
|
-
|
9
|
-
|
8
|
+
|
9
|
+
#File can either be a filepath or an actual file
|
10
|
+
def initialize(file)
|
11
|
+
file = File.new(file) if file.is_a? String
|
12
|
+
@document = Document.new(file)
|
10
13
|
parse_document
|
11
14
|
end
|
12
15
|
|
@@ -21,12 +24,15 @@ class BeidParser::Beid
|
|
21
24
|
end
|
22
25
|
|
23
26
|
# Extract the citizen picture into a JPG file
|
24
|
-
def extract_picture(filename="
|
25
|
-
if !filename.match(/.*\.jpg
|
27
|
+
def extract_picture(filename="beid_#{national_number}.jpg")
|
28
|
+
if !filename.match(/.*\.jpg$/)
|
26
29
|
raise "The ouput file for the picture must have the '.jpg' extension."
|
27
30
|
end
|
28
31
|
|
29
|
-
File.open(filename, 'w')
|
32
|
+
File.open(filename, 'w') do |f|
|
33
|
+
f.binmode
|
34
|
+
f.write(picture)
|
35
|
+
end
|
30
36
|
end
|
31
37
|
|
32
38
|
private
|
data/lib/beid_parser/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: beid_parser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0
|
5
|
+
version: 0.1.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Thibault Poncelet
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-04-
|
13
|
+
date: 2012-04-22 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rspec
|