justiz 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/justiz/contact.rb +22 -2
- data/lib/justiz/version.rb +1 -1
- data/spec/lib/contact_spec.rb +27 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2326034c190b77e1aae66c1ac49d2fb8bcfcdecb
|
4
|
+
data.tar.gz: d32e3e91a788c9a4c0624ad4c2a93d4c98cf328e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb158bfc0410052e731b441fa01a3bb28fc8f3c640b645f47f0e4b103a8fc7ea389ca4d9da3e1e2a837429b26ec4b164861955417df0f50756220f24190c8fd7
|
7
|
+
data.tar.gz: 67782ac4abc05f9c4e6a85fe7b42a241dbf6ea7ff9d1990cc62a8e968aa3a3db08d1c25add8dce752fd45ebc7912e31bc20a0c22256b8e7a8d1d86d5f0cdcf9a
|
data/lib/justiz/contact.rb
CHANGED
@@ -1,8 +1,20 @@
|
|
1
1
|
require 'ostruct'
|
2
|
+
require 'digest'
|
2
3
|
|
3
4
|
module Justiz
|
4
|
-
class Contact
|
5
|
-
|
5
|
+
class Contact
|
6
|
+
FIELDS = [:court, :location, :post, :phone, :fax, :justiz_id, :url, :email]
|
7
|
+
attr_accessor :attributes, *FIELDS
|
8
|
+
|
9
|
+
def initialize(attributes = {})
|
10
|
+
self.attributes = attributes
|
11
|
+
end
|
12
|
+
|
13
|
+
def attributes=(attributes)
|
14
|
+
attributes.each do |key, value|
|
15
|
+
send("#{key}=", value) if respond_to?("#{key}=")
|
16
|
+
end
|
17
|
+
end
|
6
18
|
|
7
19
|
def id
|
8
20
|
# too many duplicates
|
@@ -18,5 +30,13 @@ module Justiz
|
|
18
30
|
def post_address
|
19
31
|
Address.new(self[:post])
|
20
32
|
end
|
33
|
+
|
34
|
+
def digest
|
35
|
+
sha256 = Digest::SHA2.new
|
36
|
+
FIELDS.each do |field|
|
37
|
+
sha256 << send(field)
|
38
|
+
end
|
39
|
+
Digest.hexencode(sha256.digest)
|
40
|
+
end
|
21
41
|
end
|
22
42
|
end
|
data/lib/justiz/version.rb
CHANGED
data/spec/lib/contact_spec.rb
CHANGED
@@ -2,4 +2,31 @@ require 'rspec'
|
|
2
2
|
require 'justiz'
|
3
3
|
|
4
4
|
describe Justiz::Contact do
|
5
|
+
let(:court) { {court: 'Staatsanwaltschaft Düsseldorf',
|
6
|
+
location: 'Fritz-Roeber-Straße 2, 40213 Düsseldorf',
|
7
|
+
post: 'P.O.Box 123, 40999 Düsseldorf - Post',
|
8
|
+
phone: '0211 6025 0',
|
9
|
+
fax: '0211 6025 2929',
|
10
|
+
justiz_id: 'R1100S',
|
11
|
+
url: 'http://www.sta-duesseldorf.nrw.de',
|
12
|
+
email: 'poststelle@sta-duesseldorf.nrw.de'} }
|
13
|
+
|
14
|
+
let(:contact) { Justiz::Contact.new(court) }
|
15
|
+
|
16
|
+
it "should assign elements" do
|
17
|
+
%w(court location post phone fax justiz_id url email).each do |field|
|
18
|
+
field = field.to_sym
|
19
|
+
expect(contact.send(field)).to eq(court[field])
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
it "should have an id" do
|
24
|
+
id = "#{court[:court]}#{court[:email]}"
|
25
|
+
expect(contact.id).to eq(id)
|
26
|
+
end
|
27
|
+
|
28
|
+
it "should have a digest" do
|
29
|
+
digest = "76ef09d0c7d0078015df7a948cf0352c00f6451dab354389b21895a50d89a4a8"
|
30
|
+
expect(contact.digest).to eq(digest)
|
31
|
+
end
|
5
32
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: justiz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mike Park
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-06-
|
11
|
+
date: 2013-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mechanize
|