barton 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/.gitignore +18 -0
  2. data/AUTHORS +7 -0
  3. data/Gemfile +6 -0
  4. data/LICENSE +22 -0
  5. data/README.md +125 -0
  6. data/Rakefile +13 -0
  7. data/barton.gemspec +22 -0
  8. data/bin/barton +38 -0
  9. data/config.ru +4 -0
  10. data/data/.DS_Store +0 -0
  11. data/data/README.md +31 -0
  12. data/data/geo/nsw-federal.yaml +21965 -0
  13. data/data/geo/nsw-local.yaml +95263 -0
  14. data/data/geo/nsw-state.yaml +33353 -0
  15. data/data/geo/qld-federal.yaml +15019 -0
  16. data/data/geo/qld-state.yaml +20997 -0
  17. data/data/geo/vic-federal.yaml +8097 -0
  18. data/data/geo/vic-local.yaml +35686 -0
  19. data/data/geo/vic-state.yaml +14445 -0
  20. data/data/nsw-federal.yaml +337 -0
  21. data/data/nsw-local.yaml +2472 -0
  22. data/data/nsw-state.yaml +663 -0
  23. data/data/qld-federal.yaml +220 -0
  24. data/data/qld-state.yaml +643 -0
  25. data/data/vic-federal.yaml +149 -0
  26. data/data/vic-local.yaml +2255 -0
  27. data/data/vic-state.yaml +665 -0
  28. data/lib/.DS_Store +0 -0
  29. data/lib/barton/.DS_Store +0 -0
  30. data/lib/barton/app.rb +68 -0
  31. data/lib/barton/core.rb +174 -0
  32. data/lib/barton/version.rb +3 -0
  33. data/lib/barton.rb +3 -0
  34. data/pkg/barton-0.0.1.gem +0 -0
  35. data/specs/.DS_Store +0 -0
  36. data/specs/data/.DS_Store +0 -0
  37. data/specs/data/data-processed.yaml +39 -0
  38. data/specs/data/data-raw.yaml +43 -0
  39. data/specs/data/geo/data-processed.yaml +256 -0
  40. data/specs/data/geo/data-raw.yaml +256 -0
  41. data/specs/data/master/data-processed.yaml +39 -0
  42. data/specs/data/master/data-raw.yaml +31 -0
  43. data/specs/data/master/geo.yaml +256 -0
  44. data/specs/data/master/trap.txt +0 -0
  45. data/specs/route_spec.rb +36 -0
  46. data/specs/search_spec.rb +60 -0
  47. data/specs/setup_spec.rb +77 -0
  48. metadata +139 -0
