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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 675689b7fab868a111b237a0ecffb06220838068
4
- data.tar.gz: 6a43207310744cd794397a44efb181a7478bf4d6
3
+ metadata.gz: 154efdf06fb1ee844cdf89ec68f773f35edea46c
4
+ data.tar.gz: 0de8b2dc4fb88a2615870c48306536b587e029d6
5
5
  SHA512:
6
- metadata.gz: 62d259df053500ba71a21768ac7c0098391d43e011049160a799d8065d9ad4f3257dc402bcacf42f1e80b126e1420e3d19250dad694a23f0e2ee7fee4137c555
7
- data.tar.gz: 86040151ab70ab6fe2f3fbb9e8045fcc54697e3583b739f5e3ba476f4a061dd47aff6c9900b45b27d68f7009dd22c93d09a2cd15452d4b85425bef7d8db306b6
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.
@@ -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(countries_json, symbolize_names: true)
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
- def countries_json
64
- @countries_json ||= open(countries_json_url).read
65
- end
72
+ private
66
73
 
67
- def countries_json_url
68
- @url ||= 'https://raw.githubusercontent.com/' \
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
@@ -1,3 +1,3 @@
1
1
  module Everypolitician
2
- VERSION = '0.2.0'
2
+ VERSION = '0.3.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: everypolitician
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Mytton