everypolitician 0.3.0 → 0.4.0

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: 154efdf06fb1ee844cdf89ec68f773f35edea46c
4
- data.tar.gz: 0de8b2dc4fb88a2615870c48306536b587e029d6
3
+ metadata.gz: 5fb2e4b9951d0fcb07375a0eeb7e62654d69218a
4
+ data.tar.gz: 97535464a6f92d4ddaa1d94144aa48a44005a6bc
5
5
  SHA512:
6
- metadata.gz: 2a6ae15925a9ce0a611e23557efb69f59b082d2d06faf3b2288dd832e37073079408d8111ced29a487bd7dab3d1553d9df9e6e68adff3c3f5579a5f6f3b8b04b
7
- data.tar.gz: 18e7bd9edc5cb33c755609cff3c1836d316a84dcbdca5cb60f630feb4c45f84b8887f180ce77d8b1d8eeae593ab4d07ff0ee87c2ac746687511c71c744b1b858
6
+ metadata.gz: 3d812c5eedb13bdfe7f0d2cc68be4d1da742f724aa6c694b1ac82eb70b366cf50eef7f13bc2f850a6609bc66c49697157d0f50018d284600a30e28238506505e
7
+ data.tar.gz: b2cb5cb815eb29f841ed391cd2ce889aa9d259c47867bb748f1b8490c1564a36b8986ea1cc5b940642397c9c2cb3486e33c5fb1d81b33622885de429d91e8006
data/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  This project adheres to [Semantic Versioning](http://semver.org/).
5
5
 
6
+ ## [0.4.0] - 2016-01-26
7
+
8
+ ### Changed
9
+
10
+ - `Everypolitician::Legislature#popolo` now returns an instance of `Everypolitician::Popolo::JSON` from [everypolitician-popolo](https://github.com/everypolitician/everypolitician-popolo) instead of a string representing the path.
11
+
12
+ ### Added
13
+
14
+ - `Everypolitician::Legislature#popolo_url` now returns a GitHub raw url to the popolo for the legislature.
15
+
6
16
  ## [0.3.0] - 2015-12-22
7
17
 
8
18
  ### Added
@@ -22,3 +32,4 @@ This project adheres to [Semantic Versioning](http://semver.org/).
22
32
 
23
33
  [0.2.0]: https://github.com/everypolitician/everypolitician-ruby/compare/v0.1.0...v0.2.0
24
34
  [0.3.0]: https://github.com/everypolitician/everypolitician-ruby/compare/v0.2.0...v0.3.0
35
+ [0.4.0]: https://github.com/everypolitician/everypolitician-ruby/compare/v0.3.0...v0.4.0
data/README.md CHANGED
@@ -24,9 +24,9 @@ Or install it yourself as:
24
24
  require 'everypolitician'
25
25
 
26
26
  australia = Everypolitician.country('Australia')
27
- australia.code # AU
27
+ australia.code # => "AU"
28
28
  senate = australia.legislature('Senate')
29
- senate.popolo # data/Australia/Senate/ep-popolo-v1.0.json
29
+ senate.popolo # => #<Everypolitician::Popolo::JSON>
30
30
  ```
31
31
 
32
32
  If you want to point at a different `countries.json`, e.g. a local path or a different url, you can set it like this:
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ['lib']
20
20
 
21
+ spec.add_dependency 'everypolitician-popolo'
22
+
21
23
  spec.add_development_dependency 'bundler', '~> 1.10'
22
24
  spec.add_development_dependency 'rake', '~> 10.0'
23
25
  spec.add_development_dependency 'minitest'
@@ -1,6 +1,7 @@
1
1
  require 'everypolitician/version'
2
2
  require 'json'
3
3
  require 'open-uri'
4
+ require 'everypolitician/popolo'
4
5
 
5
6
  module Everypolitician
6
7
  class Error < StandardError; end
@@ -30,12 +31,17 @@ module Everypolitician
30
31
 
31
32
  class Entity
32
33
  def initialize(data)
33
- data.each do |key, value|
34
+ process_data(data).each do |key, value|
34
35
  define_singleton_method(key) do
35
36
  value
36
37
  end
37
38
  end
38
39
  end
40
+
41
+ # Override in subclasses to change structure of data
42
+ def process_data(data)
43
+ data
44
+ end
39
45
  end
40
46
 
41
47
  class Country < Entity
@@ -56,6 +62,16 @@ module Everypolitician
56
62
  def self.find(country_slug, legislature_slug)
57
63
  Country.find(country_slug).legislature(legislature_slug)
58
64
  end
65
+
66
+ def popolo
67
+ @popolo ||= Everypolitician::Popolo.parse(open(popolo_url).read)
68
+ end
69
+
70
+ def process_data(data)
71
+ data[:popolo_url] = 'https://raw.githubusercontent.com/everypolitician' \
72
+ "/everypolitician-data/master/#{data.delete(:popolo)}"
73
+ data
74
+ end
59
75
  end
60
76
 
61
77
  class CountriesJson
@@ -1,3 +1,3 @@
1
1
  module Everypolitician
2
- VERSION = '0.3.0'
2
+ VERSION = '0.4.0'
3
3
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: everypolitician
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Mytton
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-12-22 00:00:00.000000000 Z
11
+ date: 2016-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: everypolitician-popolo
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: bundler
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -133,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
147
  version: '0'
134
148
  requirements: []
135
149
  rubyforge_project:
136
- rubygems_version: 2.4.5.1
150
+ rubygems_version: 2.5.1
137
151
  signing_key:
138
152
  specification_version: 4
139
153
  summary: Interface with EveryPolitician data from your Ruby app