everypolitician 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +6 -0
- data/lib/everypolitician.rb +16 -7
- data/lib/everypolitician/version.rb +1 -1
- 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: 154efdf06fb1ee844cdf89ec68f773f35edea46c
|
4
|
+
data.tar.gz: 0de8b2dc4fb88a2615870c48306536b587e029d6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2a6ae15925a9ce0a611e23557efb69f59b082d2d06faf3b2288dd832e37073079408d8111ced29a487bd7dab3d1553d9df9e6e68adff3c3f5579a5f6f3b8b04b
|
7
|
+
data.tar.gz: 18e7bd9edc5cb33c755609cff3c1836d316a84dcbdca5cb60f630feb4c45f84b8887f180ce77d8b1d8eeae593ab4d07ff0ee87c2ac746687511c71c744b1b858
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,13 @@
|
|
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.3.0] - 2015-12-22
|
7
|
+
|
8
|
+
### Added
|
9
|
+
|
10
|
+
- You can now use `EveryPolitician` as the constant name as well as `Everypolitician`
|
11
|
+
- You can change the `countries.json` the library uses via `Everypolitician.countries_json=`
|
12
|
+
|
6
13
|
## [0.2.0] - 2015-12-22
|
7
14
|
|
8
15
|
### Changed
|
@@ -14,3 +21,4 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
14
21
|
- Initial release
|
15
22
|
|
16
23
|
[0.2.0]: https://github.com/everypolitician/everypolitician-ruby/compare/v0.1.0...v0.2.0
|
24
|
+
[0.3.0]: https://github.com/everypolitician/everypolitician-ruby/compare/v0.2.0...v0.3.0
|
data/README.md
CHANGED
@@ -29,6 +29,12 @@ senate = australia.legislature('Senate')
|
|
29
29
|
senate.popolo # data/Australia/Senate/ep-popolo-v1.0.json
|
30
30
|
```
|
31
31
|
|
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:
|
33
|
+
|
34
|
+
```ruby
|
35
|
+
Everypolitician.countries_json = 'path/to/local/countries.json'
|
36
|
+
```
|
37
|
+
|
32
38
|
## Development
|
33
39
|
|
34
40
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/everypolitician.rb
CHANGED
@@ -5,6 +5,15 @@ require 'open-uri'
|
|
5
5
|
module Everypolitician
|
6
6
|
class Error < StandardError; end
|
7
7
|
|
8
|
+
class << self
|
9
|
+
attr_writer :countries_json
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.countries_json
|
13
|
+
@countries_json ||= 'https://raw.githubusercontent.com/' \
|
14
|
+
'everypolitician/everypolitician-data/master/countries.json'
|
15
|
+
end
|
16
|
+
|
8
17
|
def self.country(slug)
|
9
18
|
Country.find(slug)
|
10
19
|
end
|
@@ -53,20 +62,20 @@ module Everypolitician
|
|
53
62
|
include Enumerable
|
54
63
|
|
55
64
|
def countries
|
56
|
-
@countries ||= JSON.parse(
|
65
|
+
@countries ||= JSON.parse(raw_json_string, symbolize_names: true)
|
57
66
|
end
|
58
67
|
|
59
68
|
def each(&block)
|
60
69
|
countries.each(&block)
|
61
70
|
end
|
62
71
|
|
63
|
-
|
64
|
-
@countries_json ||= open(countries_json_url).read
|
65
|
-
end
|
72
|
+
private
|
66
73
|
|
67
|
-
def
|
68
|
-
@
|
69
|
-
'everypolitician/everypolitician-data/master/countries.json'
|
74
|
+
def raw_json_string
|
75
|
+
@json ||= open(Everypolitician.countries_json).read
|
70
76
|
end
|
71
77
|
end
|
72
78
|
end
|
79
|
+
|
80
|
+
# Alternative constant name which is how it's usually capitalized in public copy.
|
81
|
+
EveryPolitician = Everypolitician
|