hdo-storting-importer 0.4.0 → 0.5.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: caec1b7f38dd610a7482f789ef4957f3d94e00c7
4
- data.tar.gz: f4e44a467ad3c43852b15f2a691c6d2f0300898a
3
+ metadata.gz: 26642ade6747a6d4a227ea61654c0443f16b04c7
4
+ data.tar.gz: a6ea9cb8e7948b2cb632a735c43adecfcfd07b0a
5
5
  SHA512:
6
- metadata.gz: c2d4698c08db85f21d58a8986e477f5478caaa1582ec2f057d4f6788950ab1181d00c6f5a78cdb54ab6be3e94361431541629ee133f04f8afd636e29f0a9ac6f
7
- data.tar.gz: c59796448cefa43002fc12efc881aaae4e8e6e889c41c003cb8e7a54a7e4374f68ce552bc4018b33f3500546c9e9e279027fff9d3f44d7a75606172e5f2fc6af
6
+ metadata.gz: bcc036048f7b3da58c364a41e34846cf3d76000242e163afb001e725040c4077774785fe268bc4c8eb755bd6414435ef8e47b5ad1db1dff7e28aa44c8f6911cc
7
+ data.tar.gz: 3e38dce611e3ffda4cfde125c968fbbbd21b459880ac5b556965e4318e8414b4e2163c744da31b1e4a1007f6823016d2969f424bb6eaf253e095ff41aec10061
@@ -104,7 +104,7 @@ Feature: Import data
104
104
  </fylker_liste>
105
105
  </fylker_oversikt>
106
106
  """
107
- When I run `hdo-converter districts fylker.xml`
107
+ When I successfully run `hdo-converter districts fylker.xml`
108
108
  Then the stdout should contain:
109
109
  """
110
110
  [
@@ -5,14 +5,12 @@ module Hdo
5
5
  include IvarEquality
6
6
 
7
7
  attr_reader :external_id, :name
8
- attr_accessor :governing_periods
9
8
  alias_method :short_inspect, :inspect
10
9
 
11
10
  schema_path StortingImporter.lib.join("hdo/storting_importer/schema/party.json").to_s
12
11
 
13
12
  def self.example(overrides = nil)
14
13
  obj = new("A", "Arbeiderpartiet")
15
- obj.governing_periods = [GoverningPeriod.new('2005-10-17', '2013-10-14')]
16
14
 
17
15
  if overrides
18
16
  obj = from_hash(obj.to_hash.merge(overrides))
@@ -22,31 +20,20 @@ module Hdo
22
20
  end
23
21
 
24
22
  def self.from_storting_doc(doc)
25
- parties = doc.css("partier_liste parti").map do |node|
23
+ doc.css("partier_liste parti").map do |node|
26
24
  new node.css("id").first.text,
27
25
  node.css("navn").first.text
28
26
  end
29
-
30
- GoverningPeriod.add_to parties
31
-
32
- parties
33
27
  end
34
28
 
35
29
  def self.from_hash(hash)
36
- obj = new hash['external_id'],
37
- hash['name']
38
-
39
- obj.governing_periods = Array(hash['governing_periods']).map do |gp|
40
- GoverningPeriod.from_hash gp
41
- end
42
-
43
- obj
30
+ new hash['external_id'],
31
+ hash['name']
44
32
  end
45
33
 
46
34
  def initialize(external_id, name)
47
35
  @external_id = external_id
48
36
  @name = name
49
- @governing_periods = nil
50
37
  end
51
38
 
52
39
  def external_id
@@ -54,17 +41,11 @@ module Hdo
54
41
  end
55
42
 
56
43
  def to_hash
57
- h = {
44
+ {
58
45
  'kind' => self.class.kind,
59
46
  'external_id' => @external_id,
60
47
  'name' => @name,
61
48
  }
62
-
63
- if @governing_periods
64
- h['governing_periods'] = @governing_periods.map { |e| e.to_hash }
65
- end
66
-
67
- h
68
49
  end
69
50
 
70
51
  end
@@ -18,26 +18,6 @@
18
18
  "description": "The name of the party",
19
19
  "type": "string",
20
20
  "required": true
21
- },
22
- "governing_periods": {
23
- "type": "array",
24
- "description": "Periods where this party was in the elected government.",
25
- "items": {
26
- "type": "object",
27
- "properties": {
28
- "start_date": {
29
- "type": "string",
30
- "format": "date",
31
- "description": "When the governing period started.",
32
- "required": true
33
- },
34
- "end_date": {
35
- "type": "string",
36
- "format": "date",
37
- "description": "When the governing period stopped."
38
- }
39
- }
40
- }
41
21
  }
42
22
  }
