barton 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,18 +1,5 @@
1
1
  *.gem
2
- *.rbc
3
2
  .bundle
4
- .config
5
- .yardoc
6
- Gemfile.lock
7
- InstalledFiles
8
- _yardoc
9
- coverage
10
- doc/
11
- lib/bundler/man
12
- pkg
13
- rdoc
14
- spec/reports
15
- test/tmp
16
- test/version_tmp
17
- tmp
3
+ pkg/*
18
4
  .DS_Store
5
+ */.DS_Store
data/Gemfile CHANGED
@@ -1,6 +1,4 @@
1
- source 'https://rubygems.org'
1
+ source "http://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in barton.gemspec
4
- gem "tire"
5
- gem "sinatra"
6
- gem "trollop"
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,46 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ barton (0.0.2)
5
+ json
6
+ sinatra (~> 1.3.2)
7
+ tire (~> 0.4.2)
8
+
9
+ GEM
10
+ remote: http://rubygems.org/
11
+ specs:
12
+ activemodel (3.2.6)
13
+ activesupport (= 3.2.6)
14
+ builder (~> 3.0.0)
15
+ activesupport (3.2.6)
16
+ i18n (~> 0.6)
17
+ multi_json (~> 1.0)
18
+ builder (3.0.0)
19
+ hashr (0.0.21)
20
+ i18n (0.6.0)
21
+ json (1.7.3)
22
+ mime-types (1.19)
23
+ multi_json (1.3.6)
24
+ rack (1.4.1)
25
+ rack-protection (1.2.0)
26
+ rack
27
+ rake (0.9.2.2)
28
+ rest-client (1.6.7)
29
+ mime-types (>= 1.16)
30
+ sinatra (1.3.2)
31
+ rack (~> 1.3, >= 1.3.6)
32
+ rack-protection (~> 1.2)
33
+ tilt (~> 1.3, >= 1.3.3)
34
+ tilt (1.3.3)
35
+ tire (0.4.2)
36
+ activemodel (>= 3.0)
37
+ hashr (~> 0.0.19)
38
+ multi_json (~> 1.0)
39
+ rake
40
+ rest-client (~> 1.6)
41
+
42
+ PLATFORMS
43
+ ruby
44
+
45
+ DEPENDENCIES
46
+ barton!
data/Rakefile CHANGED
@@ -1,13 +1,14 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
3
  require 'rake/testtask'
4
- require_relative 'lib/barton/core'
4
+ require 'barton/core'
5
5
 
6
6
  Rake::TestTask.new do |t|
7
7
  ENV['RAKE_ENV'] = 'test'
8
- Barton::Core.purge_es
9
- Barton::Core.update_es( Barton::Core.parse_yaml( 'specs/data/data-processed.yaml' ) )
8
+ Barton.config
9
+ #Barton::Data.purge_es
10
+ Barton::Data.update_es( Barton::Setup.parse_yaml( 'specs/data/data-processed.yaml' ) )
10
11
  t.libs << "specs"
11
12
  t.test_files = FileList['specs/*_spec.rb']
12
- #t.verbose = true
13
+ t.verbose = true
13
14
  end
data/barton.gemspec CHANGED
@@ -1,22 +1,24 @@
1
1
  # -*- encoding: utf-8 -*-
2
- $LOAD_PATH.unshift File.expand_path('../lib', __FILE__)
3
- require 'barton/version'
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "barton/version"
4
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"
5
+ Gem::Specification.new do |s|
6
+ s.name = "barton"
7
+ s.version = Barton::VERSION
8
+ s.authors = ["Dave Kinkead"]
9
+ s.email = ["dave@kinkead.com.au"]
10
+ s.homepage = "http://barton.experimentsindemocracy.org"
11
+ s.description = "Barton is an API for Australian electorates and politicains"
12
+ s.summary = "Programmable political access"
13
+
14
+ s.rubyforge_project = "barton"
11
15
 
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
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
18
20
 
19
- gem.add_dependency 'sinatra', '~> 1.3.2'
20
- gem.add_dependency 'trollop'
21
- gem.add_dependency 'tire', '~> 0.4.2'
21
+ s.add_dependency 'sinatra', '~> 1.3.2'
22
+ s.add_dependency 'tire', '~> 0.4.2'
23
+ s.add_dependency 'json'
22
24
  end