@@ -0,0 +1,665 @@
1
+ ---
2
+ - name: Victoria
3
+ tags:
4
+ - Victoria
5
+ - State
6
+ - Legislative Assembly
7
+ - Legislative Council
8
+ id: f530bf
9
+ - name: Bayswater
10
+ tags:
11
+ - Victoria
12
+ - State
13
+ - Legislative Assembly
14
+ - Eastern Metropolitan
15
+ id: 59889b
16
+ - name: Box Hill
17
+ tags:
18
+ - Victoria
19
+ - State
20
+ - Legislative Assembly
21
+ - Eastern Metropolitan
22
+ id: 67c671
23
+ - name: Bulleen
24
+ tags:
25
+ - Victoria
26
+ - State
27
+ - Legislative Assembly
28
+ - Eastern Metropolitan
29
+ id: 8801ef
30
+ - name: Doncaster
31
+ tags:
32
+ - Victoria
33
+ - State
34
+ - Legislative Assembly
35
+ - Eastern Metropolitan
36
+ id: 45d9b3
37
+ - name: Eltham
38
+ tags:
39
+ - Victoria
40
+ - State
41
+ - Legislative Assembly
42
+ - Eastern Metropolitan
43
+ id: 3bbebe
44
+ - name: Ferntree Gully
45
+ tags:
46
+ - Victoria
47
+ - State
48
+ - Legislative Assembly
49
+ - Eastern Metropolitan
50
+ id: 729deb
51
+ - name: Forest Hill
52
+ tags:
53
+ - Victoria
54
+ - State
55
+ - Legislative Assembly
56
+ - Eastern Metropolitan
57
+ id: '793413'
58
+ - name: Kilsyth
59
+ tags:
60
+ - Victoria
61
+ - State
62
+ - Legislative Assembly
63
+ - Eastern Metropolitan
64
+ id: 4b401b
65
+ - name: Mitcham
66
+ tags:
67
+ - Victoria
68
+ - State
69
+ - Legislative Assembly
70
+ - Eastern Metropolitan
71
+ id: c0d79b
72
+ - name: Scoresby
73
+ tags:
74
+ - Victoria
75
+ - State
76
+ - Legislative Assembly
77
+ - Eastern Metropolitan
78
+ id: cadd59
79
+ - name: Warrandyte
80
+ tags:
81
+ - Victoria
82
+ - State
83
+ - Legislative Assembly
84
+ - Eastern Metropolitan
85
+ id: 8254a5
86
+ - name: Bass
87
+ tags:
88
+ - Victoria
89
+ - State
90
+ - Legislative Assembly
91
+ - Eastern Victoria
92
+ id: 04dd17
93
+ - name: Evelyn
94
+ tags:
95
+ - Victoria
96
+ - State
97
+ - Legislative Assembly
98
+ - Eastern Victoria
99
+ id: 8ce3f9
100
+ - name: Gembrook
101
+ tags:
102
+ - Victoria
103
+ - State
104
+ - Legislative Assembly
105
+ - Eastern Victoria
106
+ id: 3cd4ce
107
+ - name: Gippsland East
108
+ tags:
109
+ - Victoria
110
+ - State
111
+ - Legislative Assembly
112
+ - Eastern Victoria
113
+ id: d05fec
114
+ - name: Gippsland South
115
+ tags:
116
+ - Victoria
117
+ - State
118
+ - Legislative Assembly
119
+ - Eastern Victoria
120
+ id: 84ab70
121
+ - name: Hastings
122
+ tags:
123
+ - Victoria
124
+ - State
125
+ - Legislative Assembly
126
+ - Eastern Victoria
127
+ id: 874dbc
128
+ - name: Monbulk
129
+ tags:
130
+ - Victoria
131
+ - State
132
+ - Legislative Assembly
133
+ - Eastern Victoria
134
+ id: 50910e
135
+ - name: Mornington
136
+ tags:
137
+ - Victoria
138
+ - State
139
+ - Legislative Assembly
140
+ - Eastern Victoria
141
+ id: 7f45a9
142
+ - name: Morwell
143
+ tags:
144
+ - Victoria
145
+ - State
146
+ - Legislative Assembly
147
+ - Eastern Victoria
148
+ id: 7cef33
149
+ - name: Narracan
150
+ tags:
151
+ - Victoria
152
+ - State
153
+ - Legislative Assembly
154
+ - Eastern Victoria
155
+ id: d1e277
156
+ - name: Nepean
157
+ tags:
158
+ - Victoria
159
+ - State
160
+ - Legislative Assembly
161
+ - Eastern Victoria
162
+ id: 4d94b9
163
+ - name: Broadmeadows
164
+ tags:
165
+ - Victoria
166
+ - State
167
+ - Legislative Assembly
168
+ - Northern Metropolitan
169
+ id: 553d97
170
+ - name: Brunswick
171
+ tags:
172
+ - Victoria
173
+ - State
174
+ - Legislative Assembly
175
+ - Northern Metropolitan
176
+ id: da97f6
177
+ - name: Bundoora
178
+ tags:
179
+ - Victoria
180
+ - State
181
+ - Legislative Assembly
182
+ - Northern Metropolitan
183
+ id: '378493'
184
+ - name: Ivanhoe
185
+ tags:
186
+ - Victoria
187
+ - State
188
+ - Legislative Assembly
189
+ - Northern Metropolitan
190
+ id: 172c74
191
+ - name: Melbourne
192
+ tags:
193
+ - Victoria
194
+ - State
195
+ - Legislative Assembly
196
+ - Northern Metropolitan
197
+ id: e2ee35
198
+ - name: Mill Park
199
+ tags:
200
+ - Victoria
201
+ - State
202
+ - Legislative Assembly
203
+ - Northern Metropolitan
204
+ id: f01b67
205
+ - name: Northcote
206
+ tags:
207
+ - Victoria
208
+ - State
209
+ - Legislative Assembly
210
+ - Northern Metropolitan
211
+ id: e470f1
212
+ - name: Preston
213
+ tags:
214
+ - Victoria
215
+ - State
216
+ - Legislative Assembly
217
+ - Northern Metropolitan
218
+ id: 028d23
219
+ - name: Richmond
220
+ tags:
221
+ - Victoria
222
+ - State
223
+ - Legislative Assembly
224
+ - Northern Metropolitan
225
+ id: 8df19c
226
+ - name: Thomastown
227
+ tags:
228
+ - Victoria
229
+ - State
230
+ - Legislative Assembly
231
+ - Northern Metropolitan
232
+ id: eda02b
233
+ - name: Yan Yean
234
+ tags:
235
+ - Victoria
236
+ - State
237
+ - Legislative Assembly
238
+ - Northern Metropolitan
239
+ id: 52d100
240
+ - name: Benalla
241
+ tags:
242
+ - Victoria
243
+ - State
244
+ - Legislative Assembly
245
+ - Northern Victoria
246
+ id: b4306a
247
+ - name: Benambra
248
+ tags:
249
+ - Victoria
250
+ - State
251
+ - Legislative Assembly
252
+ - Northern Victoria
253
+ id: '472910'
254
+ - name: Bendigo East
255
+ tags:
256
+ - Victoria
257
+ - State
258
+ - Legislative Assembly
259
+ - Northern Victoria
260
+ id: e7318e
261
+ - name: Bendigo West
262
+ tags:
263
+ - Victoria
264
+ - State
265
+ - Legislative Assembly
266
+ - Northern Victoria
267
+ id: '589761'
268
+ - name: Macedon
269
+ tags:
270
+ - Victoria
271
+ - State
272
+ - Legislative Assembly
273
+ - Northern Victoria
274
+ id: cec85b
275
+ - name: Mildura
276
+ tags:
277
+ - Victoria
278
+ - State
279
+ - Legislative Assembly
280
+ - Northern Victoria
281
+ id: d0f3db
282
+ - name: Murray Valley
283
+ tags:
284
+ - Victoria
285
+ - State
286
+ - Legislative Assembly
287
+ - Northern Victoria
288
+ id: 56bd2e
289
+ - name: Rodney
290
+ tags:
291
+ - Victoria
292
+ - State
293
+ - Legislative Assembly
294
+ - Northern Victoria
295
+ id: da9f12
296
+ - name: Seymour
297
+ tags:
298
+ - Victoria
299
+ - State
300
+ - Legislative Assembly
301
+ - Northern Victoria
302
+ id: '433406'
303
+ - name: Shepparton
304
+ tags:
305
+ - Victoria
306
+ - State
307
+ - Legislative Assembly
308
+ - Northern Victoria
309
+ id: 6a5252
310
+ - name: Swan Hill
311
+ tags:
312
+ - Victoria
313
+ - State
314
+ - Legislative Assembly
315
+ - Northern Victoria
316
+ id: 78b0f2
317
+ - name: Carrum
318
+ tags:
319
+ - Victoria
320
+ - State
321
+ - Legislative Assembly
322
+ - South Eastern Metropolitan
323
+ id: 2d1579
324
+ - name: Clayton
325
+ tags:
326
+ - Victoria
327
+ - State
328
+ - Legislative Assembly
329
+ - South Eastern Metropolitan
330
+ id: ac8cbb
331
+ - name: Cranbourne
332
+ tags:
333
+ - Victoria
334
+ - State
335
+ - Legislative Assembly
336
+ - South Eastern Metropolitan
337
+ id: 2fe03c
338
+ - name: Dandenong
339
+ tags:
340
+ - Victoria
341
+ - State
342
+ - Legislative Assembly
343
+ - South Eastern Metropolitan
344
+ id: 08b75b
345
+ - name: Frankston
346
+ tags:
347
+ - Victoria
348
+ - State
349
+ - Legislative Assembly
350
+ - South Eastern Metropolitan
351
+ id: '701e74'
352
+ - name: Lyndhurst
353
+ tags:
354
+ - Victoria
355
+ - State
356
+ - Legislative Assembly
357
+ - South Eastern Metropolitan
358
+ id: 11c78a
359
+ - name: Mordialloc
360
+ tags:
361
+ - Victoria
362
+ - State
363
+ - Legislative Assembly
364
+ - South Eastern Metropolitan
365
+ id: 059d7d
366
+ - name: Mount Waverley
367
+ tags:
368
+ - Victoria
369
+ - State
370
+ - Legislative Assembly
371
+ - South Eastern Metropolitan
372
+ id: 18e23a
373
+ - name: Mulgrave
374
+ tags:
375
+ - Victoria
376
+ - State
377
+ - Legislative Assembly
378
+ - South Eastern Metropolitan
379
+ id: c0d5e9
380
+ - name: Narre Warren North
381
+ tags:
382
+ - Victoria
383
+ - State
384
+ - Legislative Assembly
385
+ - South Eastern Metropolitan
386
+ id: 29e21d
387
+ - name: Narre Warren South
388
+ tags:
389
+ - Victoria
390
+ - State
391
+ - Legislative Assembly
392
+ - South Eastern Metropolitan
393
+ id: 4861c9
394
+ - name: Albert Park
395
+ tags:
396
+ - Victoria
397
+ - State
398
+ - Legislative Assembly
399
+ - Southern Metropolitan
400
+ id: b46389
401
+ - name: Bentleigh
402
+ tags:
403
+ - Victoria
404
+ - State
405
+ - Legislative Assembly
406
+ - Southern Metropolitan
407
+ id: b327e4
408
+ - name: Brighton
409
+ tags:
410
+ - Victoria
411
+ - State
412
+ - Legislative Assembly
413
+ - Southern Metropolitan
414
+ id: 7180df
415
+ - name: Burwood
416
+ tags:
417
+ - Victoria
418
+ - State
419
+ - Legislative Assembly
420
+ - Southern Metropolitan
421
+ id: e5187f
422
+ - name: Caulfield
423
+ tags:
424
+ - Victoria
425
+ - State
426
+ - Legislative Assembly
427
+ - Southern Metropolitan
428
+ id: eb814f
429
+ - name: Hawthorn
430
+ tags:
431
+ - Victoria
432
+ - State
433
+ - Legislative Assembly
434
+ - Southern Metropolitan
435
+ id: 02b53a
436
+ - name: Kew
437
+ tags:
438
+ - Victoria
439
+ - State
440
+ - Legislative Assembly
441
+ - Southern Metropolitan
442
+ id: 9b1158
443
+ - name: Malvern
444
+ tags:
445
+ - Victoria
446
+ - State
447
+ - Legislative Assembly
448
+ - Southern Metropolitan
449
+ id: 8e42bb
450
+ - name: Oakleigh
451
+ tags:
452
+ - Victoria
453
+ - State
454
+ - Legislative Assembly
455
+ - Southern Metropolitan
456
+ id: 1a4fcf
457
+ - name: Prahran
458
+ tags:
459
+ - Victoria
460
+ - State
461
+ - Legislative Assembly
462
+ - Southern Metropolitan
463
+ id: 55f92e
464
+ - name: Sandringham
465
+ tags:
466
+ - Victoria
467
+ - State
468
+ - Legislative Assembly
469
+ - Southern Metropolitan
470
+ id: 6a4c05
471
+ - name: Altona
472
+ tags:
473
+ - Victoria
474
+ - State
475
+ - Legislative Assembly
476
+ - Western Metropolitan
477
+ id: 67b04d
478
+ - name: Derrimut
479
+ tags:
480
+ - Victoria
481
+ - State
482
+ - Legislative Assembly
483
+ - Western Metropolitan
484
+ id: 8e06ba
485
+ - name: Essendon
486
+ tags:
487
+ - Victoria
488
+ - State
489
+ - Legislative Assembly
490
+ - Western Metropolitan
491
+ id: 4a2dd5
492
+ - name: Footscray
493
+ tags:
494
+ - Victoria
495
+ - State
496
+ - Legislative Assembly
497
+ - Western Metropolitan
498
+ id: e307a6
499
+ - name: Keilor
500
+ tags:
501
+ - Victoria
502
+ - State
503
+ - Legislative Assembly
504
+ - Western Metropolitan
505
+ id: f6036b
506
+ - name: Kororoit
507
+ tags:
508
+ - Victoria
509
+ - State
510
+ - Legislative Assembly
511
+ - Western Metropolitan
512
+ id: 5927a0
513
+ - name: Niddrie
514
+ tags:
515
+ - Victoria
516
+ - State
517
+ - Legislative Assembly
518
+ - Western Metropolitan
519
+ id: aedfec
520
+ - name: Pascoe Vale
521
+ tags:
522
+ - Victoria
523
+ - State
524
+ - Legislative Assembly
525
+ - Western Metropolitan
526
+ id: fb96ea
527
+ - name: Tarneit
528
+ tags:
529
+ - Victoria
530
+ - State
531
+ - Legislative Assembly
532
+ - Western Metropolitan
533
+ id: 61f8e9
534
+ - name: Williamstown
535
+ tags:
536
+ - Victoria
537
+ - State
538
+ - Legislative Assembly
539
+ - Western Metropolitan
540
+ id: 692fa9
541
+ - name: Yuroke
542
+ tags:
543
+ - Victoria
544
+ - State
545
+ - Legislative Assembly
546
+ - Western Metropolitan
547
+ id: 011b77
548
+ - name: Ballarat East
549
+ tags:
550
+ - Victoria
551
+ - State
552
+ - Legislative Assembly
553
+ - Western Victoria
554
+ id: bd0054
555
+ - name: Ballarat West
556
+ tags:
557
+ - Victoria
558
+ - State
559
+ - Legislative Assembly
560
+ - Western Victoria
561
+ id: 37ced5
562
+ - name: Bellarine
563
+ tags:
564
+ - Victoria
565
+ - State
566
+ - Legislative Assembly
567
+ - Western Victoria
568
+ id: c449b9
569
+ - name: Geelong
570
+ tags:
571
+ - Victoria
572
+ - State
573
+ - Legislative Assembly
574
+ - Western Victoria
575
+ id: caa87b
576
+ - name: Lara
577
+ tags:
578
+ - Victoria
579
+ - State
580
+ - Legislative Assembly
581
+ - Western Victoria
582
+ id: d4b357
583
+ - name: Lowan
584
+ tags:
585
+ - Victoria
586
+ - State
587
+ - Legislative Assembly
588
+ - Western Victoria
589
+ id: decc8c
590
+ - name: Melton
591
+ tags:
592
+ - Victoria
593
+ - State
594
+ - Legislative Assembly
595
+ - Western Victoria
596
+ id: e4f6e8
597
+ - name: Polwarth
598
+ tags:
599
+ - Victoria
600
+ - State
601
+ - Legislative Assembly
602
+ - Western Victoria
603
+ id: 30048f
604
+ - name: Ripon
605
+ tags:
606
+ - Victoria
607
+ - State
608
+ - Legislative Assembly
609
+ - Western Victoria
610
+ id: ac13b2
611
+ - name: South Barwon
612
+ tags:
613
+ - Victoria
614
+ - State
615
+ - Legislative Assembly
616
+ - Western Victoria
617
+ id: 4a417b
618
+ - name: South-West Coast
619
+ tags:
620
+ - Victoria
621
+ - State
622
+ - Legislative Council
623
+ id: 4561df
624
+ - name: Eastern Victoria
625
+ tags:
626
+ - Victoria
627
+ - State
628
+ - Legislative Council
629
+ id: 6f460c
630
+ - name: Northern Metropolitan
631
+ tags:
632
+ - Victoria
633
+ - State
634
+ - Legislative Council
635
+ id: 302a46
636
+ - name: Northern Victoria
637
+ tags:
638
+ - Victoria
639
+ - State
640
+ - Legislative Council
641
+ id: 783a0b
642
+ - name: South Eastern Metropolitan
643
+ tags:
644
+ - Victoria
645
+ - State
646
+ - Legislative Council
647
+ id: de7027
648
+ - name: Southern Metropolitan
649
+ tags:
650
+ - Victoria
651
+ - State
652
+ - Legislative Council
653
+ id: bed58e
654
+ - name: Western Metropolitan
655
+ tags:
656
+ - Victoria
657
+ - State
658
+ - Legislative Council
659
+ id: d74e56
660
+ - name: Western Victoria
661
+ tags:
662
+ - Victoria
663
+ - State
664
+ - Legislative Council
665
+ id: f732a2
data/lib/.DS_Store ADDED
Binary file
Binary file
data/lib/barton/app.rb ADDED
@@ -0,0 +1,68 @@
1
+ require 'sinatra'
2
+ require 'json'
3
+ require 'barton/core'
4
+
5
+ module Barton
6
+ class App < Sinatra::Base
7
+
8
+ # routes
9
+ allowed_formats = ['', 'json']
10
+
11
+ get '/' do
12
+ "this is the Barton home page"
13
+ end
14
+
15
+ get '/docs' do
16
+ "this is the docs page"
17
+ end
18
+
19
+ # electorate resource
20
+ get %r{^/api/electorates/?(\w*)/?.?([A-z]*)} do
21
+ id, format = params[:captures]
22
+ geo, tags, address = params[:geo], params[:tags], params[:address]
23
+ tags = tags.split(',') unless tags.nil?
24
+ raise Sinatra::NotFound unless allowed_formats.include?( format )
25
+ geo = Barton::Core.address( address ) if address
26
+ if not id.empty?
27
+ results = Barton::Core.electorates( {:id => id} )
28
+ prepare_response( results )
29
+ elsif geo or tags
30
+ results = Barton::Core.electorates( {:tags => tags, :geo => geo} )
31
+ prepare_response( results )
32
+ else
33
+ prepare_response
34
+ end
35
+ end
36
+
37
+ # base api
38
+ get %r{^/api/?.?([A-z]*)$} do
39
+ prepare_response
40
+ end
41
+
42
+ # views
43
+
44
+ # Prepares and array of results for the API response
45
+ def prepare_response( args=nil )
46
+ # add generic API meta data
47
+ app_url = 'http://barton.experimentsindemocracy.org'
48
+ response = {}
49
+ response[:name] = "Barton API"
50
+ response[:disclaimer] = "This data is crowded sourced and provided free of charge for informational purposes only. No guarantees whatsoever regarding data quality are made excluding its sheer awesomeness."
51
+ response[:license] = "MIT License http://www.opensource.org/licenses/mit-license.php"
52
+ unless args.nil?
53
+ response[:result_count] = args.length
54
+ response[:results] = args
55
+ end
56
+ response[:resources] = { :home => app_url, :api => "#{app_url}/api", :electorates => "#{app_url}/api/electorates" }
57
+ response[:examples] = { :electorates => {
58
+ :resource_id => "#{app_url}/api/electorates/ccbfd1",
59
+ :geo => "#{app_url}/api/electorates?geo=151.2054563,-33.8438383",
60
+ :tags => "#{app_url}/api/electorates?tags=sydney,jurisidction:local",
61
+ :mixed => "#{app_url}/api/electorates?geo=151.2054563,-33.8438383&tags=federal", }}
62
+ # format
63
+ content_type 'application/json;charset=utf-8'
64
+ JSON.pretty_generate( response )
65
+ end
66
+
67
+ end
68
+ end