open_parliament 0.0.0 → 0.0.1

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 CHANGED
@@ -1,7 +1,7 @@
1
- ---
2
- SHA512:
3
- metadata.gz: 5a8d08a60b4761a11b7b159f6235e3879961090fa89b4751a897046c64cc406a2dc12d9a69888a7a1f375431d1893fef067ddaf0af0054157af8c2bd50c8750d
4
- data.tar.gz: 4d9e4d424026e85972624bbcd015cc46d0bde3bb141ba87f15d4e84de7159230df58106f370898cdb7087f0278d633df05cff4bab5e3e59dd902d06772a6c2ee
5
- SHA1:
6
- metadata.gz: 15a3c466abd7b7e39ead5d864bfd8ebb7b5a841f
7
- data.tar.gz: af2bf6307024feffb5456aa4615223cde7850a03
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9de4e102a3a94c16f5d5f67ef60e162c1912c764
4
+ data.tar.gz: 1f875edbdb4bdd1a1df019eb54f4d480450f2fb1
5
+ SHA512:
6
+ metadata.gz: b711db89f02bbe026522ac11df413c2cb59d8ebcf9bac647ee2f4a2c4c9929e774a89831a7c15a7afffe0caa347a531998be5c62d3ded77cea7f4a6a40845283
7
+ data.tar.gz: 7cb6bae102a1c716b5544551a978c565b0a108e19ede2ecb9da251120f7ec14031ece0e1072e7bd63648bec247412f807264a0660a5d6fe26fac55b60d451b20
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ source "http://rubygems.org"
2
+
3
+ gem "json"
4
+ gem "rest-client"
5
+
6
+ group :development do
7
+ gem "rspec"
8
+ gem "bundler"
9
+ gem "pry"
10
+
11
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,51 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ coderay (1.1.0)
5
+ diff-lcs (1.2.5)
6
+ domain_name (0.5.24)
7
+ unf (>= 0.0.5, < 1.0.0)
8
+ http-cookie (1.0.2)
9
+ domain_name (~> 0.5)
10
+ json (1.8.3)
11
+ method_source (0.8.2)
12
+ mime-types (2.6.1)
13
+ netrc (0.10.3)
14
+ pry (0.10.1)
15
+ coderay (~> 1.1.0)
16
+ method_source (~> 0.8.1)
17
+ slop (~> 3.4)
18
+ rest-client (1.8.0)
19
+ http-cookie (>= 1.0.2, < 2.0)
20
+ mime-types (>= 1.16, < 3.0)
21
+ netrc (~> 0.7)
22
+ rspec (3.4.0)
23
+ rspec-core (~> 3.4.0)
24
+ rspec-expectations (~> 3.4.0)
25
+ rspec-mocks (~> 3.4.0)
26
+ rspec-core (3.4.1)
27
+ rspec-support (~> 3.4.0)
28
+ rspec-expectations (3.4.0)
29
+ diff-lcs (>= 1.2.0, < 2.0)
30
+ rspec-support (~> 3.4.0)
31
+ rspec-mocks (3.4.0)
32
+ diff-lcs (>= 1.2.0, < 2.0)
33
+ rspec-support (~> 3.4.0)
34
+ rspec-support (3.4.1)
35
+ slop (3.6.0)
36
+ unf (0.1.4)
37
+ unf_ext
38
+ unf_ext (0.0.7.1)
39
+
40
+ PLATFORMS
41
+ ruby
42
+
43
+ DEPENDENCIES
44
+ bundler
45
+ json
46
+ pry
47
+ rest-client
48
+ rspec
49
+
50
+ BUNDLED WITH
51
+ 1.10.5
data/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Dylan R
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # Open Parliament gem
2
+
3
+ A simple gem to interface with the api at https://openparliament.ca/api/
4
+
5
+ ##Features
6
+ Currently supports basic GETs of 5 endpoints: Bills, Committees, Debates, Politicians, and Votes. These endpoints return lists of OpenParliament objects (which are currently just OpenStructs).
7
+
8
+ ##Usage
9
+ ```
10
+ gem install open_parliament
11
+
12
+ require 'open_parliament'
13
+
14
+ # Get lists of Bills, Committees, Debates, Politicians, and Votes
15
+ OpenParliament.bills => [OpenParliament::Bill...]
16
+ OpenParliament.committees => [OpenParliament::Committee..]
17
+ OpenParliament.debates => [OpenParliament::Debate...]
18
+ OpenParliament.politicians => [OpenParliament::Politican...]
19
+ OpenParliament.votes => [OpenParliament::Vote...]
20
+
21
+ # Get properties from these objects as you would any OpenStruct
22
+ vote = OpenParliament.votes.first
23
+ vote.result => "Passed"
24
+ vote.description["en"] => "That the Bill be now read a third time and do pass."
25
+ ```
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ desc "Open an irb session preloaded with this library"
2
+ task :console do
3
+ sh "irb -rubygems -I lib -r open_parliament.rb"
4
+ end
@@ -1,5 +1,50 @@
1
- class OpenParliament
2
- def self.hi
3
- puts "Hello world!"
1
+ require 'rest-client'
2
+ require 'json'
3
+ require 'open-uri'
4
+ require 'ostruct'
5
+
6
+ require 'open_parliament/bill'
7
+ require 'open_parliament/committee'
8
+ require 'open_parliament/debate'
9
+ require 'open_parliament/politician'
10
+ require 'open_parliament/vote'
11
+ require 'open_parliament/request_service'
12
+
13
+ module OpenParliament
14
+ API_URL = 'http://api.openparliament.ca'
15
+
16
+ def self.bills
17
+ url = "/bills/"
18
+ json = RequestService.make_request(url: url, method: :get)
19
+ bills = json["objects"]
20
+ bills.map { |bill_json| Bill.new(bill_json) }
21
+ end
22
+
23
+ def self.committees
24
+ url = "/committees/"
25
+ json = RequestService.make_request(url: url, method: :get)
26
+ committees = json["objects"]
27
+ committees.map { |committee_json| Committee.new(committee_json) }
28
+ end
29
+
30
+ def self.debates
31
+ url = "/debates/"
32
+ json = RequestService.make_request(url: url, method: :get)
33
+ debates = json["objects"]
34
+ debates.map { |debate_json| Debate.new(debate_json) }
35
+ end
36
+
37
+ def self.votes
38
+ url = "/votes/"
39
+ json = RequestService.make_request(url: url, method: :get)
40
+ votes = json["objects"]
41
+ votes.map { |vote_json| Vote.new(vote_json) }
42
+ end
43
+
44
+ def self.politicians
45
+ url = "/politicians/"
46
+ json = RequestService.make_request(url: url, method: :get)
47
+ politicians = json["objects"]
48
+ politicians.map { |politician_json| Politician.new(politician_json) }
4
49
  end