data/bin/barton CHANGED
@@ -1,38 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- require 'trollop'
2
+ require 'barton/app'
3
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
4
+ Barton.setup unless Barton.data_loaded
5
+ Barton::App.run!
data/config.ru CHANGED
@@ -1,4 +1,4 @@
1
- require './bin/barton'
1
+ require 'barton/app'
2
2
 
3
- run baron --setup
4
- run barton
3
+ Barton.setup unless Barton.data_loaded
4
+ run Barton::App
@@ -8292,7 +8292,7 @@ d50f0c:
8292
8292
  south: -34.47949737615293
8293
8293
  east: 151.172
8294
8294
  west: 150.6909
8295
- '3e6642':
8295
+ 3e6642:
8296
8296
  boundaries:
8297
8297
  - 148.1986857989842,-36.79749335278837 148.822,-37.05 149.2,-37.201 149.501,-37.32
8298
8298
  149.976,-37.505 149.978,-37.502 149.974,-37.497 149.977,-37.49300000000001 149.974,-37.483
@@ -89,7 +89,7 @@ ed94a7:
89
89
  south: -34.00280912983876
90
90
  east: 151.271
91
91
  west: 151.2071418887867
92
- '164e15':
92
+ 164e15:
93
93
  boundaries:
94
94
  - 151.2098793825532,-33.85430370756853 151.2097565073364,-33.85420653226068 151.2092845775925,-33.85389973141803
95
95
  151.2087100737579,-33.85345658325163 151.2081149749891,-33.85345651400181 151.2066458308784,-33.85371752872344
@@ -610,7 +610,7 @@ cea83f:
610
610
  south: -33.89010485586012
611
611
  east: 151.1966222696354
612
612
  west: 151.1448841036526
613
- '1e9598':
613
+ 1e9598:
614
614
  boundaries:
615
615
  - 151.1816,-33.9069 151.1782,-33.9005 151.1777999958937,-33.89899999094037 151.1796,-33.8967
616
616
  151.1812,-33.8957 151.1791,-33.891 151.1784,-33.8912 151.1766,-33.8868 151.1721,-33.8876
@@ -7674,7 +7674,7 @@ d8825d:
7674
7674
  south: -32.40874977597339
7675
7675
  east: 151.594
7676
7676
  west: 149.7916
7677
- '039911':
7677
+ 039911:
7678
7678
  boundaries:
7679
7679
  - 153.018,-30.563 153.023,-30.553 153.029,-30.546 153.026,-30.541 153.026,-30.529
7680
7680
  153.029,-30.52 153.03,-30.511 153.032,-30.503 153.032,-30.49800000000001 153.041,-30.476
@@ -23503,7 +23503,7 @@ c008b2:
23503
23503
  south: -36.6898928720222
23504
23504
  east: 149.6025575445871
23505
23505
  west: 148.5385544839686
23506
- '25e836':
23506
+ 25e836:
23507
23507
  boundaries:
23508
23508
  - 150.093,-36.35 150.106,-36.336 150.111,-36.331 150.117,-36.329 150.115,-36.327
23509
23509
  150.119,-36.324 150.123,-36.32100000000001 150.127,-36.32100000000001 150.129,-36.317
@@ -43995,7 +43995,7 @@ f7bb53:
43995
43995
  south: -35.57582205698602
43996
43996
  east: 147.233
43997
43997
  west: 146.3544639667793
43998
- '372e79':
43998
+ 372e79:
43999
43999
  boundaries:
44000
44000
  - 145.4251360552323,-34.44313504542419 145.4223732036359,-34.44352385627402 145.4206048557963,-34.44454178059068
44001
44001
  145.4191324985363,-34.44845689091537 145.4176155935558,-34.44940813098696 145.4150250714548,-34.44938483908386
@@ -49985,7 +49985,7 @@ dac48c:
49985
49985
  south: -33.94484413394265
49986
49986
  east: 151.201695149238
49987
49987
  west: 151.1658157003126
