twfy 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,10 @@
1
+ == 1.0.1 / 2008-08-02
2
+
3
+ * In the near future the TWFY API will require an API Key for all calls. In preparation for this, this binding now requires an API Key. They are available at http://www.theyworkforyou.com/api/key
4
+ * Added support for new features of TWFY API (still version 1.0.0).
5
+ * getMLAs - Members of the Legislative Assembly (Members of the Northern Irish Assembly to you and me)
6
+ * getMSPs - Members of the Scottish Parliament
7
+
1
8
  == 1.0.0 / 2006-11-08
2
9
 
3
10
  * Initial release supporting all services from TWFY API 1.0.0
@@ -7,4 +14,4 @@
7
14
  * Coming up:
8
15
  * Easy pagination of debates, comments, etc
9
16
  * Data mining MPInfo information (ie expenses, accessible directly from MP instance)
10
- * Other stuff :-)
17
+ * Other stuff :-)
data/Manifest.txt CHANGED
@@ -6,3 +6,4 @@ lib/data_element.rb
6
6
  lib/twfy.rb
7
7
  test/test_twfy.rb
8
8
  test/test_twfy_chain.rb
9
+ test/api_key
data/README.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  twfy
2
2
  by Bruce Williams (http://codefluency.com)
3
- and Martin Owens
3
+ and Martin Owen (http://martinowen.net)
4
4
 
5
5
  == DESCRIPTION:
6
6
 
@@ -34,7 +34,10 @@ Use is very easy.
34
34
  === Get a Client
35
35
 
36
36
  require 'twfy'
37
- client = Twfy::Client.new
37
+ client = Twfy::Client.new(<YOUR API KEY HERE>)
38
+
39
+ Note that the Twfy::Client constructor in version 1.0.1 of the binding requires an API Key
40
+ string. If you don't have one they are available at http://www.theyworkforyou.com/api/key
38
41
 
39
42
  === Call API methods directly on client
40
43
 
data/Rakefile CHANGED
@@ -16,7 +16,7 @@ EOD
16
16
  p.changes = p.paragraphs_of('History.txt', 0..1).join("\n\n")
17
17
  p.extra_deps = ['json', 'paginator']
18
18
  p.email = %q{bruce@codefluency.com}
19
- p.author = ["Bruce Williams", "Martin Owens"]
19
+ p.author = ["Bruce Williams", "Martin Owen"]
20
20
  end
21
21
 
22
22
  # vim: syntax=Ruby
data/lib/twfy.rb CHANGED
@@ -1,3 +1,4 @@
1
+ require 'rubygems'
1
2
  require 'open-uri'
2
3
  require 'json'
3
4
  require 'cgi'
@@ -8,7 +9,7 @@ require File.join(File.dirname(__FILE__), 'data_element')
8
9
 
9
10
  module Twfy
10
11
 
11
- VERSION = '1.0.0'
12
+ VERSION = '1.0.1'
12
13
  BASE = URI.parse('http://www.theyworkforyou.com/api/')
13
14
 
14
15
  API_VERSION = '1.0.0'
@@ -19,7 +20,8 @@ module Twfy
19
20
  class ServiceArgumentError < ::ArgumentError; end
20
21
  class APIError < ::StandardError; end
21
22
 
22
- def initialize(log_to=$stderr)
23
+ def initialize(api_key, log_to=$stderr)
24
+ @api_key = api_key
23
25
  @logger = Logger.new(log_to)
24
26
  end
25
27
 
@@ -61,6 +63,14 @@ module Twfy
61
63
  service :getLords, validate(params, :allow => [:date, :search])
62
64
  end
63
65
 
66
+ def mlas(params={})
67
+ service :getMLAs, validate(params, :allow => [:date, :party, :search])
68
+ end
69
+
70
+ def msps(params={})
71
+ service :getMSPs, validate(params, :allow => [:date, :party, :search])
72
+ end
73
+
64
74
  def geometry(params={})
65
75
  service :getGeometry, validate(params, :allow => :name), Geometry
66
76
  end
@@ -164,10 +174,10 @@ module Twfy
164
174
  end
165
175
 
166
176
  def build_query(params)
167
- params.update(:version=>API_VERSION)
177
+ params.update(:key=>@api_key, :version=>API_VERSION)
168
178
  params.map{|set| set.map{|i| CGI.escape(i.to_s)}.join('=') }.join('&')
169
179
  end
170
180
 
171
181
  end
172
182
 
173
- end
183
+ end
data/test/api_key ADDED
@@ -0,0 +1 @@
1
+ B47i8vFYfgWvAa89eYErLWPF
data/test/test_twfy.rb CHANGED
@@ -2,9 +2,12 @@ require 'test/unit'
2
2
  require File.join(File.dirname(__FILE__), '../lib/twfy')
3
3
 
4
4
  class BasicReturnedDataTest < Test::Unit::TestCase
5
-
5
+
6
+ API_KEY_LOCATION = File.join(File.dirname(__FILE__), 'api_key')
7
+
6
8
  def setup
7
- @client = Twfy::Client.new
9
+ api_key = File.open(API_KEY_LOCATION){ |f| f.readlines[0].chomp }
10
+ @client = Twfy::Client.new(api_key)
8
11
  end
9
12
 
10
13
  def test_convert_url
@@ -26,6 +29,14 @@ class BasicReturnedDataTest < Test::Unit::TestCase
26
29
  assert_kind_of Twfy::MP, mp
27
30
  end
28
31
  end
32
+
33
+ def test_msps
34
+ msps = @client.msps
35
+ assert_kind_of Array, msps
36
+ msps.each do |msp|
37
+ assert_kind_of OpenStruct, msp
38
+ end
39
+ end
29
40
 
30
41
  def test_constituency_and_geometry
31
42
  c = @client.constituency(:postcode => 'IP6 9PN')
@@ -41,4 +52,4 @@ class BasicReturnedDataTest < Test::Unit::TestCase
41
52
  end
42
53
  end
43
54
 
44
- end
55
+ end
@@ -2,9 +2,12 @@ require 'test/unit'
2
2
  require File.join(File.dirname(__FILE__), '../lib/twfy')
3
3
 
4
4
  class ChainDataTest < Test::Unit::TestCase
5
-
5
+
6
+ API_KEY_LOCATION = File.join(File.dirname(__FILE__), 'api_key')
7
+
6
8
  def setup
7
- @client = Twfy::Client.new
9
+ api_key = File.open(API_KEY_LOCATION){ |f| f.readlines[0].chomp }
10
+ @client = Twfy::Client.new(api_key)
8
11
  @mp = @client.mp(:postcode=>'IP6 9PN')
9
12
  end
10
13
 
@@ -46,4 +49,4 @@ class ChainDataTest < Test::Unit::TestCase
46
49
  end
47
50
 
48
51
  end
49
-
52
+
metadata CHANGED
@@ -1,71 +1,95 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
3
- specification_version: 1
4
2
  name: twfy
5
3
  version: !ruby/object:Gem::Version
6
- version: 1.0.0
7
- date: 2006-11-20 00:00:00 -07:00
8
- summary: Ruby library to interface with the TheyWorkForYou(.com) API; an information source on Parliament
9
- require_paths:
10
- - lib
11
- - test
12
- email: bruce@codefluency.com
13
- homepage: http://twfy.rubyforge.org
14
- rubyforge_project: twfy
15
- description: Ruby library to interface with the TheyWorkForYou API. TheyWorkForYou.com is "a non-partisan, volunteer-run website which aims to make it easy for people to keep tabs on their elected and unelected representatives in Parliament."
16
- autorequire:
17
- default_executable:
18
- bindir: bin
19
- has_rdoc: true
20
- required_ruby_version: !ruby/object:Gem::Version::Requirement
21
- requirements:
22
- - - ">"
23
- - !ruby/object:Gem::Version
24
- version: 0.0.0
25
- version:
4
+ version: 1.0.1
26
5
  platform: ruby
27
- signing_key:
28
- cert_chain:
29
6
  authors:
30
7
  - Bruce Williams
31
- - Martin Owens
32
- files:
33
- - History.txt
34
- - Manifest.txt
35
- - README.txt
36
- - Rakefile
37
- - lib/data_element.rb
38
- - lib/twfy.rb
39
- - test/test_twfy.rb
40
- - test/test_twfy_chain.rb
41
- test_files: []
42
-
43
- rdoc_options: []
44
-
45
- extra_rdoc_files: []
46
-
47
- executables: []
48
-
49
- extensions: []
50
-
51
- requirements: []
8
+ - Martin Owen
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
52
12
 
13
+ date: 2008-08-03 00:00:00 +01:00
14
+ default_executable:
53
15
  dependencies:
54
16
  - !ruby/object:Gem::Dependency
55
17
  name: json
18
+ type: :runtime
56
19
  version_requirement:
57
- version_requirements: !ruby/object:Gem::Version::Requirement
20
+ version_requirements: !ruby/object:Gem::Requirement
58
21
  requirements:
59
- - - ">"
22
+ - - ">="
60
23
  - !ruby/object:Gem::Version
61
- version: 0.0.0
24
+ version: "0"
62
25
  version:
63
26
  - !ruby/object:Gem::Dependency
64
27
  name: paginator
28
+ type: :runtime
29
+ version_requirement:
30
+ version_requirements: !ruby/object:Gem::Requirement
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0"
35
+ version:
36
+ - !ruby/object:Gem::Dependency
37
+ name: hoe
38
+ type: :development
65
39
  version_requirement:
66
- version_requirements: !ruby/object:Gem::Version::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
67
41
  requirements:
68
- - - ">"
42
+ - - ">="
69
43
  - !ruby/object:Gem::Version
70
- version: 0.0.0
44
+ version: 1.7.0
71
45
  version:
46
+ description: Ruby library to interface with the TheyWorkForYou API. TheyWorkForYou.com is "a non-partisan, volunteer-run website which aims to make it easy for people to keep tabs on their elected and unelected representatives in Parliament."
47
+ email: bruce@codefluency.com
48
+ executables: []
49
+
50
+ extensions: []
51
+
52
+ extra_rdoc_files:
53
+ - History.txt
54
+ - Manifest.txt
55
+ - README.txt
56
+ files:
57
+ - History.txt
58
+ - Manifest.txt
59
+ - README.txt
60
+ - Rakefile
61
+ - lib/data_element.rb
62
+ - lib/twfy.rb
63
+ - test/test_twfy.rb
64
+ - test/test_twfy_chain.rb
65
+ - test/api_key
66
+ has_rdoc: true
67
+ homepage: http://twfy.rubyforge.org
68
+ post_install_message:
69
+ rdoc_options:
70
+ - --main
71
+ - README.txt
72
+ require_paths:
73
+ - lib
74
+ required_ruby_version: !ruby/object:Gem::Requirement
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
79
+ version:
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: "0"
85
+ version:
86
+ requirements: []
87
+
88
+ rubyforge_project: twfy
89
+ rubygems_version: 1.2.0
90
+ signing_key:
91
+ specification_version: 2
92
+ summary: Ruby library to interface with the TheyWorkForYou(.com) API; an information source on Parliament
93
+ test_files:
94
+ - test/test_twfy.rb
95
+ - test/test_twfy_chain.rb