votesmart 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (70) hide show
  1. data/.gitignore +1 -0
  2. data/History.txt +20 -0
  3. data/README.rdoc +48 -0
  4. data/Rakefile +45 -0
  5. data/VERSION.yml +4 -0
  6. data/lib/mcll4r/MIT-LICENSE +20 -0
  7. data/lib/mcll4r/README +19 -0
  8. data/lib/mcll4r/mcll4r.rb +24 -0
  9. data/lib/mcll4r/mcll4r_test.rb +35 -0
  10. data/lib/vote_smart.rb +22 -0
  11. data/lib/vote_smart/address.rb +42 -0
  12. data/lib/vote_smart/candidate.rb +32 -0
  13. data/lib/vote_smart/candidate_bio.rb +16 -0
  14. data/lib/vote_smart/candidate_office.rb +15 -0
  15. data/lib/vote_smart/committee.rb +23 -0
  16. data/lib/vote_smart/common.rb +97 -0
  17. data/lib/vote_smart/district.rb +38 -0
  18. data/lib/vote_smart/election.rb +21 -0
  19. data/lib/vote_smart/leadership.rb +16 -0
  20. data/lib/vote_smart/local.rb +21 -0
  21. data/lib/vote_smart/measure.rb +16 -0
  22. data/lib/vote_smart/notes.rb +11 -0
  23. data/lib/vote_smart/npat.rb +11 -0
  24. data/lib/vote_smart/office.rb +119 -0
  25. data/lib/vote_smart/official.rb +131 -0
  26. data/lib/vote_smart/phone.rb +12 -0
  27. data/lib/vote_smart/rating.rb +43 -0
  28. data/lib/vote_smart/state.rb +29 -0
  29. data/lib/vote_smart/vote.rb +70 -0
  30. data/lib/votesmart.rb +1 -0
  31. data/script/autospec +6 -0
  32. data/script/console +10 -0
  33. data/script/destroy +14 -0
  34. data/script/generate +14 -0
  35. data/script/is_gem_built +40 -0
  36. data/spec/responses/Address.get_office.106446.js +1 -0
  37. data/spec/responses/Address.get_office.1721.js +1 -0
  38. data/spec/responses/District.get_by_office_state.7.GA.js +1 -0
  39. data/spec/responses/District.get_by_office_state.8.GA.js +1 -0
  40. data/spec/responses/District.get_by_office_state.9.GA.js +1 -0
  41. data/spec/responses/Office.get_offices_by_type.C.js +1 -0
  42. data/spec/responses/Office.get_offices_by_type.L.js +1 -0
  43. data/spec/responses/Office.get_offices_by_type.P.js +1 -0
  44. data/spec/responses/Office.get_offices_by_type.S.js +1 -0
  45. data/spec/responses/Office.get_types.js +1 -0
  46. data/spec/responses/Official.get_by_district.20451.js +1 -0
  47. data/spec/responses/Official.get_by_district.20689.js +1 -0
  48. data/spec/responses/Official.get_by_district.21397.js +1 -0
  49. data/spec/responses/Official.get_by_district.21946.js +1 -0
  50. data/spec/responses/Official.get_by_office_state.12.CO.js +1 -0
  51. data/spec/responses/Official.get_by_office_state.12.GA.js +1 -0
  52. data/spec/responses/Official.get_by_office_state.13.GA.js +1 -0
  53. data/spec/responses/Official.get_by_office_state.33.GA.js +1 -0
  54. data/spec/responses/Official.get_by_office_state.42.GA.js +1 -0
  55. data/spec/responses/Official.get_by_office_state.44.GA.js +1 -0
  56. data/spec/responses/Official.get_by_office_state.45.GA.js +1 -0
  57. data/spec/responses/Official.get_by_office_state.53.GA.js +1 -0
  58. data/spec/responses/Rating.get_sig.1863.js +1 -0
  59. data/spec/responses/State.get_state.GA.js +1 -0
  60. data/spec/responses/State.get_state_ids.js +1 -0
  61. data/spec/responses/authorization_failed.js +1 -0
  62. data/spec/spec_helper.rb +98 -0
  63. data/spec/vote_smart/district_spec.rb +36 -0
  64. data/spec/vote_smart/office_spec.rb +96 -0
  65. data/spec/vote_smart/official_spec.rb +56 -0
  66. data/spec/vote_smart/rating_spec.rb +15 -0
  67. data/spec/vote_smart/state_spec.rb +28 -0
  68. data/tasks/spec_json.rake +64 -0
  69. data/votesmart.gemspec +116 -0
  70. metadata +149 -0