49988
- '093529':
49988
+ 093529:
49989
49989
  boundaries:
49990
49990
  - 151.2142724181714,-33.92442917729746 151.2127296849892,-33.92407249950207 151.2112147324045,-33.92354876407109
49991
49991
  151.201695149238,-33.92218866039233 151.2014125343224,-33.92332968166043 151.1996219941813,-33.92310316907097
@@ -70542,7 +70542,7 @@ d3bd84:
70542
70542
  south: -37.505
70543
70543
  east: 150.084
70544
70544
  west: 149.3564746918378
70545
- '5e7689':
70545
+ 5e7689:
70546
70546
  boundaries:
70547
70547
  - 148.822,-37.05 149.2,-37.201 149.3564746918378,-37.26286208377659 149.4019680784731,-37.11530223851265
70548
70548
  149.3986942156654,-37.02503264542202 149.3976562404854,-37.02218691691137 149.3980273527682,-37.02065623713841
@@ -74203,7 +74203,7 @@ a18a8a:
74203
74203
  south: -34.9074
74204
74204
  east: 148.670388
74205
74205
  west: 148.1421072823724
74206
- '82e381':
74206
+ 82e381:
74207
74207
  boundaries:
74208
74208
  - 149.5679537114042,-36.00857128602338 149.5692664351178,-36.00931912317167 149.5718991823523,-36.00889947295418
74209
74209
  149.5783507832786,-36.00731797609768 149.5830851246774,-36.00754129800762 149.5861222554103,-36.0041434254088
@@ -239,7 +239,7 @@ bcbe3f:
239
239
  south: -33.5829
240
240
  east: 151.3953
241
241
  west: 150.9842
242
- '048630':
242
+ 048630:
243
243
  boundaries:
244
244
  - 151.3933880058075,-33.42832122993632 151.3925158604013,-33.42896383873365 151.3920379919639,-33.42965978926647
245
245
  151.391955865436,-33.43068310003513 151.392002745656,-33.43126750265828 151.3916782742376,-33.43199942560669
@@ -500,7 +500,7 @@ bcbe3f:
500
500
  south: -33.42
501
501
  east: 151.5156462023187
502
502
  west: 151.2970681500458
503
- '82e217':
503
+ 82e217:
504
504
  boundaries:
505
505
  - 151.573,-33.291 151.57,-33.288 151.571,-33.286 151.575,-33.285 151.575,-33.283
506
506
  151.578,-33.283 151.579,-33.281 151.577,-33.28 151.574,-33.281 151.572,-33.279
@@ -581,7 +581,7 @@ bcbe3f:
581
581
  south: -33.36592571411578
582
582
  east: 151.5815683075395
583
583
  west: 151.4025454799637
584
- '164e90':
584
+ 164e90:
585
585
  boundaries:
586
586
  - 151.262,-33.927 151.258,-33.923 151.263,-33.917 151.261,-33.915 151.264,-33.915
587
587
  151.267,-33.916 151.268,-33.915 151.266,-33.91400000000001 151.2665,-33.91400000000001
@@ -5535,7 +5535,7 @@ a9f5da:
5535
5535
  south: -33.816115
5536
5536
  east: 150.982917
5537
5537
  west: 150.9154044189205
5538
- '2e2812':
5538
+ 2e2812:
5539
5539
  boundaries:
5540
5540
  - 150.5493206481002,-33.36613602219403 150.5496629143948,-33.36482391074615 150.5492216189221,-33.363769387072
5541
5541
  150.5481299413434,-33.36344538788779 150.5471710580237,-33.3635214944333 150.5463493120329,-33.36487167633499
@@ -756,7 +756,7 @@ ca48a0:
756
756
  south: -27.70016120734079
757
757
  east: 153.1836
758
758
  west: 153.014871
759
- '087739':
759
+ 087739:
760
760
  boundaries:
761
761
  - 153.003,-27.47500000000001 153.0019,-27.4742 153.001,-27.4741 152.9994,-27.4731
762
762
  153.0003,-27.4723 152.9998,-27.47060000000002 152.9982,-27.46890000000001 152.9987,-27.4685
