beid_parser 0.0.2 → 0.1.0

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.
@@ -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
- def initialize(filename)
9
- @document = Document.new(File.new(filename))
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="picture.jpg")
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') { |f| f.write(picture) }
32
+ File.open(filename, 'w') do |f|
33
+ f.binmode
34
+ f.write(picture)
35
+ end
30
36
  end
31
37
 
32
38
  private
@@ -1,3 +1,3 @@
1
1
  module BeidParser
2
- VERSION = "0.0.2"
2
+ VERSION = "0.1.0"
3
3
  end
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.2
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-21 00:00:00 Z
13
+ date: 2012-04-22 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec