openaustralia 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/.rvmrc +55 -0
- data/CHANGES.md +13 -0
- data/Gemfile +4 -0
- data/LICENSE.md +23 -0
- data/README.md +49 -0
- data/Rakefile +10 -0
- data/lib/openaustralia.rb +6 -0
- data/lib/openaustralia/api.rb +248 -0
- data/lib/openaustralia/comments.rb +28 -0
- data/lib/openaustralia/debates.rb +43 -0
- data/lib/openaustralia/divisions.rb +22 -0
- data/lib/openaustralia/hansard.rb +62 -0
- data/lib/openaustralia/representatives.rb +51 -0
- data/lib/openaustralia/search_info.rb +14 -0
- data/lib/openaustralia/senators.rb +51 -0
- data/lib/openaustralia/version.rb +3 -0
- data/openaustralia.gemspec +20 -0
- data/test/comments.xml +282 -0
- data/test/debate_search_reps.xml +181 -0
- data/test/debate_search_senate.xml +652 -0
- data/test/division_search_2077.xml +6 -0
- data/test/hansard_utegate_search.xml +235 -0
- data/test/nsw_senators.xml +75 -0
- data/test/representative_abbott.xml +31 -0
- data/test/representatives_search_andrew.xml +31 -0
- data/test/senator_steve_hutchison.xml +19 -0
- data/test/test_api.rb +78 -0
- data/test/test_helper.rb +4 -0
- data/test/test_parse.rb +45 -0
- data/test/test_res.xml +31 -0
- metadata +113 -0
data/test/test_helper.rb
ADDED
data/test/test_parse.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
# test the XML mapping objects
|
4
|
+
# and see that they parse OK
|
5
|
+
# against the captured samples
|
6
|
+
class TestParse < Test::Unit::TestCase
|
7
|
+
def open_sample(file)
|
8
|
+
File.open(File.join(File.dirname(__FILE__), file)) do |f|
|
9
|
+
return REXML::Document.new f
|
10
|
+
end
|
11
|
+
end
|
12
|
+
def test_request_url
|
13
|
+
api = OpenAustralia::Api.new 'ASDF'
|
14
|
+
|
15
|
+
url = api.send(:request_url, 'getDivisions', { :postcode => '2032'})
|
16
|
+
assert_equal('http://www.openaustralia.org/api/getDivisions?key=ASDF&output=xml&postcode=2032', url)
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_parse_debate_search_reps
|
20
|
+
doc = open_sample('debate_search_reps.xml')
|
21
|
+
srch = OpenAustralia::DebateSearch.load_from_xml doc.root
|
22
|
+
|
23
|
+
assert(srch != nil, 'should have parsed the search results object')
|
24
|
+
assert(srch.search_description != nil, "search description didn't parse")
|
25
|
+
assert(srch.results.count > 0, 'should have multiple results')
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_parse_debate_search_senate
|
29
|
+
doc = open_sample('debate_search_senate.xml')
|
30
|
+
srch = OpenAustralia::DebateSearch.load_from_xml doc.root
|
31
|
+
|
32
|
+
assert(srch != nil, 'should have parsed the search results object')
|
33
|
+
assert(srch.search_description != nil, "search description didn't parse")
|
34
|
+
assert(srch.results.count > 0, 'should have multiple results')
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_hansard_utegate_search
|
38
|
+
doc = open_sample('hansard_utegate_search.xml')
|
39
|
+
srch = OpenAustralia::HansardSearch.load_from_xml doc.root
|
40
|
+
|
41
|
+
assert(srch != nil, 'should have parsed the search results object')
|
42
|
+
assert(srch.search_description != nil, "search description didn't parse")
|
43
|
+
assert(srch.results.count > 0, 'should have multiple results')
|
44
|
+
end
|
45
|
+
end
|
data/test/test_res.xml
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
<?xml version="1.0"?>
|
2
|
+
<result>
|
3
|
+
<match>
|
4
|
+
<member_id>1</member_id>
|
5
|
+
<house>1</house>
|
6
|
+
<first_name>Tony</first_name>
|
7
|
+
<last_name>Abbott</last_name>
|
8
|
+
<constituency>Warringah</constituency>
|
9
|
+
<party>Liberal Party</party>
|
10
|
+
<entered_house>1994-03-26</entered_house>
|
11
|
+
<left_house>9999-12-31</left_house>
|
12
|
+
<entered_reason>by_election</entered_reason>
|
13
|
+
<left_reason>still_in_office</left_reason>
|
14
|
+
<person_id>10001</person_id>
|
15
|
+
<title></title>
|
16
|
+
<lastupdate>2008-07-20 22:54:54</lastupdate>
|
17
|
+
<full_name>Tony Abbott</full_name>
|
18
|
+
<image>/images/mpsL/10001.jpg</image>
|
19
|
+
<office>
|
20
|
+
<match>
|
21
|
+
<moffice_id>20181</moffice_id>
|
22
|
+
<dept></dept>
|
23
|
+
<position>Shadow Minister for Families, Housing, Community Services and Indigenous Affairs</position>
|
24
|
+
<from_date>2008-09-22</from_date>
|
25
|
+
<to_date>9999-12-31</to_date>
|
26
|
+
<person>10001</person>
|
27
|
+
<source></source>
|
28
|
+
</match>
|
29
|
+
</office>
|
30
|
+
</match>
|
31
|
+
</result>
|
metadata
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: openaustralia
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Henare Degan
|
9
|
+
- Alex Cooper
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-07-13 00:00:00.000000000Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: xml-mapping
|
17
|
+
requirement: &21938460 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *21938460
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rake
|
28
|
+
requirement: &21938020 !ruby/object:Gem::Requirement
|
29
|
+
none: false
|
30
|
+
requirements:
|
31
|
+
- - ! '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: *21938020
|
37
|
+
description: OpenAustralia API
|
38
|
+
email:
|
39
|
+
- henare.degan@gmail.com
|
40
|
+
executables: []
|
41
|
+
extensions: []
|
42
|
+
extra_rdoc_files: []
|
43
|
+
files:
|
44
|
+
- .gitignore
|
45
|
+
- .rvmrc
|
46
|
+
- CHANGES.md
|
47
|
+
- Gemfile
|
48
|
+
- LICENSE.md
|
49
|
+
- README.md
|
50
|
+
- Rakefile
|
51
|
+
- lib/openaustralia.rb
|
52
|
+
- lib/openaustralia/api.rb
|
53
|
+
- lib/openaustralia/comments.rb
|
54
|
+
- lib/openaustralia/debates.rb
|
55
|
+
- lib/openaustralia/divisions.rb
|
56
|
+
- lib/openaustralia/hansard.rb
|
57
|
+
- lib/openaustralia/representatives.rb
|
58
|
+
- lib/openaustralia/search_info.rb
|
59
|
+
- lib/openaustralia/senators.rb
|
60
|
+
- lib/openaustralia/version.rb
|
61
|
+
- openaustralia.gemspec
|
62
|
+
- test/comments.xml
|
63
|
+
- test/debate_search_reps.xml
|
64
|
+
- test/debate_search_senate.xml
|
65
|
+
- test/division_search_2077.xml
|
66
|
+
- test/hansard_utegate_search.xml
|
67
|
+
- test/nsw_senators.xml
|
68
|
+
- test/representative_abbott.xml
|
69
|
+
- test/representatives_search_andrew.xml
|
70
|
+
- test/senator_steve_hutchison.xml
|
71
|
+
- test/test_api.rb
|
72
|
+
- test/test_helper.rb
|
73
|
+
- test/test_parse.rb
|
74
|
+
- test/test_res.xml
|
75
|
+
homepage: https://github.com/henare/openaustralia-api/
|
76
|
+
licenses: []
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: '0'
|
87
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
|
+
none: false
|
89
|
+
requirements:
|
90
|
+
- - ! '>='
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
requirements: []
|
94
|
+
rubyforge_project:
|
95
|
+
rubygems_version: 1.8.10
|
96
|
+
signing_key:
|
97
|
+
specification_version: 3
|
98
|
+
summary: Ruby wrapper for the OpenAustralia API
|
99
|
+
test_files:
|
100
|
+
- test/comments.xml
|
101
|
+
- test/debate_search_reps.xml
|
102
|
+
- test/debate_search_senate.xml
|
103
|
+
- test/division_search_2077.xml
|
104
|
+
- test/hansard_utegate_search.xml
|
105
|
+
- test/nsw_senators.xml
|
106
|
+
- test/representative_abbott.xml
|
107
|
+
- test/representatives_search_andrew.xml
|
108
|
+
- test/senator_steve_hutchison.xml
|
109
|
+
- test/test_api.rb
|
110
|
+
- test/test_helper.rb
|
111
|
+
- test/test_parse.rb
|
112
|
+
- test/test_res.xml
|
113
|
+
has_rdoc:
|