5
50
  end
@@ -0,0 +1,4 @@
1
+ module OpenParliament
2
+ class Bill < OpenStruct
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module OpenParliament
2
+ class Committee < OpenStruct
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module OpenParliament
2
+ class Debate < OpenStruct
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module OpenParliament
2
+ class Politician < OpenStruct
3
+ end
4
+ end
@@ -0,0 +1,16 @@
1
+ module OpenParliament
2
+ module RequestService
3
+
4
+ def self.make_request(url:, method:, params: {})
5
+ full_url = "#{OpenParliament::API_URL}#{url}"
6
+
7
+ resp = RestClient::Request.execute(method: method,
8
+ url: full_url,
9
+ timeout: 10,
10
+ headers: { accept: :json }
11
+ )
12
+ JSON.parse(resp)
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,4 @@
1
+ module OpenParliament
2
+ class Vote < OpenStruct
3
+ end
4
+ end
metadata CHANGED
@@ -1,53 +1,55 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: open_parliament
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
5
  platform: ruby
6
- authors:
6
+ authors:
7
7
  - Dylan Runkel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
-
12
- date: 2016-01-01 00:00:00 Z
11
+ date: 2016-01-01 00:00:00.000000000 Z
13
12
  dependencies: []
14
-
15
13
  description: Simple gem for interfacing with openparliament.ca's API
16
14
  email: dylan.runkel@gmail.com
17
15
  executables: []
18
-
19
16
  extensions: []
20
-
21
17
  extra_rdoc_files: []
22
-
23
- files:
18
+ files:
19
+ - Gemfile
20
+ - Gemfile.lock
21
+ - LICENSE.md
22
+ - README.md
23
+ - Rakefile
24
24
  - lib/open_parliament.rb
25
- homepage: http://rubygems.org/gems/open_parliament
26
- licenses:
25
+ - lib/open_parliament/bill.rb
26
+ - lib/open_parliament/committee.rb
27
+ - lib/open_parliament/debate.rb
28
+ - lib/open_parliament/politician.rb
29
+ - lib/open_parliament/request_service.rb
30
+ - lib/open_parliament/vote.rb
31
+ homepage: https://github.com/drunkel/open_parliament
32
+ licenses:
27
33
  - MIT
28
34
  metadata: {}
29
-
30
35
  post_install_message:
31
36
  rdoc_options: []
32
-
33
- require_paths:
37
+ require_paths:
34
38
  - lib
35
- required_ruby_version: !ruby/object:Gem::Requirement
36
- requirements:
37
- - &id001
38
- - ">="
39
- - !ruby/object:Gem::Version
40
- version: "0"
41
- required_rubygems_version: !ruby/object:Gem::Requirement
42
- requirements:
43
- - *id001
39
+ required_ruby_version: !ruby/object:Gem::Requirement
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
44
+ required_rubygems_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: '0'
44
49
  requirements: []
45
-
46
50
  rubyforge_project:
47
- rubygems_version: 2.0.17
51
+ rubygems_version: 2.4.8
48
52
  signing_key:
49
53
  specification_version: 4
50
54
  summary: Open Parliament
51
55
  test_files: []
52
-
53
- has_rdoc: