hdo-storting-importer 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 650a82f767d7b1fa523e46f5fd4a149a079eb918
|
4
|
+
data.tar.gz: cf7ce7ee81fd72572d58ed36a91245399ec87e0c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7f993ba126ab83e66ab95f624b7ad26414d0508399bb9f37011a8a256a4caacfc83fd535c9fe18f2654d2ab111b1e2a9eef0b5ecf45aaed6cbbbce2b0112dba0
|
7
|
+
data.tar.gz: c116a14b075d5fd6d67074c8f4eae2351d766db58d3ede8b9af270e5774ae45f15b2200fe1394d68f3deeb7041619577a13c83cc8151e63cb79771aa66dde7c1
|
@@ -8,7 +8,7 @@ module Hdo
|
|
8
8
|
include HasJsonSchema
|
9
9
|
include IvarEquality
|
10
10
|
|
11
|
-
attr_reader :external_id, :
|
11
|
+
attr_reader :external_id, :promisor, :body, :general, :categories, :source, :page, :period
|
12
12
|
alias_method :general?, :general
|
13
13
|
alias_method :short_inspect, :inspect
|
14
14
|
|
@@ -17,7 +17,7 @@ module Hdo
|
|
17
17
|
def self.example(overrides = nil)
|
18
18
|
obj = new(
|
19
19
|
"1",
|
20
|
-
|
20
|
+
"H",
|
21
21
|
"Stille strengere krav til orden og oppførsel for å hindre at uro ødelegger undervisningen.",
|
22
22
|
true,
|
23
23
|
["GRUNNSKOLE"],
|
@@ -58,7 +58,7 @@ module Hdo
|
|
58
58
|
|
59
59
|
external_id = data.fetch(0).to_i.to_s
|
60
60
|
period = data.fetch(1)
|
61
|
-
|
61
|
+
promisor = data.fetch(2)
|
62
62
|
body = data.fetch(3)
|
63
63
|
general = data.fetch(4).to_s.strip.downcase
|
64
64
|
categories = data.fetch(5)
|
@@ -73,10 +73,12 @@ module Hdo
|
|
73
73
|
errors << "row #{external_id}: unexpected value #{page.inspect} for page"
|
74
74
|
end
|
75
75
|
|
76
|
-
if
|
77
|
-
errors << "row #{external_id}:
|
76
|
+
if promisor.nil? || promisor.empty?
|
77
|
+
errors << "row #{external_id}: promisor missing"
|
78
|
+
elsif promise.include?(",")
|
79
|
+
errors << "row #{external_id}: comma not allowed in promisor id/name"
|
78
80
|
end
|
79
|
-
|
81
|
+
|
80
82
|
if categories.nil? || categories.empty?
|
81
83
|
errors << "row #{external_id}: categories missing"
|
82
84
|
end
|
@@ -99,7 +101,7 @@ module Hdo
|
|
99
101
|
end
|
100
102
|
|
101
103
|
promise = new external_id,
|
102
|
-
|
104
|
+
promisor.strip,
|
103
105
|
clean_invalid_unicode.call(body.strip),
|
104
106
|
general.downcase == "ja",
|
105
107
|
clean_invalid_unicode.call(categories),
|
@@ -126,7 +128,7 @@ module Hdo
|
|
126
128
|
|
127
129
|
def self.from_hash(hash)
|
128
130
|
pr = new hash['external_id'],
|
129
|
-
hash['
|
131
|
+
hash['promisor'],
|
130
132
|
hash['body'],
|
131
133
|
hash['general'],
|
132
134
|
hash['categories'],
|
@@ -137,9 +139,9 @@ module Hdo
|
|
137
139
|
pr
|
138
140
|
end
|
139
141
|
|
140
|
-
def initialize(external_id,
|
142
|
+
def initialize(external_id, promisor, body, general, categories, source, page, period)
|
141
143
|
@external_id = external_id
|
142
|
-
@
|
144
|
+
@promisor = promisor
|
143
145
|
@body = strip_if_string(body)
|
144
146
|
@general = general
|
145
147
|
@categories = clean_array(categories).map { |e| UnicodeUtils.upcase(e) }
|
@@ -152,7 +154,7 @@ module Hdo
|
|
152
154
|
{
|
153
155
|
'kind' => self.class.kind,
|
154
156
|
'external_id' => @external_id,
|
155
|
-
'
|
157
|
+
'promisor' => @promisor,
|
156
158
|
'general' => @general,
|
157
159
|
'categories' => @categories,
|
158
160
|
'source' => @source,
|
@@ -14,13 +14,10 @@
|
|
14
14
|
"description": "A unique identifier for this promise.",
|
15
15
|
"required": true
|
16
16
|
},
|
17
|
-
"
|
18
|
-
"type": "
|
19
|
-
"description": "
|
20
|
-
"required": true
|
21
|
-
"items": {
|
22
|
-
"type": "string"
|
23
|
-
}
|
17
|
+
"promisor": {
|
18
|
+
"type": "string",
|
19
|
+
"description": "A party id (i.e. 'A', 'SV', 'Sp') or government name (i.e. 'Stoltenberg II')",
|
20
|
+
"required": true
|
24
21
|
},
|
25
22
|
"general": {
|
26
23
|
"type": "boolean",
|