barton 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,77 @@
1
+ require 'minitest/spec'
2
+ require 'minitest/autorun'
3
+ require 'barton/core'
4
+
5
+ describe Barton::Core do
6
+ describe "parse_yaml" do
7
+ before :each do
8
+ FileUtils.rm( 'specs/data/tmp.yaml' ) if File.exist?( 'specs/data/tmp.yaml' )
9
+ FileUtils.cp( 'specs/data/master/geo.yaml', 'specs/data/geo/data-processed.yaml' )
10
+ FileUtils.cp( 'specs/data/master/data-raw.yaml', 'specs/data/data-raw.yaml' )
11
+ FileUtils.cp( 'specs/data/master/data-processed.yaml', 'specs/data/data-processed.yaml' )
12
+ end
13
+
14
+ it "should accept a yaml file and return an array" do
15
+ electorates = Barton::Core.parse_yaml( 'specs/data/data-raw.yaml' )
16
+ electorates.must_be_instance_of Array
17
+ end
18
+
19
+ it "should only accept a yaml files" do
20
+ Barton::Core.parse_yaml( 'spects/data/asfasds.xml' ).must_be_nil
21
+ end
22
+
23
+ it "should parse yaml data" do
24
+ electorates = Barton::Core.parse_yaml( 'specs/data/data-raw.yaml' )
25
+ electorates.length.must_equal 5
26
+ electorates[0]['name'].must_equal 'Queensland'
27
+ electorates[1]['tags'][1].must_equal 'State'
28
+ end
29
+
30
+ it "should create an id if none exists" do
31
+ electorates = Barton::Core.parse_yaml( 'specs/data/data-raw.yaml' )
32
+ electorates[1]['id'].must_equal 'e07a89'
33
+ electorates[0]['id'].must_equal '83a0a8'
34
+ electorates = Barton::Core.parse_yaml( 'specs/data/data-processed.yaml' )
35
+ electorates[0]['id'].must_equal 'e07a89'
36
+ electorates[3]['id'].must_equal '801187'
37
+
38
+ end
39
+
40
+ it "should make geobox" do
41
+ electorates = Barton::Core.parse_yaml( 'specs/data/data-raw.yaml' )
42
+ electorates[1].has_key?( 'geobox' ).must_equal true
43
+ electorates[2]['geobox']['north'].must_equal -27.28691721973524
44
+ end
45
+
46
+ it "should find associated geo.yaml file if present" do
47
+ electorates = Barton::Core.parse_yaml( 'specs/data/data-processed.yaml' )
48
+ electorates[0]['id'].must_equal 'e07a89'
49
+ electorates[1]['geobox']['south'].must_equal -27.389226
50
+ end
51
+ end
52
+
53
+ describe 'create_geobox' do
54
+ before do
55
+ @boundaries = ['153.0557,-27.5257 153.0565,-27.5271 153.057,-27.5287 153.0588,-27.5382 153.0592,-27.5382 153.0599,-27.54060000000001,0 153.061,27.5427 153.0625,-27.5448 153.0671,-27.54980000000001 153.0688,-27.5523', '-153.0671,-27.54980000000001,0', '0,0,0 50,50,0' ]
56
+ end
57
+
58
+ it "should only accept a array of boundaries" do
59
+ Barton::Core.create_geobox( 'hi' ).must_be_nil
60
+ Barton::Core.create_geobox( @boundaries ).must_be_instance_of Hash
61
+ end
62
+
63
+ it "should create a geobox for the boundaries provided" do
64
+ box = Barton::Core.create_geobox( @boundaries )
65
+ box.has_key?( 'south' ).must_equal true
66
+ box['north'].must_equal 50.0
67
+ box['south'].must_equal -27.5523
68
+ end
69
+
70
+ it "should save geo data in the geo dir" do
71
+ Barton::Core.parse_yaml( 'specs/data/data-raw.yaml' )
72
+ File.open( 'specs/data/data-raw.yaml' ).grep( /id:/ ).length.must_equal 5
73
+ File.open( 'specs/data/data-raw.yaml' ).grep( /boundaries:|geobox:/ ).length.must_equal 0
74
+ File.open( 'specs/data/geo/data-raw.yaml' ).grep( /boundaries:|geobox:/ ).length.must_equal 8
75
+ end
76
+ end
77
+ end
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: barton
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Dave Kinkead
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-16 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: sinatra
16
+ requirement: &70238435686220 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 1.3.2
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *70238435686220
25
+ - !ruby/object:Gem::Dependency
26
+ name: trollop
27
+ requirement: &70238435682680 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *70238435682680
36
+ - !ruby/object:Gem::Dependency
37
+ name: tire
38
+ requirement: &70238435674800 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 0.4.2
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *70238435674800
47
+ description: Barton is an API for Australian electorates and politicains
48
+ email:
49
+ - dave@kinkead.com.au
50
+ executables:
51
+ - barton
52
+ extensions: []
53
+ extra_rdoc_files: []
54
+ files:
55
+ - .gitignore
56
+ - AUTHORS
57
+ - Gemfile
58
+ - LICENSE
59
+ - README.md
60
+ - Rakefile
61
+ - barton.gemspec
62
+ - bin/barton
63
+ - config.ru
64
+ - data/.DS_Store
65
+ - data/README.md
66
+ - data/geo/nsw-federal.yaml
67
+ - data/geo/nsw-local.yaml
68
+ - data/geo/nsw-state.yaml
69
+ - data/geo/qld-federal.yaml
70
+ - data/geo/qld-state.yaml
71
+ - data/geo/vic-federal.yaml
72
+ - data/geo/vic-local.yaml
73
+ - data/geo/vic-state.yaml
74
+ - data/nsw-federal.yaml
75
+ - data/nsw-local.yaml
76
+ - data/nsw-state.yaml
77
+ - data/qld-federal.yaml
78
+ - data/qld-state.yaml
79
+ - data/vic-federal.yaml
80
+ - data/vic-local.yaml
81
+ - data/vic-state.yaml
82
+ - lib/.DS_Store
83
+ - lib/barton.rb
84
+ - lib/barton/.DS_Store
85
+ - lib/barton/app.rb
86
+ - lib/barton/core.rb
87
+ - lib/barton/version.rb
88
+ - pkg/barton-0.0.1.gem
89
+ - specs/.DS_Store
90
+ - specs/data/.DS_Store
91
+ - specs/data/data-processed.yaml
92
+ - specs/data/data-raw.yaml
93
+ - specs/data/geo/data-processed.yaml
94
+ - specs/data/geo/data-raw.yaml
95
+ - specs/data/master/data-processed.yaml
96
+ - specs/data/master/data-raw.yaml
97
+ - specs/data/master/geo.yaml
98
+ - specs/data/master/trap.txt
99
+ - specs/route_spec.rb
100
+ - specs/search_spec.rb
101
+ - specs/setup_spec.rb
102
+ homepage: http://barton.experiementsindemocracy.org
103
+ licenses: []
104
+ post_install_message:
105
+ rdoc_options: []
106
+ require_paths:
107
+ - lib
108
+ required_ruby_version: !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ! '>='
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ! '>='
118
+ - !ruby/object:Gem::Version
119
+ version: '0'
120
+ requirements: []
121
+ rubyforge_project:
122
+ rubygems_version: 1.8.15
123
+ signing_key:
124
+ specification_version: 3
125
+ summary: Programmable political access
126
+ test_files:
127
+ - specs/.DS_Store
128
+ - specs/data/.DS_Store
129
+ - specs/data/data-processed.yaml
130
+ - specs/data/data-raw.yaml
131
+ - specs/data/geo/data-processed.yaml
132
+ - specs/data/geo/data-raw.yaml
133
+ - specs/data/master/data-processed.yaml
134
+ - specs/data/master/data-raw.yaml
135
+ - specs/data/master/geo.yaml
136
+ - specs/data/master/trap.txt
137
+ - specs/route_spec.rb
138
+ - specs/search_spec.rb
139
+ - specs/setup_spec.rb