43
23
  }
@@ -1,5 +1,5 @@
1
1
  module Hdo
2
2
  module StortingImporter
3
- VERSION = "0.4.0"
3
+ VERSION = "0.5.0"
4
4
  end
5
5
  end
@@ -30,7 +30,6 @@ module Hdo
30
30
  Committee,
31
31
  CommitteeMembership,
32
32
  District,
33
- GoverningPeriod,
34
33
  ParliamentIssue,
35
34
  ParliamentSession,
36
35
  ParliamentPeriod,
@@ -138,6 +137,5 @@ require 'hdo/storting_importer/promise'
138
137
  require 'hdo/storting_importer/representative'
139
138
  require 'hdo/storting_importer/proposition'
140
139
  require 'hdo/storting_importer/vote'
141
- require 'hdo/storting_importer/governing_period'
142
140
 
143
141
  require 'hdo/storting_importer/cli'
@@ -6,7 +6,7 @@ module Hdo
6
6
  describe CachingDataSource do
7
7
 
8
8
  it 'caches requests' do
9
- delegate = mock(DataSource)
9
+ delegate = double(DataSource)
10
10
 
11
11
  ads = CachingDataSource.new(delegate)
12
12
 
@@ -40,14 +40,7 @@ module Hdo
40
40
  {
41
41
  "kind": "hdo#party",
42
42
  "external_id": "A",
43
- "name": "Arbeiderpartiet",
44
- "governing_periods": [
45
- {
46
- "kind": "hdo#governing_period",
47
- "start_date": "2005-10-17",
48
- "end_date": "2013-10-14"
49
- }
50
- ]
43
+ "name": "Arbeiderpartiet"
51
44
  }
52
45
  JSON
53
46
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hdo-storting-importer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jari Bakken
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-12 00:00:00.000000000 Z
11
+ date: 2013-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: builder
@@ -278,7 +278,6 @@ files:
278
278
  - lib/hdo/storting_importer/data_source.rb
279
279
  - lib/hdo/storting_importer/disk_data_source.rb
280
280
  - lib/hdo/storting_importer/district.rb
281
- - lib/hdo/storting_importer/governing_period.rb
282
281
  - lib/hdo/storting_importer/has_json_schema.rb
283
282
  - lib/hdo/storting_importer/in_memory_cache.rb
284
283
  - lib/hdo/storting_importer/inspectable.rb
@@ -297,7 +296,6 @@ files:
297
296
  - lib/hdo/storting_importer/schema/committee.json
298
297
  - lib/hdo/storting_importer/schema/committee_membership.json
299
298
  - lib/hdo/storting_importer/schema/district.json
300
- - lib/hdo/storting_importer/schema/governing_period.json
301
299
  - lib/hdo/storting_importer/schema/parliament_issue.json
302
300
  - lib/hdo/storting_importer/schema/parliament_period.json
303
301
  - lib/hdo/storting_importer/schema/parliament_session.json
@@ -315,7 +313,6 @@ files:
315
313
  - spec/hdo/storting_importer/committee_membership_spec.rb
316
314
  - spec/hdo/storting_importer/committee_spec.rb
317
315
  - spec/hdo/storting_importer/district_spec.rb
318
- - spec/hdo/storting_importer/governing_period_spec.rb
319
316
  - spec/hdo/storting_importer/parliament_issue_spec.rb
320
317
  - spec/hdo/storting_importer/parliament_period_spec.rb
321
318
  - spec/hdo/storting_importer/parliament_session_spec.rb
@@ -347,7 +344,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
347
344
  version: '0'
348
345
  requirements: []
