hdo-storting-importer 0.3.2 → 0.3.3

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml CHANGED
@@ -11,4 +11,4 @@ notifications:
11
11
  on_failure: change
12
12
  template:
13
13
  - "%{author} | %{commit} | %{message} | %{build_url}"
14
- script: "bundle exec rake"
14
+ script: "SPEC_OPTS=--backtrace bundle exec rake"
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2012 Holder De Ord
1
+ Copyright (c) 2012-2013 Holder De Ord
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -1,3 +1,8 @@
1
+ [![Build Status](https://secure.travis-ci.org/holderdeord/hdo-storting-importer.png?branch=master)](http://travis-ci.org/holderdeord/hdo-storting-importer)
2
+ [![Code Climate](https://codeclimate.com/github/holderdeord/hdo-storting-importer.png)](https://codeclimate.com/github/holderdeord/hdo-storting-importer)
3
+ [![Dependency Status](https://gemnasium.com/holderdeord/hdo-storting-importer.png)](https://gemnasium.com/holderdeord/hdo-storting-importer)
4
+ [![Coverage Status](https://coveralls.io/repos/holderdeord/hdo-storting-importer/badge.png?branch=master)](https://coveralls.io/r/holderdeord/hdo-storting-importer)
5
+
1
6
  What
2
7
  ====
3
8
 
@@ -32,4 +32,5 @@ Gem::Specification.new do |gem|
32
32
  gem.add_development_dependency 'guard-rspec'
33
33
  gem.add_development_dependency 'rspec'
34
34
  gem.add_development_dependency 'simplecov'
35
+ gem.add_development_dependency 'coveralls'
35
36
  end
@@ -1,6 +1,10 @@
1
1
  module Hdo
2
2
  module StortingImporter
3
3
  class ParsingDataSource < DataSource
4
+ def self.default
5
+ new ApiDataSource.default
6
+ end
7
+
4
8
  def initialize(delegate_data_source)
5
9
  @data_source = delegate_data_source
6
10
  end
@@ -10,7 +10,7 @@ module Hdo
10
10
  attr_reader :external_id, :first_name, :last_name, :date_of_birth, :date_of_death,
11
11
  :district, :parties, :committees, :period, :gender
12
12
 
13
- attr_accessor :vote_result
13
+ attr_accessor :vote_result, :permanent_substitute_for
14
14
 
15
15
  schema_path StortingImporter.lib.join("hdo/storting_importer/schema/representative.json").to_s
16
16
 
@@ -64,7 +64,7 @@ module Hdo
64
64
  CommitteeMembership.new(id, start_date, end_date)
65
65
  end
66
66
 
67
- new(
67
+ rep = new(
68
68
  node.css("id").first.text,
69
69
  node.css("fornavn").first.text,
70
70
  node.css("etternavn").first.text,
@@ -75,6 +75,13 @@ module Hdo
75
75
  parties,
76
76
  committees
77
77
  )
78
+
79
+ sub = node.css('fast_vara_for').first
80
+ if sub && sub['nil'] != 'true'
81
+ rep.permanent_substitute_for = sub.css("id").first.text
82
+ end
83
+
84
+ rep
78
85
  end
79
86
 
80
87
  def self.from_hash(hash)
@@ -89,6 +96,7 @@ module Hdo
89
96
  Array(hash['committees']).map { |e| CommitteeMembership.from_hash(e) }
90
97
 
91
98
  v.vote_result = hash['voteResult']
99
+ v.permanent_substitute_for = hash['permanentSubstituteFor']
92
100
 
93
101
  v
94
102
  end
@@ -105,6 +113,7 @@ module Hdo
105
113
  @committees = committees
106
114
 
107
115
  @vote_result = nil
116
+ @permanent_substitute_for = nil
108
117
  end
109
118
 
110
119
  def short_inspect
@@ -130,6 +139,7 @@ module Hdo
130
139
  }
131
140
 
132
141
  h['voteResult'] = @vote_result if @vote_result
142
+ h['permanentSubstituteFor'] = @permanent_substitute_for if @permanent_substitute_for
133
143
 
134
144
  h
135
145
  end
@@ -54,6 +54,10 @@
54
54
  "type": "string",
55
55
  "description": "If this representative object is part of a hdo#vote, this property describes how the representative voted. Valid values are for|against|absent.",
56
56
  "pattern": "for|against|absent"
57
+ },
58
+ "permanentSubstituteFor": {
59
+ "type": "string",
60
+ "description": "A representative the current representative is a permanent substitute for."
57
61
  }
58
62
  }
59
63
  }
@@ -1,5 +1,5 @@
1
1
  module Hdo
2
2
  module StortingImporter
3
- VERSION = "0.3.2"
3
+ VERSION = "0.3.3"
4
4
  end
5
5
  end
@@ -8,7 +8,7 @@ module Hdo
8
8
  include Inspectable
9
9
 
10
10
  attr_reader :external_id, :external_issue_id, :personal, :enacted, :subject,
11
- :method, :result_type, :time, :counts
11
+ :method_name, :result_type, :time, :counts
12
12
  attr_accessor :propositions, :representatives
13
13
 
14
14
  alias_method :personal?, :personal
@@ -87,13 +87,13 @@ module Hdo
87
87
  vote
88
88
  end
89
89
 
90
- def initialize(external_id, external_issue_id, personal, enacted, subject, method, result_type, time, for_count, against_count, absent_count)
90
+ def initialize(external_id, external_issue_id, personal, enacted, subject, method_name, result_type, time, for_count, against_count, absent_count)
91
91
  @external_id = external_id
92
92
  @external_issue_id = external_issue_id
93
93
  @personal = personal
94
94
  @enacted = enacted
95
95
  @subject = subject
96
- @method = method
96
+ @method_name = method_name
97
97
  @result_type = result_type
98
98
  @time = time
99
99
  @counts = Counts.new(Integer(for_count || 0), Integer(against_count || 0), Integer(absent_count || 0))
@@ -141,7 +141,7 @@ module Hdo
141
141
  'personal' => @personal,
142
142
  'enacted' => @enacted,
143
143
  'subject' => @subject,
144
- 'method' => @method,
144
+ 'method' => @method_name,
145
145
  'resultType' => @result_type,
146
146
  'time' => @time,
147
147
  'representatives' => @representatives.map(&:to_hash),
@@ -106,6 +106,16 @@ module Hdo
106
106
  obj.first_name.should == 'foo'
107
107
  end
108
108
 
109
+ it 'serializes the "permanent substitute for" field' do
110
+ obj = Representative.example
111
+ obj.permanent_substitute_for = "JB"
112
+
113
+ data = obj.to_hash
114
+ data['permanentSubstituteFor'].should == "JB"
115
+
116
+ Representative.from_hash(data).permanent_substitute_for.should == "JB"
117
+ end
118
+
109
119
  end
110
120
  end
111
121
  end
@@ -67,7 +67,7 @@ module Hdo
67
67
  vote.should be_personal
68
68
  vote.enacted.should be_false
69
69
  vote.subject.should == 'Forslag 24 - 26 på vegne av Per Olaf Lundteigen'
70
- vote.method.should == 'ikke_spesifisert'
70
+ vote.method_name.should == 'ikke_spesifisert'
71
71
  vote.result_type.should == 'ikke_spesifisert'
72
72
  vote.time.should == '2012-04-12T16:37:27.053'
73
73
  vote.counts.for.should == 2
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,6 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+
1
4
  require 'rspec'
2
5
  require 'pry'
3
6
  require 'pp'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hdo-storting-importer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-24 00:00:00.000000000 Z
12
+ date: 2013-03-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: builder
@@ -267,6 +267,22 @@ dependencies:
267
267
  - - ! '>='
268
268
  - !ruby/object:Gem::Version
269
269
  version: '0'
270
+ - !ruby/object:Gem::Dependency
271
+ name: coveralls
272
+ requirement: !ruby/object:Gem::Requirement
273
+ none: false
274
+ requirements:
275
+ - - ! '>='
276
+ - !ruby/object:Gem::Version
277
+ version: '0'
278
+ type: :development
279
+ prerelease: false
280
+ version_requirements: !ruby/object:Gem::Requirement
281
+ none: false
282
+ requirements:
283
+ - - ! '>='
284
+ - !ruby/object:Gem::Version
285
+ version: '0'
270
286
  description: Gem to process data from data.stortinget.no
271
287
  email:
272
288
  - jari.bakken@gmail.com
@@ -359,21 +375,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
359
375
  - - ! '>='
360
376
  - !ruby/object:Gem::Version
361
377
  version: '0'
362
- segments:
363
- - 0
364
- hash: 1318751592972283247
365
378
  required_rubygems_version: !ruby/object:Gem::Requirement
366
379
  none: false
367
380
  requirements:
368
381
  - - ! '>='
369
382
  - !ruby/object:Gem::Version
370
383
  version: '0'
371
- segments:
372
- - 0
373
- hash: 1318751592972283247
374
384
  requirements: []
375
385
  rubyforge_project:
376
- rubygems_version: 1.8.24
386
+ rubygems_version: 1.8.23
377
387
  signing_key:
378
388
  specification_version: 3
379
389
  summary: Gem to process data from data.stortinget.no