everypolitician 0.1.0 → 0.2.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: e6cd7789d441da01c6a0685b7eea36f8a4af1e77
4
- data.tar.gz: aa92d7fa2be7ac85a54868ea3aa7596b2520a2be
3
+ metadata.gz: 675689b7fab868a111b237a0ecffb06220838068
4
+ data.tar.gz: 6a43207310744cd794397a44efb181a7478bf4d6
5
5
  SHA512:
6
- metadata.gz: 9059c49784aae8154f2d80ceac8602f382d2f1acec82dca37d13dbb3e682477dcefe32e4840f5e18a16d2d0f34ca63a7871666e577bab251053f58f8f245cd80
7
- data.tar.gz: 42256a613b5ad9de9a191635d96b1d483803c5ffd1cf3db8bbd1e7eb4d99c603e35dc68580108e5d56dbad637b4bb33aa45b42eb18d9a5cb520952fe2308e3ab
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 [![Build Status](https://travis-ci.org/everypolitician/everypolitician-ruby.svg?branch=v0.1.0)](https://travis-ci.org/everypolitician/everypolitician-ruby) [![Gem Version](https://badge.fury.io/rb/everypolitician.svg)](https://badge.fury.io/rb/everypolitician)
2
2
 
3
3
  Interface with EveryPolitician data from your Ruby application.
4
4
 
@@ -1,3 +1,3 @@
1
1
  module Everypolitician
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -31,11 +31,7 @@ module Everypolitician
31
31
 
32
32
  class Country < Entity
33
33
  def self.find(slug)
34
- countries_json_url = 'https://raw.githubusercontent.com/' \
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
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.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Mytton