barton 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/AUTHORS +7 -0
- data/Gemfile +6 -0
- data/LICENSE +22 -0
- data/README.md +125 -0
- data/Rakefile +13 -0
- data/barton.gemspec +22 -0
- data/bin/barton +38 -0
- data/config.ru +4 -0
- data/data/.DS_Store +0 -0
- data/data/README.md +31 -0
- data/data/geo/nsw-federal.yaml +21965 -0
- data/data/geo/nsw-local.yaml +95263 -0
- data/data/geo/nsw-state.yaml +33353 -0
- data/data/geo/qld-federal.yaml +15019 -0
- data/data/geo/qld-state.yaml +20997 -0
- data/data/geo/vic-federal.yaml +8097 -0
- data/data/geo/vic-local.yaml +35686 -0
- data/data/geo/vic-state.yaml +14445 -0
- data/data/nsw-federal.yaml +337 -0
- data/data/nsw-local.yaml +2472 -0
- data/data/nsw-state.yaml +663 -0
- data/data/qld-federal.yaml +220 -0
- data/data/qld-state.yaml +643 -0
- data/data/vic-federal.yaml +149 -0
- data/data/vic-local.yaml +2255 -0
- data/data/vic-state.yaml +665 -0
- data/lib/.DS_Store +0 -0
- data/lib/barton/.DS_Store +0 -0
- data/lib/barton/app.rb +68 -0
- data/lib/barton/core.rb +174 -0
- data/lib/barton/version.rb +3 -0
- data/lib/barton.rb +3 -0
- data/pkg/barton-0.0.1.gem +0 -0
- data/specs/.DS_Store +0 -0
- data/specs/data/.DS_Store +0 -0
- data/specs/data/data-processed.yaml +39 -0
- data/specs/data/data-raw.yaml +43 -0
- data/specs/data/geo/data-processed.yaml +256 -0
- data/specs/data/geo/data-raw.yaml +256 -0
- data/specs/data/master/data-processed.yaml +39 -0
- data/specs/data/master/data-raw.yaml +31 -0
- data/specs/data/master/geo.yaml +256 -0
- data/specs/data/master/trap.txt +0 -0
- data/specs/route_spec.rb +36 -0
- data/specs/search_spec.rb +60 -0
- data/specs/setup_spec.rb +77 -0
- metadata +139 -0
data/.gitignore
ADDED
data/AUTHORS
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Barton was designed and developed by Dave Kinkead (davekinkead) in
|
2
|
+
Brisbane, Australia.
|
3
|
+
|
4
|
+
Special thanks to the following extraordinary individuals, who-out which
|
5
|
+
Barton would not be possible:
|
6
|
+
|
7
|
+
* Ben Raue, whose website The Tally Room <http://www.tallyroom.com.au> provided much of the geographical data
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Dave Kinkead
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,125 @@
|
|
1
|
+
# Barton
|
2
|
+
|
3
|
+
Barton is programmable, political access. It's an API for Australian electorate and politician contact details.
|
4
|
+
|
5
|
+
## Access
|
6
|
+
|
7
|
+
Access the API via HTTP:
|
8
|
+
|
9
|
+
curl http://barton.experimentsindemocracy.org/api
|
10
|
+
|
11
|
+
|
12
|
+
Or download and install it yourself:
|
13
|
+
|
14
|
+
$ gem install barton
|
15
|
+
$ barton --setup
|
16
|
+
$ barton
|
17
|
+
|
18
|
+
## Requests
|
19
|
+
|
20
|
+
NOTE: Barton is in a very early alpha stage and the API may change substantially. Ensure you use the email param to get notifications of any changes.
|
21
|
+
|
22
|
+
The API base with examples can be found at:
|
23
|
+
|
24
|
+
http://barton.experimentsindemocracy.org/api
|
25
|
+
|
26
|
+
Subsequent use takes the form:
|
27
|
+
|
28
|
+
/resource/[id]?[params]
|
29
|
+
|
30
|
+
To return a single electorate
|
31
|
+
|
32
|
+
/electorates/id
|
33
|
+
|
34
|
+
To return multiple electorates
|
35
|
+
|
36
|
+
/electorates?params=values
|
37
|
+
|
38
|
+
Address returns all electorates bounding the supplied address. Where ever possible, do the geocoding yourself to avoid Google's 2500 per day rate limit.
|
39
|
+
|
40
|
+
/electorates?address=676+Ann+St,+Fortitude+Valley+Qld+4006
|
41
|
+
|
42
|
+
Geo returns all electorates bounding the supplied 'long,lat' string. Using geo instead of address will result in better results.
|
43
|
+
|
44
|
+
/electorates?geo=145.77602080,-16.92192860
|
45
|
+
|
46
|
+
Tags returns all electorates matching the comma separated tags. To find all local councils and wards in Sydney for example:
|
47
|
+
|
48
|
+
/electorates?tags=sydney,local
|
49
|
+
|
50
|
+
Or get more cunning with key:value and splat tags for all Mayors in Queensland whose name that start with the letter 'G'
|
51
|
+
|
52
|
+
/electorates?tags=name:g*,queensland,mayor
|
53
|
+
|
54
|
+
Go totally freaky by mixing tags and geo. Try all politicians responsible for transport in Cairns
|
55
|
+
|
56
|
+
/electorates?geo=145.77602080,-16.92192860&tags=transport
|
57
|
+
|
58
|
+
Finally, add your email so I can keep a handle on usage and loads
|
59
|
+
|
60
|
+
/electorates?email=bob@gmail.com
|
61
|
+
|
62
|
+
## Responses
|
63
|
+
|
64
|
+
Barton will try to play HATEOAS as nicely as possible so you should be able to explore from the base api url to all resources. Responses are will be in JSON format and limited to 100 results.
|
65
|
+
|
66
|
+
/electorates?tags=name:sydney,local
|
67
|
+
|
68
|
+
{
|
69
|
+
"name": "Barton API",
|
70
|
+
"result_count": 3,
|
71
|
+
"results": [
|
72
|
+
{
|
73
|
+
"name": "Sydney",
|
74
|
+
"tags": [
|
75
|
+
"New South Wales",
|
76
|
+
"Local",
|
77
|
+
"Ward",
|
78
|
+
"Eastern Suburbs"
|
79
|
+
],
|
80
|
+
"id": "1623a1"
|
81
|
+
},
|
82
|
+
{
|
83
|
+
"name": "Sydney",
|
84
|
+
"tags": [
|
85
|
+
"New South Wales",
|
86
|
+
"Local",
|
87
|
+
"LGA",
|
88
|
+
"Eastern Suburbs"
|
89
|
+
],
|
90
|
+
"id": "164e15"
|
91
|
+
},
|
92
|
+
{
|
93
|
+
"name": "North Sydney",
|
94
|
+
"tags": [
|
95
|
+
"New South Wales",
|
96
|
+
"Local",
|
97
|
+
"LGA",
|
98
|
+
"Lower North Shore"
|
99
|
+
],
|
100
|
+
"id": "7b971f"
|
101
|
+
}
|
102
|
+
],
|
103
|
+
"resources": {
|
104
|
+
"home": "http://barton.experimentsindemocracy.org",
|
105
|
+
"api": "http://barton.experimentsindemocracy.org/api",
|
106
|
+
"electorates": "http://barton.experimentsindemocracy.org/api/electorates"
|
107
|
+
},
|
108
|
+
"examples": {
|
109
|
+
"electorates": {
|
110
|
+
"resource_id": "http://barton.experimentsindemocracy.org/api/electorates/ccbfd1",
|
111
|
+
"geo": "http://barton.experimentsindemocracy.org/api/electorates?geo=151.2054563,-33.8438383",
|
112
|
+
"tags": "http://barton.experimentsindemocracy.org/api/electorates?tags=sydney,jurisidction:local",
|
113
|
+
"mixed": "http://barton.experimentsindemocracy.org/api/electorates?geo=151.2054563,-33.8438383&tags=federal"
|
114
|
+
}
|
115
|
+
}
|
116
|
+
}
|
117
|
+
|
118
|
+
|
119
|
+
## Contributing
|
120
|
+
|
121
|
+
If you want to help then by all means jump in, fork and push a pull request.
|
122
|
+
|
123
|
+
Updating politician contact details is the most pressing job. See the [data readme][data-readme] for more details.
|
124
|
+
|
125
|
+
[data-readme]:https://github.com/davekinkead/barton/blob/master/data/README.md
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require "bundler/gem_tasks"
|
3
|
+
require 'rake/testtask'
|
4
|
+
require_relative 'lib/barton/core'
|
5
|
+
|
6
|
+
Rake::TestTask.new do |t|
|
7
|
+
ENV['RAKE_ENV'] = 'test'
|
8
|
+
Barton::Core.purge_es
|
9
|
+
Barton::Core.update_es( Barton::Core.parse_yaml( 'specs/data/data-processed.yaml' ) )
|
10
|
+
t.libs << "specs"
|
11
|
+
t.test_files = FileList['specs/*_spec.rb']
|
12
|
+
#t.verbose = true
|
13
|
+
end
|
data/barton.gemspec
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
|
3
|
+
require 'barton/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.authors = ["Dave Kinkead"]
|
7
|
+
gem.email = ["dave@kinkead.com.au"]
|
8
|
+
gem.description = "Barton is an API for Australian electorates and politicains"
|
9
|
+
gem.summary = "Programmable political access"
|
10
|
+
gem.homepage = "http://barton.experiementsindemocracy.org"
|
11
|
+
|
12
|
+
gem.files = `git ls-files`.split($\)
|
13
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
14
|
+
gem.test_files = gem.files.grep(%r{^(specs)/})
|
15
|
+
gem.name = "barton"
|
16
|
+
gem.require_paths = ["lib"]
|
17
|
+
gem.version = Barton::VERSION
|
18
|
+
|
19
|
+
gem.add_dependency 'sinatra', '~> 1.3.2'
|
20
|
+
gem.add_dependency 'trollop'
|
21
|
+
gem.add_dependency 'tire', '~> 0.4.2'
|
22
|
+
end
|
data/bin/barton
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'trollop'
|
3
|
+
|
4
|
+
# Load data from yaml source file
|
5
|
+
def load_file( filename, es=false )
|
6
|
+
puts "Loading data from #{filename}....."
|
7
|
+
electorates = Barton::Core.parse_yaml( filename )
|
8
|
+
puts "Failed to load #{filename}" if electorates.nil?
|
9
|
+
unless es
|
10
|
+
connected = Barton::Core.update_es( electorates )
|
11
|
+
abort "Connection to Elasticsearch failed" if connected.nil?
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# Option parsing for setup
|
16
|
+
opts = Trollop::options do
|
17
|
+
opt :setup, "Reload data from yaml source files", :default => false
|
18
|
+
opt :file, "Only reload specified file", :default => 'all'
|
19
|
+
opt :no_es, "Turn off elasticsearch", :default => false
|
20
|
+
end
|
21
|
+
|
22
|
+
# Action setup options
|
23
|
+
if opts[:setup]
|
24
|
+
require 'barton/core'
|
25
|
+
unless opts[:no_es]
|
26
|
+
connected = Barton::Core.purge_es
|
27
|
+
abort "Connection to Elasticsearch failed" if connected.nil?
|
28
|
+
end
|
29
|
+
if opts[:file] == 'all'
|
30
|
+
Dir['data/*.yaml'].each do |f|
|
31
|
+
load_file( f, opts[:no_es] )
|
32
|
+
end
|
33
|
+
else
|
34
|
+
load_file( opts[:file], opts[:no_es] )
|
35
|
+
end
|
36
|
+
else
|
37
|
+
require 'barton'
|
38
|
+
end
|
data/config.ru
ADDED
data/data/.DS_Store
ADDED
Binary file
|
data/data/README.md
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
# Barton API Data Source
|
2
|
+
|
3
|
+
Barton is a crowd-sourced data project and it needs your help. All (hoefully) Australian electorates, districts, councils and wards are listed but what's currently missing is contact details of politicians.
|
4
|
+
|
5
|
+
Each major jurisdiction has its own file, e.g. qld-state.yaml that contains data in the following format:
|
6
|
+
|
7
|
+
- name: Ashgrove
|
8
|
+
tags:
|
9
|
+
- Queensland
|
10
|
+
- State
|
11
|
+
- Legislative Assembly
|
12
|
+
- Brisbane North
|
13
|
+
id: e07a89
|
14
|
+
members:
|
15
|
+
- name: Campbell Newman
|
16
|
+
roles:
|
17
|
+
- Member for Ashgrove
|
18
|
+
tags:
|
19
|
+
- Premier
|
20
|
+
party: Liberal National Party (LNP)
|
21
|
+
email: ashgrove@parliament.qld.gov.au
|
22
|
+
phone: 07 3366 6000
|
23
|
+
web: http://www.parliament.qld.gov.au/members/current/list/bio?member=Newman+Campbell
|
24
|
+
post: PO Box 40, Ashgrove Q 4060
|
25
|
+
address: Ashgrove Central, 221 Waterworks Road, Ashgrove
|
26
|
+
|
27
|
+
Start perhaps with your own electorates and go from there. Any field can be edited except the id which is auto-generated.
|
28
|
+
|
29
|
+
Editing is easy. Just fork this repo (the button up there on the top right), edit the files you need and then when you are done, click 'pull request'. No techies could also just email me (dave at kinkead dot com dot au) the text and I'll merge it for you.
|
30
|
+
|
31
|
+
Thanks in advance :)
|