@@ -0,0 +1,56 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ module VoteSmart
4
+ describe Official do
5
+
6
+ describe "find_by_district_id" do
7
+ def do_find
8
+ Official.find_by_district_id("20451")
9
+ end
10
+
11
+ it_should_find :item => {:last_name => "Isakson", :id => "1721", :district_id => "20451", :party => 'Republican'}
12
+ end
13
+
14
+ describe "multiple offices" do
15
+ def do_find
16
+ @official = Official.find_by_district_id("20451")
17
+ @official.offices
18
+ end
19
+
20
+ it_should_find :count => 5, :first => {:address => {:type => "District"}},
21
+ :last => {:address => {:type => "Washington, D.C."}}
22
+ end
23
+
24
+ describe "one office" do
25
+ def do_find
26
+ @official = Official.find_by_district_id("21397")
27
+ @official.offices
28
+ end
29
+
30
+ it_should_find :count => 1, :first => {:address => {:type => "Capitol"}}
31
+ end
32
+
33
+ describe "find_by_office_id_and_state_id" do
34
+ def do_find
35
+ Official.find_by_office_id_and_state_id("12", "CO")
36
+ end
37
+
38
+ it_should_find :item => {:last_name => "Suthers", :id => "29799", :office_id => "12", :state_id => "CO"}
39
+ end
40
+
41
+ describe "find by address" do
42
+ before :each do
43
+ mcll4r = {"response" => {"state_lower" => {"district" => "1"}, "state_upper" => {"district" => "2"}}}
44
+ Geocoding.should_receive(:get).once.and_return([mock("placemark", :latitude => 2, :longitude => 10)])
45
+ Mcll4r.should_receive(:new).once.and_return(mock("mcll4r", :district_lookup => mcll4r))
46
+ end
47
+
48
+ def do_find
49
+ Official.find_all_by_address "123 fake st", "atlanta", "GA", "30303"
50
+ end
51
+
52
+ it_should_find :count => 5, :first => {:last_name => "Handel", :title => "Secretary"},
53
+ :last => {:last_name => "Jackson", :title => "Senator"}
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,15 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe VoteSmart::Rating do
4
+ describe ".get_sig" do
5
+ it "should properly handle UTF characters" do
6
+ VoteSmart::Rating.get_sig('1863')['sig']['description'].unpack("U*").should_not include(148)
7
+ end
8
+
9
+ it "shouldn't have a quoted description" do
10
+ description = VoteSmart::Rating.get_sig('1863')['sig']['description']
11
+ description.first.should_not == '"'
12
+ description.last.should_not == '"'
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,28 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ module VoteSmart
4
+ describe State do
5
+
6
+ describe "all" do
7
+
8
+ def do_find
9
+ State.all
10
+ end
11
+
12
+ it_should_find :count => 56, :first => {:name => "National", :id => "NA"},
13
+ :last => {:name => "Louisiana", :id => "LA"}
14
+
15
+ end
16
+
17
+ describe "find_by_id" do
18
+
19
+ def do_find
20
+ State.find_by_id("GA")
21
+ end
22
+
23
+ it_should_find :item => {:name => "Georgia", :id => "GA", :largest_city => "Atlanta"}
24
+
25
+ end
26
+
27
+ end
28
+ end
@@ -0,0 +1,64 @@
1
+
2
+ namespace :spec do
3
+
4
+ def save_json_response name, response
5
+ File.open("#{File.dirname(__FILE__)}/../spec/responses/#{name}.js", "w") do |f|
6
+ f.write response.to_json
7
+ end
8
+ end
9
+
10
+ def save_json clazz, method, *args
11
+ response = args.empty? ? clazz.send(method) : clazz.send(method, *args)
12
+
13
+ clazz_name = clazz.name.split("::").last
14
+ params = [method].concat(args).join('.')
15
+
16
+ save_json_response "#{clazz_name}.#{params}", response
17
+ end
18
+
19
+ task :json do
20
+ require "#{File.dirname(__FILE__)}/../lib/vote_smart"
21
+ # response = VoteSmart::State.get_state("GA")
22
+ # save_json_response "authorization_failed", response
23
+
24
+ VoteSmart.api_key = ENV['PVS_API_KEY'] if ENV['PVS_API_KEY']
25
+
26
+ # save_json VoteSmart::State, :get_state_ids
27
+ # save_json VoteSmart::State, :get_state, "GA"
28
+
29
+ # save_json VoteSmart::Office, :get_types
30
+
31
+ # save_json VoteSmart::Office, :get_offices_by_type, "P"
32
+ # save_json VoteSmart::Office, :get_offices_by_type, "C"
33
+
34
+ # save_json VoteSmart::Official, :get_by_district, "20451"
35
+
36
+ # save_json VoteSmart::District, :get_by_office_state, "9", "GA"
37
+
38
+ # save_json VoteSmart::Address, :get_office, "1721"
39
+
40
+ # save_json VoteSmart::Office, :get_offices_by_type, "S"
41
+
42
+ # save_json VoteSmart::Official, :get_by_office_state, "44", "GA"
43
+ # save_json VoteSmart::Official, :get_by_office_state, "45", "GA"
44
+ # save_json VoteSmart::Official, :get_by_office_state, "12", "GA"
45
+ # save_json VoteSmart::Official, :get_by_office_state, "42", "GA"
46
+ # save_json VoteSmart::Official, :get_by_office_state, "33", "GA"
47
+ # save_json VoteSmart::Official, :get_by_office_state, "53", "GA"
48
+ # save_json VoteSmart::Official, :get_by_office_state, "13", "GA"
49
+
50
+ # save_json VoteSmart::Office, :get_offices_by_type, "L"
51
+ # save_json VoteSmart::District, :get_by_office_state, "7", "GA"
52
+ # save_json VoteSmart::District, :get_by_office_state, "8", "GA"
53
+
54
+ # save_json VoteSmart::Official, :get_by_district, "20689"
55
+ # save_json VoteSmart::Official, :get_by_district, "21946"
56
+
57
+ # save_json VoteSmart::Official, :get_by_district, "21397"
58
+
59
+ # save_json VoteSmart::Address, :get_office, "106446"
60
+
61
+ # save_json VoteSmart::Official, :get_by_office_state, "12", "CO"
62
+ save_json VoteSmart::Rating, :get_sig, "1863"
63
+ end
64
+ end
@@ -0,0 +1,116 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{votesmart}
8
+ s.version = "0.3.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Dan Cunning", "Ben Woosley"]
12
+ s.date = %q{2010-03-25}
13
+ s.description = %q{A wrapper for the Project Vote Smart API}
14
+ s.email = %q{ben.woosley@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "README.rdoc"
17
+ ]
18
+ s.files = [
19
+ ".gitignore",
20
+ "History.txt",
21
+ "README.rdoc",
22
+ "Rakefile",
23
+ "VERSION.yml",
24
+ "lib/mcll4r/MIT-LICENSE",
25
+ "lib/mcll4r/README",
26
+ "lib/mcll4r/mcll4r.rb",
27
+ "lib/mcll4r/mcll4r_test.rb",
28
+ "lib/vote_smart.rb",
29
+ "lib/vote_smart/address.rb",
30
+ "lib/vote_smart/candidate.rb",
31
+ "lib/vote_smart/candidate_bio.rb",
32
+ "lib/vote_smart/candidate_office.rb",
33
+ "lib/vote_smart/committee.rb",
34
+ "lib/vote_smart/common.rb",
35
+ "lib/vote_smart/district.rb",
36
+ "lib/vote_smart/election.rb",
37
+ "lib/vote_smart/leadership.rb",
38
+ "lib/vote_smart/local.rb",
39
+ "lib/vote_smart/measure.rb",
40
+ "lib/vote_smart/notes.rb",
41
+ "lib/vote_smart/npat.rb",
42
+ "lib/vote_smart/office.rb",
43
+ "lib/vote_smart/official.rb",
44
+ "lib/vote_smart/phone.rb",
45
+ "lib/vote_smart/rating.rb",
46
+ "lib/vote_smart/state.rb",
47
+ "lib/vote_smart/vote.rb",
48
+ "lib/votesmart.rb",
49
+ "script/autospec",
50
+ "script/console",
51
+ "script/destroy",
52
+ "script/generate",
53
+ "script/is_gem_built",
54
+ "spec/responses/Address.get_office.106446.js",
55
+ "spec/responses/Address.get_office.1721.js",
56
+ "spec/responses/District.get_by_office_state.7.GA.js",
57
+ "spec/responses/District.get_by_office_state.8.GA.js",
58
+ "spec/responses/District.get_by_office_state.9.GA.js",
59
+ "spec/responses/Office.get_offices_by_type.C.js",
60
+ "spec/responses/Office.get_offices_by_type.L.js",
61
+ "spec/responses/Office.get_offices_by_type.P.js",
62
+ "spec/responses/Office.get_offices_by_type.S.js",
63
+ "spec/responses/Office.get_types.js",
64
+ "spec/responses/Official.get_by_district.20451.js",
65
+ "spec/responses/Official.get_by_district.20689.js",
66
+ "spec/responses/Official.get_by_district.21397.js",
67
+ "spec/responses/Official.get_by_district.21946.js",
68
+ "spec/responses/Official.get_by_office_state.12.CO.js",
69
+ "spec/responses/Official.get_by_office_state.12.GA.js",
70
+ "spec/responses/Official.get_by_office_state.13.GA.js",
71
+ "spec/responses/Official.get_by_office_state.33.GA.js",
72
+ "spec/responses/Official.get_by_office_state.42.GA.js",
73
+ "spec/responses/Official.get_by_office_state.44.GA.js",
74
+ "spec/responses/Official.get_by_office_state.45.GA.js",
75
+ "spec/responses/Official.get_by_office_state.53.GA.js",
76
+ "spec/responses/Rating.get_sig.1863.js",
77
+ "spec/responses/State.get_state.GA.js",
78
+ "spec/responses/State.get_state_ids.js",
79
+ "spec/responses/authorization_failed.js",
80
+ "spec/spec_helper.rb",
81
+ "spec/vote_smart/district_spec.rb",
82
+ "spec/vote_smart/office_spec.rb",
83
+ "spec/vote_smart/official_spec.rb",
84
+ "spec/vote_smart/rating_spec.rb",
85
+ "spec/vote_smart/state_spec.rb",
86
+ "tasks/spec_json.rake",
87
+ "votesmart.gemspec"
88
+ ]
89
+ s.homepage = %q{http://github.com/Empact/votesmart}
90
+ s.rdoc_options = ["--charset=UTF-8"]
91
+ s.require_paths = ["lib"]
92
+ s.rubygems_version = %q{1.3.6}
93
+ s.summary = %q{A wrapper for the Project Vote Smart API}
94
+ s.test_files = [
95
+ "spec/spec_helper.rb",
96
+ "spec/vote_smart/district_spec.rb",
97
+ "spec/vote_smart/office_spec.rb",
98
+ "spec/vote_smart/official_spec.rb",
99
+ "spec/vote_smart/rating_spec.rb",
100
+ "spec/vote_smart/state_spec.rb"
101
+ ]
102
+
103
+ if s.respond_to? :specification_version then
104
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
105
+ s.specification_version = 3
106
+
107
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
108
+ s.add_runtime_dependency(%q<patron>, [">= 0.4.6"])
109
+ else
110
+ s.add_dependency(%q<patron>, [">= 0.4.6"])
111
+ end
112
+ else
113
+ s.add_dependency(%q<patron>, [">= 0.4.6"])
114
+ end
115
+ end
116
+
metadata ADDED
@@ -0,0 +1,149 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: votesmart
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 3
8
+ - 0
9
+ version: 0.3.0
10
+ platform: ruby
11
+ authors:
12
+ - Dan Cunning
13
+ - Ben Woosley
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-03-25 00:00:00 -04:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: patron
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
30
+ - 4
31
+ - 6
32
+ version: 0.4.6
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ description: A wrapper for the Project Vote Smart API
36
+ email: ben.woosley@gmail.com
37
+ executables: []
38
+
39
+ extensions: []
40
+
41
+ extra_rdoc_files:
42
+ - README.rdoc
43
+ files:
44
+ - .gitignore
45
+ - History.txt
46
+ - README.rdoc
47
+ - Rakefile
48
+ - VERSION.yml
49
+ - lib/mcll4r/MIT-LICENSE
50
+ - lib/mcll4r/README
51
+ - lib/mcll4r/mcll4r.rb
52
+ - lib/mcll4r/mcll4r_test.rb
53
+ - lib/vote_smart.rb
54
+ - lib/vote_smart/address.rb
55
+ - lib/vote_smart/candidate.rb
56
+ - lib/vote_smart/candidate_bio.rb
57
+ - lib/vote_smart/candidate_office.rb
58
+ - lib/vote_smart/committee.rb
59
+ - lib/vote_smart/common.rb
60
+ - lib/vote_smart/district.rb
61
+ - lib/vote_smart/election.rb
62
+ - lib/vote_smart/leadership.rb
63
+ - lib/vote_smart/local.rb
64
+ - lib/vote_smart/measure.rb
65
+ - lib/vote_smart/notes.rb
66
+ - lib/vote_smart/npat.rb
67
+ - lib/vote_smart/office.rb
68
+ - lib/vote_smart/official.rb
69
+ - lib/vote_smart/phone.rb
70
+ - lib/vote_smart/rating.rb
71
+ - lib/vote_smart/state.rb
72
+ - lib/vote_smart/vote.rb
73
+ - lib/votesmart.rb
74
+ - script/autospec
75
+ - script/console
76
+ - script/destroy
77
+ - script/generate
78
+ - script/is_gem_built
79
+ - spec/responses/Address.get_office.106446.js
80
+ - spec/responses/Address.get_office.1721.js
81
+ - spec/responses/District.get_by_office_state.7.GA.js
82
+ - spec/responses/District.get_by_office_state.8.GA.js
83
+ - spec/responses/District.get_by_office_state.9.GA.js
84
+ - spec/responses/Office.get_offices_by_type.C.js
85
+ - spec/responses/Office.get_offices_by_type.L.js
86
+ - spec/responses/Office.get_offices_by_type.P.js
87
+ - spec/responses/Office.get_offices_by_type.S.js
88
+ - spec/responses/Office.get_types.js
89
+ - spec/responses/Official.get_by_district.20451.js
90
+ - spec/responses/Official.get_by_district.20689.js
91
+ - spec/responses/Official.get_by_district.21397.js
92
+ - spec/responses/Official.get_by_district.21946.js
93
+ - spec/responses/Official.get_by_office_state.12.CO.js
94
+ - spec/responses/Official.get_by_office_state.12.GA.js
95
+ - spec/responses/Official.get_by_office_state.13.GA.js
96
+ - spec/responses/Official.get_by_office_state.33.GA.js
97
+ - spec/responses/Official.get_by_office_state.42.GA.js
98
+ - spec/responses/Official.get_by_office_state.44.GA.js
99
+ - spec/responses/Official.get_by_office_state.45.GA.js
100
+ - spec/responses/Official.get_by_office_state.53.GA.js
101
+ - spec/responses/Rating.get_sig.1863.js
102
+ - spec/responses/State.get_state.GA.js
103
+ - spec/responses/State.get_state_ids.js
104
+ - spec/responses/authorization_failed.js
105
+ - spec/spec_helper.rb
106
+ - spec/vote_smart/district_spec.rb
107
+ - spec/vote_smart/office_spec.rb
108
+ - spec/vote_smart/official_spec.rb
109
+ - spec/vote_smart/rating_spec.rb
110
+ - spec/vote_smart/state_spec.rb
111
+ - tasks/spec_json.rake
112
+ - votesmart.gemspec
113
+ has_rdoc: true
114
+ homepage: http://github.com/Empact/votesmart
115
+ licenses: []
116
+
117
+ post_install_message:
118
+ rdoc_options:
119
+ - --charset=UTF-8
120
+ require_paths:
121
+ - lib
122
+ required_ruby_version: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ segments:
127
+ - 0
128
+ version: "0"
129
+ required_rubygems_version: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ segments:
134
+ - 0
135
+ version: "0"
136
+ requirements: []
137
+
138
+ rubyforge_project:
139
+ rubygems_version: 1.3.6
140
+ signing_key:
141
+ specification_version: 3
142
+ summary: A wrapper for the Project Vote Smart API
143
+ test_files:
144
+ - spec/spec_helper.rb
145
+ - spec/vote_smart/district_spec.rb
146
+ - spec/vote_smart/office_spec.rb
147
+ - spec/vote_smart/official_spec.rb
148
+ - spec/vote_smart/rating_spec.rb
149
+ - spec/vote_smart/state_spec.rb