everypolitician 0.1.0 → 0.2.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 +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +1 -1
- data/lib/everypolitician/version.rb +1 -1
- data/lib/everypolitician.rb +22 -5
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 675689b7fab868a111b237a0ecffb06220838068
|
|
4
|
+
data.tar.gz: 6a43207310744cd794397a44efb181a7478bf4d6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 62d259df053500ba71a21768ac7c0098391d43e011049160a799d8065d9ad4f3257dc402bcacf42f1e80b126e1420e3d19250dad694a23f0e2ee7fee4137c555
|
|
7
|
+
data.tar.gz: 86040151ab70ab6fe2f3fbb9e8045fcc54697e3583b739f5e3ba476f4a061dd47aff6c9900b45b27d68f7009dd22c93d09a2cd15452d4b85425bef7d8db306b6
|
data/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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.2.0] - 2015-12-22
|
|
7
|
+
|
|
8
|
+
### Changed
|
|
9
|
+
|
|
10
|
+
- `countries.json` is now represented by a separate class allowing users to access the raw underlying data.
|
|
11
|
+
|
|
6
12
|
## 0.1.0 - 2015-12-22
|
|
7
13
|
|
|
8
14
|
- Initial release
|
|
15
|
+
|
|
16
|
+
[0.2.0]: https://github.com/everypolitician/everypolitician-ruby/compare/v0.1.0...v0.2.0
|
data/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Everypolitician
|
|
1
|
+
# Everypolitician [](https://travis-ci.org/everypolitician/everypolitician-ruby) [](https://badge.fury.io/rb/everypolitician)
|
|
2
2
|
|
|
3
3
|
Interface with EveryPolitician data from your Ruby application.
|
|
4
4
|
|
data/lib/everypolitician.rb
CHANGED
|
@@ -31,11 +31,7 @@ module Everypolitician
|
|
|
31
31
|
|
|
32
32
|
class Country < Entity
|
|
33
33
|
def self.find(slug)
|
|
34
|
-
|
|
35
|
-
'everypolitician/everypolitician-data/master/countries.json'
|
|
36
|
-
countries_json = open(countries_json_url).read
|
|
37
|
-
countries = JSON.parse(countries_json, symbolize_names: true)
|
|
38
|
-
country = countries.find { |c| c[:slug] == slug }
|
|
34
|
+
country = CountriesJson.new.find { |c| c[:slug] == slug }
|
|
39
35
|
fail Error, "Unknown country slug: #{slug}" if country.nil?
|
|
40
36
|
new(country)
|
|
41
37
|
end
|
|
@@ -52,4 +48,25 @@ module Everypolitician
|
|
|
52
48
|
Country.find(country_slug).legislature(legislature_slug)
|
|
53
49
|
end
|
|
54
50
|
end
|
|
51
|
+
|
|
52
|
+
class CountriesJson
|
|
53
|
+
include Enumerable
|
|
54
|
+
|
|
55
|
+
def countries
|
|
56
|
+
@countries ||= JSON.parse(countries_json, symbolize_names: true)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def each(&block)
|
|
60
|
+
countries.each(&block)
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def countries_json
|
|
64
|
+
@countries_json ||= open(countries_json_url).read
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def countries_json_url
|
|
68
|
+
@url ||= 'https://raw.githubusercontent.com/' \
|
|
69
|
+
'everypolitician/everypolitician-data/master/countries.json'
|
|
70
|
+
end
|
|
71
|
+
end
|
|
55
72
|
end
|