@@ -11862,7 +11862,7 @@ b3f1de:
11862
11862
  south: -27.741
11863
11863
  east: 153.547
11864
11864
  west: 153.1717
11865
- '081148':
11865
+ 081148:
11866
11866
  boundaries:
11867
11867
  - 153.261725,-27.799102 153.2629289965241,-27.80192351725872 153.2657146583228,-27.80599610737931
11868
11868
  153.2679704120473,-27.80846343858932 153.2725273888082,-27.81210632113799 153.2955427281062,-27.82395787584578
@@ -1962,7 +1962,7 @@ fb9318:
1962
1962
  south: -27.54028743523276
1963
1963
  east: 153.094011955625
1964
1964
  west: 153.040181
1965
- '009702':
1965
+ 009702:
1966
1966
  boundaries:
1967
1967
  - 152.988,-27.5702 152.9871,-27.5695 152.9867,-27.5687 152.987,-27.5684 152.9887,-27.5686
1968
1968
  152.9905,-27.5682 152.9891,-27.5673 152.9894,-27.567 152.9903,-27.5672 152.9908,-27.5668
@@ -15477,7 +15477,7 @@ a100d2:
15477
15477
  south: -27.678538
15478
15478
  east: 152.8292563162398
15479
15479
  west: 152.719331864359
15480
- '769e84':
15480
+ 769e84:
15481
15481
  boundaries:
15482
15482
  - 152.8562,-27.5826 152.8555,-27.5804 152.8554,-27.57880000000002 152.854,-27.5754
15483
15483
  152.8534,-27.5736 152.8519,-27.5705 152.8514,-27.5699 152.8501,-27.567 152.8495,-27.5645
@@ -2841,7 +2841,7 @@ e8b8ca:
2841
2841
  south: -37.6294
2842
2842
  east: 148.221
2843
2843
  west: 145.1627806620593
2844
- '9e0246':
2844
+ 9e0246:
2845
2845
  boundaries:
2846
2846
  - 145.2248433248994,-37.45825644965087 145.2300829046973,-37.45917170599739 145.226898429695,-37.45338295888819
2847
2847
  145.2302186483618,-37.45064843556249 145.2306314572769,-37.44843872600255 145.2335817271366,-37.44668645648983
@@ -2841,7 +2841,7 @@ d66b65:
2841
2841
  south: -37.8345
2842
2842
  east: 145.0453
2843
2843
  west: 144.9615544156226
2844
- '9890e8':
2844
+ 9890e8:
2845
2845
  boundaries:
2846
2846
  - 145.143,-37.6868 145.1437,-37.6826 145.1375,-37.6831 145.1305,-37.686 145.1223,-37.6868
2847
2847
  145.1188,-37.6874 145.1168,-37.6879 145.1104,-37.6909 145.1045,-37.6922 145.0997,-37.69240000000001
@@ -10467,7 +10467,7 @@ baa428:
10467
10467
  south: -37.2245
10468
10468
  east: 142.574
10469
10469
  west: 141.6574079930136
10470
- '086695':
10470
+ 086695:
10471
10471
  boundaries:
10472
10472
  - 142.507,-34.749 142.508,-34.746 142.513,-34.743 142.512,-34.741 142.502,-34.741
10473
10473
  142.5,-34.739 142.502,-34.733 142.512,-34.723 142.513,-34.72 142.509,-34.714 142.519,-34.704
@@ -18812,7 +18812,7 @@ d41c8b:
18812
18812
  south: -38.30038778184499
18813
18813
  east: 145.1287275785401
18814
18814
  west: 144.9953671705406
18815
- '756e19':
18815
+ 756e19:
18816
18816
  boundaries:
18817
18817
  - 145.185,-38.372 145.193,-38.373 145.194,-38.367 145.196,-38.367 145.2,-38.37 145.201,-38.374
18818
18818
  145.209,-38.376 145.211,-38.379 145.215,-38.38000000000001 145.222,-38.378 145.222,-38.375
@@ -20711,7 +20711,7 @@ b94797:
20711
20711
  south: -37.8929
20712
20712
  east: 145.2003
20713
20713
  west: 145.1457
