barton 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +12 -5
- data/README.md +78 -45
- data/Rakefile +2 -3
- data/TODO.md +16 -0
- data/barton.gemspec +5 -2
- data/bin/barton +17 -2
- data/config.ru +2 -1
- data/data/nsw-state.yaml +2 -0
- data/data/qld-state.yaml +133 -5
- data/lib/barton.rb +14 -5
- data/lib/barton/app.rb +45 -19
- data/lib/barton/core.rb +158 -101
- data/lib/barton/docs.html +173 -0
- data/lib/barton/version.rb +1 -1
- data/specs/data/data-processed.yaml +19 -13
- data/specs/data/data-raw.yaml +10 -13
- data/specs/data/geo/data-processed.yaml +7 -7
- data/specs/data/geo/data-raw.yaml +4 -4
- data/specs/data/master/data-processed.yaml +19 -13
- data/specs/data/master/data-raw.yaml +7 -8
- data/specs/data/master/geo.yaml +7 -7
- data/specs/find_spec.rb +80 -0
- data/specs/route_spec.rb +21 -7
- data/specs/search_spec.rb +18 -39
- data/specs/setup_spec.rb +31 -30
- metadata +59 -3
data/Gemfile.lock
CHANGED
@@ -1,29 +1,35 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
barton (0.0.
|
4
|
+
barton (0.0.3)
|
5
5
|
json
|
6
|
+
newrelic_rpm
|
7
|
+
rack-test
|
6
8
|
sinatra (~> 1.3.2)
|
7
9
|
tire (~> 0.4.2)
|
10
|
+
trollop
|
8
11
|
|
9
12
|
GEM
|
10
13
|
remote: http://rubygems.org/
|
11
14
|
specs:
|
12
|
-
activemodel (3.2.
|
13
|
-
activesupport (= 3.2.
|
15
|
+
activemodel (3.2.8)
|
16
|
+
activesupport (= 3.2.8)
|
14
17
|
builder (~> 3.0.0)
|
15
|
-
activesupport (3.2.
|
18
|
+
activesupport (3.2.8)
|
16
19
|
i18n (~> 0.6)
|
17
20
|
multi_json (~> 1.0)
|
18
21
|
builder (3.0.0)
|
19
22
|
hashr (0.0.21)
|
20
23
|
i18n (0.6.0)
|
21
|
-
json (1.7.
|
24
|
+
json (1.7.4)
|
22
25
|
mime-types (1.19)
|
23
26
|
multi_json (1.3.6)
|
27
|
+
newrelic_rpm (3.4.1)
|
24
28
|
rack (1.4.1)
|
25
29
|
rack-protection (1.2.0)
|
26
30
|
rack
|
31
|
+
rack-test (0.6.1)
|
32
|
+
rack (>= 1.0)
|
27
33
|
rake (0.9.2.2)
|
28
34
|
rest-client (1.6.7)
|
29
35
|
mime-types (>= 1.16)
|
@@ -38,6 +44,7 @@ GEM
|
|
38
44
|
multi_json (~> 1.0)
|
39
45
|
rake
|
40
46
|
rest-client (~> 1.6)
|
47
|
+
trollop (1.16.2)
|
41
48
|
|
42
49
|
PLATFORMS
|
43
50
|
ruby
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Barton
|
2
2
|
|
3
|
-
Barton is programmable, political access. It's an API for Australian
|
3
|
+
Barton is programmable, political access. It's an API for Australian electorates and politician contact details.
|
4
4
|
|
5
5
|
## Access
|
6
6
|
|
@@ -8,12 +8,26 @@ Access the API via HTTP:
|
|
8
8
|
|
9
9
|
curl http://barton.experimentsindemocracy.org/api
|
10
10
|
|
11
|
+
Barton is read only so you'll only ever need to GET
|
11
12
|
|
12
|
-
|
13
|
+
## Download
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
$ barton
|
15
|
+
If you'd like to download and install it yourself you can do this as either a gem:
|
16
|
+
|
17
|
+
$ gem install barton
|
18
|
+
|
19
|
+
Or git if that tickles your fancy
|
20
|
+
|
21
|
+
git@github.com:experimentsindemocracy/barton.git
|
22
|
+
|
23
|
+
But first you'll need to install [Elasticsearch][es]
|
24
|
+
|
25
|
+
$ brew install elasticsearch
|
26
|
+
|
27
|
+
Then setup the data and run locally
|
28
|
+
|
29
|
+
$ barton --setup environment_name
|
30
|
+
$ barton --run environment_name
|
17
31
|
|
18
32
|
## Requests
|
19
33
|
|
@@ -31,15 +45,15 @@ To return a single electorate
|
|
31
45
|
|
32
46
|
/electorates/id
|
33
47
|
|
34
|
-
To return multiple
|
48
|
+
To return multiple politicians
|
35
49
|
|
36
|
-
/
|
50
|
+
/members?params=values
|
37
51
|
|
38
52
|
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
53
|
|
40
54
|
/electorates?address=676+Ann+St,+Fortitude+Valley+Qld+4006
|
41
55
|
|
42
|
-
Geo returns all electorates bounding the supplied 'long,lat' string. Using geo instead of address will result in
|
56
|
+
Geo returns all electorates bounding the supplied 'long,lat' string. Using geo instead of address will result in faster response times.
|
43
57
|
|
44
58
|
/electorates?geo=145.77602080,-16.92192860
|
45
59
|
|
@@ -47,9 +61,11 @@ Tags returns all electorates matching the comma separated tags. To find all loca
|
|
47
61
|
|
48
62
|
/electorates?tags=sydney,local
|
49
63
|
|
50
|
-
|
64
|
+
Reach down into resources to filter by their children. To find
|
65
|
+
|
66
|
+
Or get more cunning with key:value and splats for all Mayors in Queensland whose name that start with the letter 'G'
|
51
67
|
|
52
|
-
/
|
68
|
+
/members?tags=name:g*,queensland,mayor
|
53
69
|
|
54
70
|
Go totally freaky by mixing tags and geo. Try all politicians responsible for transport in Cairns
|
55
71
|
|
@@ -61,65 +77,82 @@ Finally, add your email so I can keep a handle on usage and loads
|
|
61
77
|
|
62
78
|
## Responses
|
63
79
|
|
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.
|
80
|
+
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.
|
65
81
|
|
66
|
-
|
82
|
+
Responses are JSON format and limited to 100 results. Barton will return a status 200 whenever things are dandy or a 404 if no matching resources are found.
|
83
|
+
|
84
|
+
http://barton.experimentsindemocracy.org/api/members?tags=name:newman
|
67
85
|
|
68
86
|
{
|
69
87
|
"name": "Barton API",
|
70
|
-
"
|
88
|
+
"disclaimer": "This data is crowded sourced and provided free of charge for informational purposes only. No guarantees regarding data quality are made whatsoever apart from it's rather considerable coolness.",
|
89
|
+
"license": "MIT License http://www.opensource.org/licenses/mit-license.php",
|
90
|
+
"result_count": 2,
|
71
91
|
"results": [
|
72
92
|
{
|
73
|
-
"name": "
|
93
|
+
"name": "Campbell Newman",
|
94
|
+
"role": "Premier",
|
95
|
+
"party": "LNP",
|
96
|
+
"address": "Level 15, Executive Building, 100 George Street, Brisbane Qld 4000",
|
97
|
+
"email": "thepremier@premiers.qld.gov.au",
|
98
|
+
"phone": "07 3224 4500",
|
99
|
+
"fax": "07 3221 1809",
|
100
|
+
"id": "0db2ec",
|
101
|
+
"type": "member",
|
74
102
|
"tags": [
|
75
|
-
"
|
76
|
-
"
|
77
|
-
"
|
78
|
-
"Eastern Suburbs"
|
103
|
+
"Queensland",
|
104
|
+
"State",
|
105
|
+
"Legislative Assembly"
|
79
106
|
],
|
80
|
-
"
|
107
|
+
"electorate": {
|
108
|
+
"name": "Queensland",
|
109
|
+
"url": "http://barton.experimentsindemocracy.org/api/electorates/03d420"
|
110
|
+
},
|
111
|
+
"url": "http://barton.experimentsindemocracy.org/api/members/0db2ec"
|
81
112
|
},
|
82
113
|
{
|
83
|
-
"name": "
|
114
|
+
"name": "Campbell Newman",
|
115
|
+
"party": "LNP",
|
116
|
+
"role": "Member for Ashgrove",
|
117
|
+
"email": "ashgrove@parliament.qld.gov.au",
|
118
|
+
"phone": "07 3366 6000",
|
119
|
+
"web": "http://www.parliament.qld.gov.au/members/current/list/bio?member=Newman+Campbell",
|
120
|
+
"post": "PO Box 40, Ashgrove Q 4060",
|
121
|
+
"address": "Ashgrove Central, 221 Waterworks Road, Ashgrove",
|
122
|
+
"id": "207190",
|
123
|
+
"type": "member",
|
84
124
|
"tags": [
|
85
|
-
"
|
86
|
-
"
|
87
|
-
"
|
88
|
-
"
|
125
|
+
"Queensland",
|
126
|
+
"State",
|
127
|
+
"Legislative Assembly",
|
128
|
+
"Brisbane North"
|
89
129
|
],
|
90
|
-
"
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
"
|
95
|
-
"New South Wales",
|
96
|
-
"Local",
|
97
|
-
"LGA",
|
98
|
-
"Lower North Shore"
|
99
|
-
],
|
100
|
-
"id": "7b971f"
|
130
|
+
"electorate": {
|
131
|
+
"name": "Ashgrove",
|
132
|
+
"url": "http://barton.experimentsindemocracy.org/api/electorates/e07a89"
|
133
|
+
},
|
134
|
+
"url": "http://barton.experimentsindemocracy.org/api/members/207190"
|
101
135
|
}
|
102
136
|
],
|
103
137
|
"resources": {
|
104
138
|
"home": "http://barton.experimentsindemocracy.org",
|
105
139
|
"api": "http://barton.experimentsindemocracy.org/api",
|
106
|
-
"electorates": "http://barton.experimentsindemocracy.org/api/electorates"
|
140
|
+
"electorates": "http://barton.experimentsindemocracy.org/api/electorates",
|
141
|
+
"members": "http://barton.experimentsindemocracy.org/api/members"
|
107
142
|
},
|
108
143
|
"examples": {
|
109
|
-
"
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
"mixed": "http://barton.experimentsindemocracy.org/api/electorates?geo=151.2054563,-33.8438383&tags=federal"
|
114
|
-
}
|
144
|
+
"id": "http://barton.experimentsindemocracy.org/api/members/0db2ec",
|
145
|
+
"geo": "http://barton.experimentsindemocracy.org/api/electorates?geo=151.2054563,-33.8438383",
|
146
|
+
"tags": "http://barton.experimentsindemocracy.org/api/members?tags=sydney,local",
|
147
|
+
"mixed": "http://barton.experimentsindemocracy.org/api/electorates?geo=151.2054563,-33.8438383&tags=federal"
|
115
148
|
}
|
116
149
|
}
|
117
150
|
|
118
|
-
|
119
151
|
## Contributing
|
120
152
|
|
121
|
-
If you want to help then by all means jump in, fork and
|
153
|
+
If you want to help then by all means jump in, fork and send a pull request.
|
122
154
|
|
123
155
|
Updating politician contact details is the most pressing job. See the [data readme][data-readme] for more details.
|
124
156
|
|
125
|
-
[data-readme]:https://github.com/davekinkead/barton/blob/master/data/README.md
|
157
|
+
[data-readme]:https://github.com/davekinkead/barton/blob/master/data/README.md
|
158
|
+
[es]:http://www.elasticsearch.org/
|
data/Rakefile
CHANGED
@@ -4,9 +4,8 @@ require 'rake/testtask'
|
|
4
4
|
require 'barton/core'
|
5
5
|
|
6
6
|
Rake::TestTask.new do |t|
|
7
|
-
|
8
|
-
Barton.
|
9
|
-
#Barton::Data.purge_es
|
7
|
+
Barton.environment = 'test'
|
8
|
+
Barton::Data.purge_es
|
10
9
|
Barton::Data.update_es( Barton::Setup.parse_yaml( 'specs/data/data-processed.yaml' ) )
|
11
10
|
t.libs << "specs"
|
12
11
|
t.test_files = FileList['specs/*_spec.rb']
|
data/TODO.md
ADDED
data/barton.gemspec
CHANGED
@@ -10,15 +10,18 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.homepage = "http://barton.experimentsindemocracy.org"
|
11
11
|
s.description = "Barton is an API for Australian electorates and politicains"
|
12
12
|
s.summary = "Programmable political access"
|
13
|
-
|
13
|
+
|
14
14
|
s.rubyforge_project = "barton"
|
15
15
|
|
16
16
|
s.files = `git ls-files`.split("\n")
|
17
17
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
18
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
19
|
s.require_paths = ["lib"]
|
20
|
-
|
20
|
+
|
21
21
|
s.add_dependency 'sinatra', '~> 1.3.2'
|
22
22
|
s.add_dependency 'tire', '~> 0.4.2'
|
23
23
|
s.add_dependency 'json'
|
24
|
+
s.add_dependency 'newrelic_rpm' # only required on heroku to stop idling
|
25
|
+
s.add_dependency 'rack-test' # only for testing
|
26
|
+
s.add_dependency 'trollop'
|
24
27
|
end
|
data/bin/barton
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
require 'barton/app'
|
3
|
+
require 'trollop'
|
3
4
|
|
4
|
-
|
5
|
-
|
5
|
+
opts = Trollop::options do
|
6
|
+
opt :setup, "Configure and update database as <s>", :type => :string # flag --setup, string required
|
7
|
+
opt :run, "Run Baront as a webapp", :type => :string # flag --run, default 'development'
|
8
|
+
end
|
9
|
+
|
10
|
+
if opts[:run]
|
11
|
+
Barton.environment = opts[:run]
|
12
|
+
puts "Running Barton as #{Barton.environment}"
|
13
|
+
Barton.environment = opts[:run]
|
14
|
+
Barton::App.run!
|
15
|
+
elsif opts[:setup]
|
16
|
+
Barton.environment = opts[:setup]
|
17
|
+
puts "Seting up Barton as #{Barton.environment}"
|
18
|
+
Barton.environment = opts[:setup]
|
19
|
+
Barton.setup
|
20
|
+
end
|
data/config.ru
CHANGED
data/data/nsw-state.yaml
CHANGED
data/data/qld-state.yaml
CHANGED
@@ -6,9 +6,99 @@
|
|
6
6
|
- Legislative Assembly
|
7
7
|
members:
|
8
8
|
- name: Campbell Newman
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
role: Premier
|
10
|
+
party: LNP
|
11
|
+
address: Level 15, Executive Building, 100 George Street, Brisbane Qld 4000
|
12
|
+
email: thepremier@premiers.qld.gov.au
|
13
|
+
phone: 07 3224 4500
|
14
|
+
fax: 07 3221 1809
|
15
|
+
id: 0db2ec
|
16
|
+
- name: Jeff Seeney
|
17
|
+
role: Deputy Premier and Minister for State Development, Infrastructure and Planning
|
18
|
+
email: deputypremier@ministerial.qld.gov.au
|
19
|
+
phone: (07) 3224 4600
|
20
|
+
fax: (07) 3224 2490
|
21
|
+
web: http://www.parliament.qld.gov.au/members/current/list/bio?member=Seeney+Jeffrey
|
22
|
+
address: Level 12, Executive Building, 100 George Street, BRISBANE QLD 4000
|
23
|
+
id: f5deb4
|
24
|
+
- name: Tim Nicholls
|
25
|
+
party: LNP
|
26
|
+
role: Member for Queensland
|
27
|
+
id: 4f5f3b
|
28
|
+
- name: Lawrence Springborg
|
29
|
+
party: LNP
|
30
|
+
role: Member for Queensland
|
31
|
+
id: 4f5f3b
|
32
|
+
- name: John-Paul Langbroek
|
33
|
+
party: LNP
|
34
|
+
role: Member for Queensland
|
35
|
+
id: 4f5f3b
|
36
|
+
- name: Jack Dempsey
|
37
|
+
party: LNP
|
38
|
+
role: Member for Queensland
|
39
|
+
id: 4f5f3b
|
40
|
+
- name: Jarrod Bleijie
|
41
|
+
party: LNP
|
42
|
+
role: Member for Queensland
|
43
|
+
id: 4f5f3b
|
44
|
+
- name: Scott Emerson
|
45
|
+
party: LNP
|
46
|
+
role: Minister for Transport and Main Roads
|
47
|
+
phone: (07) 3237 1111
|
48
|
+
fax: (07) 3224 2493
|
49
|
+
email: transportandmainRoads@ministerial.qld.gov.au
|
50
|
+
web: http://www.parliament.qld.gov.au/members/current/list/bio?member=Emerson+Scott
|
51
|
+
address: Level 15, Capital Hill, 85 George Street, BRISBANE QLD 4000
|
52
|
+
id: 96a1e9
|
53
|
+
- name: Bruce Flegg
|
54
|
+
party: LNP
|
55
|
+
role: Member for Queensland
|
56
|
+
id: 4f5f3b
|
57
|
+
- name: John McVeigh
|
58
|
+
party: LNP
|
59
|
+
role: Member for Queensland
|
60
|
+
id: 4f5f3b
|
61
|
+
- name: Andrew Powell
|
62
|
+
party: LNP
|
63
|
+
role: Member for Queensland
|
64
|
+
id: 4f5f3b
|
65
|
+
- name: Andrew Cripps
|
66
|
+
party: LNP
|
67
|
+
role: Member for Queensland
|
68
|
+
id: 4f5f3b
|
69
|
+
- name: Mark McArdle
|
70
|
+
party: LNP
|
71
|
+
role: Member for Queensland
|
72
|
+
id: 4f5f3b
|
73
|
+
- name: David Crisafulli
|
74
|
+
party: LNP
|
75
|
+
role: Member for Queensland
|
76
|
+
id: 4f5f3b
|
77
|
+
- name: Tracy Davis
|
78
|
+
role: Member for Queensland
|
79
|
+
id: 4f5f3b
|
80
|
+
- name: Ros Bates
|
81
|
+
party: LNP
|
82
|
+
role: Minister for Science, Information Technology, Innovation and the Arts
|
83
|
+
address: Level 5, Executive Building, 100 George Street Brisbane Qld 4000
|
84
|
+
phone: 07 3224 2880
|
85
|
+
fax: 07 3224 2492
|
86
|
+
email: ScienceandIT@ministerial.qld.gov.au
|
87
|
+
id: c1b232
|
88
|
+
- name: Steven Dickson
|
89
|
+
party: LNP
|
90
|
+
role: Member for Queensland
|
91
|
+
id: 4f5f3b
|
92
|
+
- name: Jann Stuckey
|
93
|
+
party: LNP
|
94
|
+
role: Member for Queensland
|
95
|
+
id: 4f5f3b
|
96
|
+
- name: Glen Elmes
|
97
|
+
party: LNP
|
98
|
+
role: Member for Queensland
|
99
|
+
id: 4f5f3b
|
100
|
+
id: !binary |-
|
101
|
+
MDNkNDIw
|
12
102
|
- name: Ashgrove
|
13
103
|
tags:
|
14
104
|
- Queensland
|
@@ -18,13 +108,14 @@
|
|
18
108
|
id: e07a89
|
19
109
|
members:
|
20
110
|
- name: Campbell Newman
|
21
|
-
|
22
|
-
|
111
|
+
party: LNP
|
112
|
+
role: Member for Ashgrove
|
23
113
|
email: ashgrove@parliament.qld.gov.au
|
24
114
|
phone: 07 3366 6000
|
25
115
|
web: http://www.parliament.qld.gov.au/members/current/list/bio?member=Newman+Campbell
|
26
116
|
post: PO Box 40, Ashgrove Q 4060
|
27
117
|
address: Ashgrove Central, 221 Waterworks Road, Ashgrove
|
118
|
+
id: '207190'
|
28
119
|
- name: Aspley
|
29
120
|
tags:
|
30
121
|
- Queensland
|
@@ -284,6 +375,15 @@
|
|
284
375
|
- Legislative Assembly
|
285
376
|
- Central Queensland
|
286
377
|
id: 2b9415
|
378
|
+
members:
|
379
|
+
- name: Steve Bennett
|
380
|
+
role: Member for Burnett
|
381
|
+
party: LNP
|
382
|
+
address: Shop 7, Bargara Beach Plaza, 15-19 See Street, Bargara Qld 4670
|
383
|
+
email: burnett@parliament.qld.gov.au
|
384
|
+
phone: 07 4159 1988
|
385
|
+
fax: 07 4159 2696
|
386
|
+
id: 80122e
|
287
387
|
- name: Callide
|
288
388
|
tags:
|
289
389
|
- Queensland
|
@@ -361,6 +461,16 @@
|
|
361
461
|
- Legislative Assembly
|
362
462
|
- Gold Coast
|
363
463
|
id: d99586
|
464
|
+
members:
|
465
|
+
- name: Verity Barton
|
466
|
+
role: Member for Broadwater
|
467
|
+
party: LNP
|
468
|
+
address: 102 Imperial Parade, (Cnr Government Rd and Imperial Pde), Labrador Qld
|
469
|
+
4215
|
470
|
+
email: broadwater@parliament.qld.gov.au
|
471
|
+
phone: 07 5563 9010
|
472
|
+
fax: 07 5500 5364
|
473
|
+
id: 42bd72
|
364
474
|
- name: Burleigh
|
365
475
|
tags:
|
366
476
|
- Queensland
|
@@ -403,6 +513,15 @@
|
|
403
513
|
- Legislative Assembly
|
404
514
|
- Gold Coast
|
405
515
|
id: 291a43
|
516
|
+
members:
|
517
|
+
- name: Ros Bates
|
518
|
+
party: LNP
|
519
|
+
address: Mudgeeraba Professional Centre, Swan Lane Mudgeeraba Qld 4213
|
520
|
+
email: mudgeeraba@parliament.qld.gov.au
|
521
|
+
phone: 07 5569 0482
|
522
|
+
fax: 07 5569 0675
|
523
|
+
role: Member for Mudgeeraba
|
524
|
+
id: 9c6e42
|
406
525
|
- name: Southport
|
407
526
|
tags:
|
408
527
|
- Queensland
|
@@ -522,6 +641,15 @@
|
|
522
641
|
- Legislative Assembly
|
523
642
|
- SE Queensland
|
524
643
|
id: '457031'
|
644
|
+
members:
|
645
|
+
- name: Ian Berry
|
646
|
+
role: Member for Ipswich
|
647
|
+
party: LNP
|
648
|
+
address: 125 Brisbane Road, Booval Qld 4304
|
649
|
+
email: ipswich@parliament.qld.gov.au
|
650
|
+
phone: 07 3202 3452
|
651
|
+
fax: 07 3202 4778
|
652
|
+
id: cf0b40
|
525
653
|
- name: Ipswich West
|
526
654
|
tags:
|
527
655
|
- Queensland
|