349
346
  rubyforge_project:
350
- rubygems_version: 2.0.3
347
+ rubygems_version: 2.1.9
351
348
  signing_key:
352
349
  specification_version: 4
353
350
  summary: Gem to process data from data.stortinget.no
@@ -359,7 +356,6 @@ test_files:
359
356
  - spec/hdo/storting_importer/committee_membership_spec.rb
360
357
  - spec/hdo/storting_importer/committee_spec.rb
361
358
  - spec/hdo/storting_importer/district_spec.rb
362
- - spec/hdo/storting_importer/governing_period_spec.rb
363
359
  - spec/hdo/storting_importer/parliament_issue_spec.rb
364
360
  - spec/hdo/storting_importer/parliament_period_spec.rb
365
361
  - spec/hdo/storting_importer/parliament_session_spec.rb
@@ -372,3 +368,4 @@ test_files:
372
368
  - spec/spec_helper.rb
373
369
  - spec/support/shared_examples_for_json_schema.rb
374
370
  - spec/support/shared_examples_for_short_inspect.rb
371
+ has_rdoc:
@@ -1,54 +0,0 @@
1
- module Hdo
2
- module StortingImporter
3
- class GoverningPeriod
4
- include IvarEquality
5
- include HasJsonSchema
6
-
7
- attr_reader :start_date, :end_date
8
-
9
- schema_path StortingImporter.lib.join("hdo/storting_importer/schema/governing_period.json").to_s
10
-
11
- def self.add_to(parties)
12
- Array(parties).each do |party|
13
- party.governing_periods = all[party.external_id]
14
- end
15
- end
16
-
17
- #
18
- # Who and who isn't in government is not available in the data
19
- # from Stortinget, so we hardcode it here.
20
- #
21
-
22
- def self.all
23
- @periods ||= {
24
- "A" => [ GoverningPeriod.new('2005-10-17') ],
25
- "SV" => [ GoverningPeriod.new('2005-10-17') ],
26
- "Sp" => [ GoverningPeriod.new('2005-10-17') ]
27
- }
28
- end
29
-
30
- def self.example
31
- all['A'].first
32
- end
33
-
34
- def self.from_hash(hash)
35
- new hash['start_date'], hash['end_date']
36
- end
37
-
38
- def initialize(start_date, end_date = nil)
39
- @start_date = Date.strptime(start_date) if start_date
40
- @end_date = Date.strptime(end_date) if end_date
41
- end
42
-
43
- def to_hash
44
- {
45
- 'kind' => self.class.kind,
46
- 'start_date' => @start_date && @start_date.iso8601,
47
- 'end_date' => @end_date && @end_date.iso8601
48
- }
49
- end
50
-
51
- end
52
-
53
- end
54
- end
@@ -1,24 +0,0 @@
1
- {
2
- "id": "hdo#governing_period",
3
- "description": "a period where a party is in government",
4
- "type":"object",
5
- "properties": {
6
- "kind": {
7
- "type": "string",
8
- "description": "This is always 'hdo#governing_period'",
9
- "default": "hdo#governing_period",
10
- "required": true
11
- },
12
- "start_date": {
13
- "type": "string",
14
- "description": "The date the period started.",
15
- "format": "date",
16
- "required": true
17
- },
18
- "end_date": {
19
- "type": "string",
20
- "description": "The date the period ended. Can be null if the period is current.",
21
- "format": "date",
22
- "required": false
23
- }
24
- }
@@ -1,25 +0,0 @@
1
- # encoding: UTF-8
2
- require 'spec_helper'
3
-
4
- module Hdo
5
- module StortingImporter
6
- describe GoverningPeriod do
7
-
8
- it_behaves_like 'type with JSON schema'
9
-
10
- it 'can serialize as JSON' do
11
- expected = <<-JSON
12
- {
13
- "kind": "hdo#governing_period",
14
- "start_date": "2005-10-01",
15
- "end_date": "2013-09-30"
16
- }
17
- JSON
18
-
19
- session = GoverningPeriod.new('2005-10-01', '2013-09-30')
20
- session.to_json.should be_json(expected)
21
- end
22
-
23
- end
24
- end
25
- end