20714
- '63e668':
20714
+ 63e668:
20715
20715
  boundaries:
20716
20716
  - 145.1314,-37.8576 145.1140320879415,-37.85559805547781 145.0950896639592,-37.85334558648473
20717
20717
  145.0921,-37.8706 145.0921808241841,-37.87181188936618 145.0922,-37.8721 145.0905,-37.88190000000001
@@ -30925,7 +30925,7 @@ b981c0:
30925
30925
  south: -36.48287656187399
30926
30926
  east: 143.2952143388028
30927
30927
  west: 142.6008165240712
30928
- '2e9375':
30928
+ 2e9375:
30929
30929
  boundaries:
30930
30930
  - 142.1657419725659,-36.43254860379932 142.1649305804999,-36.36625649707261 142.1685113158012,-36.36626590588421
30931
30931
  142.1685193895224,-36.28849981650542 142.1506251964688,-36.30117920487832 142.1317362092689,-36.30758117399162
@@ -7397,7 +7397,7 @@ ac8cbb:
7397
7397
  south: -38.0037
7398
7398
  east: 145.2656055162517
7399
7399
  west: 145.1816539788258
7400
- '701e74':
7400
+ 701e74:
7401
7401
  boundaries:
7402
7402
  - 145.1692210302088,-38.156070985585 145.1730037273379,-38.14845256970227 145.1735840440754,-38.14445776748263
7403
7403
  145.1743369330139,-38.13524332411645 145.1629024721805,-38.13209801849608 145.1636105728066,-38.12782954738623
@@ -173,7 +173,7 @@
173
173
  - Federal
174
174
  - House of Representitives
175
175
  - Southern NSW
176
- id: '3e6642'
176
+ id: 3e6642
177
177
  - name: Gilmore
178
178
  tags:
179
179
  - New South Wales
data/data/nsw-local.yaml CHANGED
@@ -19,7 +19,7 @@
19
19
  - Local
20
20
  - LGA
21
21
  - Eastern Suburbs
22
- id: '164e15'
22
+ id: 164e15
23
23
  - name: Waverley
24
24
  tags:
25
25
  - New South Wales
@@ -75,7 +75,7 @@
75
75
  - Local
76
76
  - LGA
77
77
  - Inner West
78
- id: '1e9598'
78
+ id: 1e9598
79
79
  - name: Strathfield
80
80
  tags:
81
81
  - New South Wales
@@ -383,7 +383,7 @@
383
383
  - Local
384
384
  - LGA
385
385
  - Mid-North Coast
386
- id: '039911'
386
+ id: 039911
387
387
  - name: Clarence Valley
388
388
  tags:
389
389
  - New South Wales
@@ -628,7 +628,7 @@
628
628
  - Local
629
629
  - LGA
630
630
  - South-Eastern NSW
631
- id: '25e836'
631
+ id: 25e836
632
632
  - name: Goulburn Mulwaree
633
633
  tags:
634
634
  - New South Wales
@@ -964,7 +964,7 @@
964
964
  - Local
965
965
  - LGA
966
966
  - Murrumbidgee
967
- id: '372e79'
967
+ id: 372e79
968
968
  - name: Narrandera
969
969
  tags:
970
970
  - New South Wales
@@ -1097,7 +1097,7 @@
1097
1097
  - Local
1098
1098
  - Ward
1099
1099
  - Botany Bay
1100
- id: '093529'
1100
+ id: 093529
1101
1101
  - name: Botany Bay 6
1102
1102
  tags:
1103
1103
  - New South Wales
@@ -2091,7 +2091,7 @@
2091
2091
  - Local
2092
2092
  - Ward
2093
2093
  - South-Eastern NSW
2094
- id: '5e7689'
2094
+ id: 5e7689
2095
2095
  - name: Boorowa
2096
2096
  tags:
2097
2097
  - New South Wales
@@ -2133,7 +2133,7 @@
2133
2133
  - Local
2134
2134
  - Ward
2135
2135
  - South-Eastern NSW
2136
- id: '82e381'
2136
+ id: 82e381
2137
2137
  - name: Queanbeyan
2138
2138
  tags:
2139
2139
  - New South Wales