twenty_sixteen 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +2 -0
- data/CREDITS.md +3 -0
- data/README.md +17 -10
- data/lib/twenty_sixteen/candidate.rb +12 -107
- data/lib/twenty_sixteen/candidates.json +295 -0
- data/lib/twenty_sixteen/version.rb +1 -1
- data/spec/candidate_spec.rb +47 -0
- data/spec/spec_helper.rb +98 -0
- data/twenty_sixteen.gemspec +4 -0
- metadata +51 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b1b06a86f2ac601c399f80e543dbbcb3627c01bc
|
4
|
+
data.tar.gz: 7fb391d8e67f8caff7b0ca270b0e1af5672a25a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a2f2b12e2cca8b74e10dde50b44b22cb8fe75f8f7576b4d16f1d10b703e1439b673cb86298afe4e7391e6bb049ceb23b9a68eab688ddefdccaadc9b02da2089
|
7
|
+
data.tar.gz: ef293a485ad3a26a59294f5eb89e8f2ca5740710560d572b69988fd429bfd22703a7167ab3b0a8f27adc129da2403647e18f5e691c3cd18fca2ca091dbce1e8c
|
data/.rspec
ADDED
data/CREDITS.md
CHANGED
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# TwentySixteen
|
2
2
|
|
3
|
-
A source for data about the 2016 United States Presidential election. Includes a
|
3
|
+
A source for data about the 2016 United States Presidential election. Includes a **candidates** endpoint.
|
4
4
|
|
5
5
|
## Installation
|
6
6
|
|
@@ -18,16 +18,23 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
$ gem install twenty_sixteen
|
20
20
|
|
21
|
-
> A NOTE ON VERSIONING: The master branch is considered live and may contain newer data than the latest rubygems release version. You may want to bundle install using a git reference. Minor version changes will be made to reflect new data, and major version changes may be made to reflect new or revised functionality, which may or may not be backwards-compatible.
|
22
|
-
|
23
21
|
## Usage
|
24
22
|
|
25
|
-
###
|
23
|
+
### Client-side
|
24
|
+
|
25
|
+
Feel free to make client-side requests for the JSON data file:
|
26
|
+
+ https://raw.githubusercontent.com/debate-watch/twenty_sixteen/master/lib/twenty_sixteen/candidates.json
|
27
|
+
|
28
|
+
Thanks to GitHub for hosting.
|
29
|
+
|
30
|
+
### Server-side
|
31
|
+
|
32
|
+
#### Candidates
|
26
33
|
|
27
34
|
List all candidates running for President.
|
28
35
|
|
29
36
|
```` rb
|
30
|
-
candidates = TwentySixteen::Candidate.all
|
37
|
+
candidates = TwentySixteen::Candidate.all
|
31
38
|
candidates.each do |candidate|
|
32
39
|
# do something crazy
|
33
40
|
end
|
@@ -36,20 +43,20 @@ end
|
|
36
43
|
Filter candidates.
|
37
44
|
|
38
45
|
```` rb
|
39
|
-
reps = Candidate.republican
|
40
|
-
dems = Candidate.democrat
|
46
|
+
reps = TwentySixteen::Candidate.republican
|
47
|
+
dems = TwentySixteen::Candidate.democrat
|
41
48
|
````
|
42
49
|
|
43
50
|
Find a specific candidate.
|
44
51
|
|
45
52
|
```` rb
|
46
|
-
hrc = Candidate.find_by_url("https://www.hillaryclinton.com/")
|
47
|
-
joe = Candidate.find_by_last_name("Biden")
|
53
|
+
hrc = TwentySixteen::Candidate.find_by_url("https://www.hillaryclinton.com/")
|
54
|
+
joe = TwentySixteen::Candidate.find_by_last_name("Biden")
|
48
55
|
````
|
49
56
|
|
50
57
|
## Contributing
|
51
58
|
|
52
|
-
Edit candidate data in **lib/twenty_sixteen/
|
59
|
+
Edit candidate data in **lib/twenty_sixteen/candidates.json**. Please add new slogans in sequential order of appearance.
|
53
60
|
|
54
61
|
1. Fork it ( https://github.com/debate-watch/twenty_sixteen/fork )
|
55
62
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
@@ -1,121 +1,26 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
1
3
|
module TwentySixteen
|
2
4
|
class Candidate
|
3
|
-
CANDIDATES = [
|
4
|
-
{
|
5
|
-
:party => "Democrat",
|
6
|
-
:first_name => "Jim",
|
7
|
-
:last_name => "Webb",
|
8
|
-
:url => "http://www.webb2016.com/",
|
9
|
-
:campaign_name => nil,
|
10
|
-
:slogans => ["Leadership You Can Trust"],
|
11
|
-
:social_urls => [
|
12
|
-
"http://www.facebook.com/IHeardMyCountryCalling",
|
13
|
-
"http://instagram.com/webb2016/",
|
14
|
-
"http://www.twitter.com/jimwebbusa",
|
15
|
-
"https://www.youtube.com/channel/UC-Cs55IKt_UoYTMyioTSPww"
|
16
|
-
],
|
17
|
-
:support_groups => [{:name => "Born Fighting PAC", :url => "http://www.bornfighting.com"}]
|
18
|
-
},
|
19
|
-
{
|
20
|
-
:party => "Democrat",
|
21
|
-
:first_name => "Hillary",
|
22
|
-
:last_name => "Clinton",
|
23
|
-
:url => "https://www.hillaryclinton.com/",
|
24
|
-
:campaign_name => "Hillary for America",
|
25
|
-
:slogans => [],
|
26
|
-
:social_urls => [
|
27
|
-
"https://www.facebook.com/hillaryclinton",
|
28
|
-
"https://twitter.com/hillaryclinton",
|
29
|
-
"https://youtube.com/hillaryclinton",
|
30
|
-
"https://instagram.com/hillaryclinton"
|
31
|
-
],
|
32
|
-
:support_groups => [
|
33
|
-
{:name => "Ready PAC (Ready for Hillary)", :url => "https://www.readyforhillary.com/"},
|
34
|
-
{:name => "Priorities USA Action", :url => "http://www.prioritiesusaaction.org/"},
|
35
|
-
{:name => "American Bridge 21st Century", :url => "https://americanbridgepac.org/"}
|
36
|
-
]
|
37
|
-
},
|
38
|
-
{
|
39
|
-
:party => "Democrat",
|
40
|
-
:first_name => "Lincoln",
|
41
|
-
:last_name => "Chafee",
|
42
|
-
:url => "http://www.chafee2016.com/",
|
43
|
-
:campaign_name => "Chafee 2016 Committee",
|
44
|
-
:slogans => ["Fresh Ideas for America"],
|
45
|
-
:social_urls => [
|
46
|
-
"https://www.facebook.com/chafee2016",
|
47
|
-
"https://twitter.com/lincolnchafee",
|
48
|
-
"https://instagram.com/lincchafee/",
|
49
|
-
"https://vimeo.com/chafee2016"
|
50
|
-
],
|
51
|
-
:support_groups => []
|
52
|
-
},
|
53
|
-
{
|
54
|
-
:party => "Democrat",
|
55
|
-
:first_name => "Martin",
|
56
|
-
:last_name => "O'Malley",
|
57
|
-
:url => "https://martinomalley.com/",
|
58
|
-
:campaign_name => "O'Malley for President",
|
59
|
-
:slogans => [],
|
60
|
-
:social_urls => [
|
61
|
-
"https://facebook.com/MartinOMalley",
|
62
|
-
"https://twitter.com/martinomalley",
|
63
|
-
"https://youtube.com/channel/UCb7eu74-_tCNLw9FfavvKnw",
|
64
|
-
"https://instagram.com/MartinOmalley"
|
65
|
-
],
|
66
|
-
:support_groups => []
|
67
|
-
},
|
68
|
-
{
|
69
|
-
:party => "Democrat",
|
70
|
-
:first_name => "Bernie",
|
71
|
-
:last_name => "Sanders",
|
72
|
-
:url => "https://berniesanders.com/",
|
73
|
-
:campaign_name => "Bernie 2016",
|
74
|
-
:slogans => [],
|
75
|
-
:social_urls => [
|
76
|
-
"https://www.facebook.com/berniesanders",
|
77
|
-
"https://twitter.com/BernieSanders",
|
78
|
-
"https://www.youtube.com/channel/UCH1dpzjCEiGAt8CXkryhkZg",
|
79
|
-
"https://instagram.com/berniesanders/"
|
80
|
-
],
|
81
|
-
:support_groups => []
|
82
|
-
}#,
|
83
|
-
#{
|
84
|
-
# :party => "Democrat",
|
85
|
-
# :first_name => "Joe",
|
86
|
-
# :last_name => "Biden",
|
87
|
-
# :url => "___________",
|
88
|
-
# :campaign_name => "__________",
|
89
|
-
# :slogans => [],
|
90
|
-
# :social_urls => [
|
91
|
-
# "_______________",
|
92
|
-
# "_________________________________",
|
93
|
-
# "_________________________________",
|
94
|
-
# "__________"
|
95
|
-
# ],
|
96
|
-
# :support_groups => []
|
97
|
-
#},
|
98
|
-
]
|
99
|
-
|
100
5
|
def self.all
|
101
|
-
|
6
|
+
JSON.parse(File.read("lib/twenty_sixteen/candidates.json"), :symbolize_names => true)
|
102
7
|
end
|
103
8
|
|
104
|
-
def self.
|
105
|
-
|
9
|
+
def self.democrat
|
10
|
+
all.select{|candidate| candidate[:party] == "Democrat"}
|
106
11
|
end
|
107
12
|
|
108
|
-
|
109
|
-
|
110
|
-
CANDIDATES.find{|candidate| candidate[:last_name] == last_name}
|
13
|
+
def self.republican
|
14
|
+
all.select{|candidate| candidate[:party] == "Republican"}
|
111
15
|
end
|
112
16
|
|
113
|
-
def self.
|
114
|
-
|
17
|
+
def self.find_by_url(url)
|
18
|
+
all.find{|candidate| candidate[:url] == url}
|
115
19
|
end
|
116
20
|
|
117
|
-
|
118
|
-
|
21
|
+
# assumes uniqueness of last_names...
|
22
|
+
def self.find_by_last_name(last_name)
|
23
|
+
all.find{|candidate| candidate[:last_name] == last_name}
|
119
24
|
end
|
120
25
|
end
|
121
26
|
end
|
@@ -0,0 +1,295 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"party":"Democrat",
|
4
|
+
"first_name":"Jim",
|
5
|
+
"last_name":"Webb",
|
6
|
+
"url":"http://www.webb2016.com/",
|
7
|
+
"campaign_name":null,
|
8
|
+
"slogans":["Leadership You Can Trust"],
|
9
|
+
"social_urls":[
|
10
|
+
"http://www.facebook.com/IHeardMyCountryCalling",
|
11
|
+
"http://instagram.com/webb2016/",
|
12
|
+
"http://www.twitter.com/jimwebbusa",
|
13
|
+
"https://www.youtube.com/channel/UC-Cs55IKt_UoYTMyioTSPww"
|
14
|
+
],
|
15
|
+
"support_groups": [{"name":"Born Fighting PAC", "url":"http://www.bornfighting.com"}]
|
16
|
+
},
|
17
|
+
{
|
18
|
+
"party":"Democrat",
|
19
|
+
"first_name":"Hillary",
|
20
|
+
"last_name":"Clinton",
|
21
|
+
"url":"https://www.hillaryclinton.com/",
|
22
|
+
"campaign_name":"Hillary for America",
|
23
|
+
"slogans":[],
|
24
|
+
"social_urls":[
|
25
|
+
"https://www.facebook.com/hillaryclinton",
|
26
|
+
"https://twitter.com/hillaryclinton",
|
27
|
+
"https://youtube.com/hillaryclinton",
|
28
|
+
"https://instagram.com/hillaryclinton"
|
29
|
+
],
|
30
|
+
"support_groups":[
|
31
|
+
{"name":"Ready PAC (Ready for Hillary)", "url":"https://www.readyforhillary.com/"},
|
32
|
+
{"name":"Priorities USA Action", "url":"http://www.prioritiesusaaction.org/"},
|
33
|
+
{"name":"American Bridge 21st Century", "url":"https://americanbridgepac.org/"}
|
34
|
+
]
|
35
|
+
},
|
36
|
+
{
|
37
|
+
"party":"Democrat",
|
38
|
+
"first_name":"Lincoln",
|
39
|
+
"last_name":"Chafee",
|
40
|
+
"url":"http://www.chafee2016.com/",
|
41
|
+
"campaign_name":"Chafee 2016 Committee",
|
42
|
+
"slogans":["Fresh Ideas for America"],
|
43
|
+
"social_urls":[
|
44
|
+
"https://www.facebook.com/chafee2016",
|
45
|
+
"https://twitter.com/lincolnchafee",
|
46
|
+
"https://instagram.com/lincchafee/",
|
47
|
+
"https://vimeo.com/chafee2016"
|
48
|
+
],
|
49
|
+
"support_groups":[]
|
50
|
+
},
|
51
|
+
{
|
52
|
+
"party":"Democrat",
|
53
|
+
"first_name":"Martin",
|
54
|
+
"last_name":"O'Malley",
|
55
|
+
"url":"https://martinomalley.com/",
|
56
|
+
"campaign_name":"O'Malley for President",
|
57
|
+
"slogans":[],
|
58
|
+
"social_urls":[
|
59
|
+
"https://facebook.com/MartinOMalley",
|
60
|
+
"https://twitter.com/martinomalley",
|
61
|
+
"https://youtube.com/channel/UCb7eu74-_tCNLw9FfavvKnw",
|
62
|
+
"https://instagram.com/MartinOmalley"
|
63
|
+
],
|
64
|
+
"support_groups":[]
|
65
|
+
},
|
66
|
+
{
|
67
|
+
"party":"Democrat",
|
68
|
+
"first_name":"Bernie",
|
69
|
+
"last_name":"Sanders",
|
70
|
+
"url":"https://berniesanders.com/",
|
71
|
+
"campaign_name":"Bernie 2016",
|
72
|
+
"slogans":[],
|
73
|
+
"social_urls":[
|
74
|
+
"https://www.facebook.com/berniesanders",
|
75
|
+
"https://twitter.com/BernieSanders",
|
76
|
+
"https://www.youtube.com/channel/UCH1dpzjCEiGAt8CXkryhkZg",
|
77
|
+
"https://instagram.com/berniesanders/"
|
78
|
+
],
|
79
|
+
"support_groups":[]
|
80
|
+
},
|
81
|
+
{
|
82
|
+
"party":"Republican",
|
83
|
+
"first_name":"Chris",
|
84
|
+
"last_name":"Christie",
|
85
|
+
"url":"https://www.chrischristie.com",
|
86
|
+
"campaign_name":"Chris Christie for President",
|
87
|
+
"slogans":["Telling it like it is."],
|
88
|
+
"social_urls":[
|
89
|
+
"https://www.facebook.com/govchristie",
|
90
|
+
"https://twitter.com/chrischristie",
|
91
|
+
"https://instagram.com/chrischristie",
|
92
|
+
"https://www.youtube.com/channel/UCQnJDld3oa2vX7xYaXlSj4A"
|
93
|
+
],
|
94
|
+
"support_groups":[]
|
95
|
+
},
|
96
|
+
{
|
97
|
+
"party":"Republican",
|
98
|
+
"first_name":"Bobby",
|
99
|
+
"last_name":"Jindal",
|
100
|
+
"url":"http://www.bobbyjindal.com/",
|
101
|
+
"campaign_name":"Jindal for President",
|
102
|
+
"slogans":[],
|
103
|
+
"social_urls":[
|
104
|
+
"http://facebook.com/bobbyjindal",
|
105
|
+
"http://twitter.com/bobbyjindal",
|
106
|
+
"http://instagram.com/bobbyjindal",
|
107
|
+
"https://www.youtube.com/user/bobbyjindal"
|
108
|
+
],
|
109
|
+
"support_groups":[]
|
110
|
+
},
|
111
|
+
{
|
112
|
+
"party":"Republican",
|
113
|
+
"first_name":"Donald",
|
114
|
+
"last_name":"Trump",
|
115
|
+
"url":"https://www.donaldjtrump.com/",
|
116
|
+
"campaign_name":"Donald J. Trump for President",
|
117
|
+
"slogans":["Make America Great Again!"],
|
118
|
+
"social_urls":[
|
119
|
+
"https://twitter.com/realdonaldtrump",
|
120
|
+
"https://www.facebook.com/DonaldTrump",
|
121
|
+
"https://instagram.com/realdonaldtrump/",
|
122
|
+
"https://www.youtube.com/user/trump"
|
123
|
+
],
|
124
|
+
"support_groups":[]
|
125
|
+
},
|
126
|
+
{
|
127
|
+
"party":"Republican",
|
128
|
+
"first_name":"Jeb",
|
129
|
+
"last_name":"Bush",
|
130
|
+
"url":"https://jeb2016.com",
|
131
|
+
"campaign_name":"Jeb 2016",
|
132
|
+
"slogans":[],
|
133
|
+
"social_urls":[
|
134
|
+
"https://twitter.com/JebBush",
|
135
|
+
"https://www.facebook.com/jebbush",
|
136
|
+
"https://instagram.com/jebbush",
|
137
|
+
"https://www.youtube.com/channel/UCxuef1vrlJMjZRrFmYyGSeQ"
|
138
|
+
],
|
139
|
+
"support_groups":[]
|
140
|
+
},
|
141
|
+
{
|
142
|
+
"party":"Republican",
|
143
|
+
"first_name":"Rick",
|
144
|
+
"last_name":"Perry",
|
145
|
+
"url":"https://rickperry.org/",
|
146
|
+
"campaign_name":"Perry for President",
|
147
|
+
"slogans":[],
|
148
|
+
"social_urls":[
|
149
|
+
"https://twitter.com/governorperry",
|
150
|
+
"https://www.facebook.com/GovernorPerry",
|
151
|
+
"https://www.youtube.com/user/governorrickperry",
|
152
|
+
"https://instagram.com/governorperry/"
|
153
|
+
],
|
154
|
+
"support_groups":[]
|
155
|
+
},
|
156
|
+
{
|
157
|
+
"party":"Republican",
|
158
|
+
"first_name":"Lindsey",
|
159
|
+
"last_name":"Graham",
|
160
|
+
"url":"http://www.lindseygraham.com/",
|
161
|
+
"campaign_name":"Lindsey Graham 2016",
|
162
|
+
"slogans":["Ready to be Commander-in-Chief on Day One"],
|
163
|
+
"social_urls":[
|
164
|
+
"https://twitter.com/LindseyGrahamSC",
|
165
|
+
"https://instagram.com/lindseygrahamsc/",
|
166
|
+
"https://www.facebook.com/LindseyGrahamSC",
|
167
|
+
"https://www.youtube.com/user/LindseyGrahamdotcom"
|
168
|
+
],
|
169
|
+
"support_groups":[]
|
170
|
+
},
|
171
|
+
{
|
172
|
+
"party":"Republican",
|
173
|
+
"first_name":"George",
|
174
|
+
"last_name":"Pataki",
|
175
|
+
"url":"http://www.georgepataki.com/",
|
176
|
+
"campaign_name":"Pataki for President",
|
177
|
+
"slogans":["People over Politics"],
|
178
|
+
"social_urls":[
|
179
|
+
"https://www.facebook.com/GovGeorgePataki",
|
180
|
+
"https://twitter.com/governorpataki",
|
181
|
+
"https://www.youtube.com/channel/UCuP7cm-m6JDhhBxH8HfFSjQ"
|
182
|
+
],
|
183
|
+
"support_groups":[]
|
184
|
+
},
|
185
|
+
{
|
186
|
+
"party":"Republican",
|
187
|
+
"first_name":"Rick",
|
188
|
+
"last_name":"Santorum",
|
189
|
+
"url":"http://www.ricksantorum.com/",
|
190
|
+
"campaign_name":"Santorum for President 2016",
|
191
|
+
"slogans":["Restore the American Dream for Hard-working Families"],
|
192
|
+
"social_urls":[
|
193
|
+
"https://www.facebook.com/RickSantorum",
|
194
|
+
"http://instagram.com/ricksantorum",
|
195
|
+
"https://twitter.com/ricksantorum",
|
196
|
+
"https://www.youtube.com/user/RickSantorum"
|
197
|
+
],
|
198
|
+
"support_groups":[]
|
199
|
+
},
|
200
|
+
{
|
201
|
+
"party":"Republican",
|
202
|
+
"first_name":"Mike",
|
203
|
+
"last_name":"Huckabee",
|
204
|
+
"url":"http://www.mikehuckabee.com/",
|
205
|
+
"campaign_name":"Huckabee for President",
|
206
|
+
"slogans":["From Hope to Higher Ground"],
|
207
|
+
"social_urls":[
|
208
|
+
"https://www.facebook.com/mikehuckabee",
|
209
|
+
"https://twitter.com/govmikehuckabee",
|
210
|
+
"https://plus.google.com/u/0/114248918644175005647/about",
|
211
|
+
"https://instagram.com/govmikehuckabee/",
|
212
|
+
"https://www.youtube.com/channel/UC4vrtT6rYwuocyUAqzw7ERA"
|
213
|
+
],
|
214
|
+
"support_groups":[]
|
215
|
+
},
|
216
|
+
{
|
217
|
+
"party":"Republican",
|
218
|
+
"first_name":"Ben",
|
219
|
+
"last_name":"Carson",
|
220
|
+
"url":"https://www.bencarson.com/",
|
221
|
+
"campaign_name":"Carson America",
|
222
|
+
"slogans":["Heal, Inspire, Revive"],
|
223
|
+
"social_urls":[
|
224
|
+
"https://www.facebook.com/realbencarson/",
|
225
|
+
"https://twitter.com/realbencarson",
|
226
|
+
"http://instagram.com/realbencarson/",
|
227
|
+
"https://www.youtube.com/user/realbencarson/"
|
228
|
+
],
|
229
|
+
"social_hashtags":["#BC2DC16"],
|
230
|
+
"support_groups":[]
|
231
|
+
},
|
232
|
+
{
|
233
|
+
"party":"Republican",
|
234
|
+
"first_name":"Carly",
|
235
|
+
"last_name":"Fiorina",
|
236
|
+
"url":"https://carlyforamerica.com/",
|
237
|
+
"campaign_name":"Carly for America",
|
238
|
+
"slogans":["We must once again become a nation of limitless possibility."],
|
239
|
+
"social_urls":[
|
240
|
+
"https://www.facebook.com/pages/Carly-For-America/801745626578122",
|
241
|
+
"https://twitter.com/carlyforamerica",
|
242
|
+
"https://www.youtube.com/channel/UCiYZ3Ta44Lc0qP5bOASz7Yw",
|
243
|
+
"https://instagram.com/carlyforamerica/"
|
244
|
+
],
|
245
|
+
"support_groups":[{"name":"CARLY for America", "url":"https://carlyforamerica.com/"}]
|
246
|
+
},
|
247
|
+
{
|
248
|
+
"party":"Republican",
|
249
|
+
"first_name":"Marco",
|
250
|
+
"last_name":"Rubio",
|
251
|
+
"url":"https://marcorubio.com/",
|
252
|
+
"campaign_name":"Marco Rubio for President",
|
253
|
+
"slogans":["A New American Century"],
|
254
|
+
"social_urls":[
|
255
|
+
"https://www.youtube.com/user/marcorubio",
|
256
|
+
"https://instagram.com/marcorubiofla/",
|
257
|
+
"http://marcorubio.tumblr.com/",
|
258
|
+
"https://plus.google.com/+MarcoRubio",
|
259
|
+
"https://www.pinterest.com/contact1112/",
|
260
|
+
"https://twitter.com/marcorubio",
|
261
|
+
"https://www.facebook.com/MarcoRubio"
|
262
|
+
],
|
263
|
+
"support_groups":[]
|
264
|
+
},
|
265
|
+
{
|
266
|
+
"party":"Republican",
|
267
|
+
"first_name":"Rand",
|
268
|
+
"last_name":"Paul",
|
269
|
+
"url":"https://randpaul.com/",
|
270
|
+
"campaign_name":"Rand Paul for President",
|
271
|
+
"slogans":["Defeat the Washington Machine"],
|
272
|
+
"social_urls":[
|
273
|
+
"https://www.facebook.com/RandPaul",
|
274
|
+
"https://plus.google.com/u/2/111010718120518521029/",
|
275
|
+
"https://twitter.com/RandPaul",
|
276
|
+
"https://www.youtube.com/channel/UC_8WUrPbi8clO6sWt_FDvuA",
|
277
|
+
"https://instagram.com/drrandpaul/"
|
278
|
+
],
|
279
|
+
"support_groups":[]
|
280
|
+
},
|
281
|
+
{
|
282
|
+
"party":"Republican",
|
283
|
+
"first_name":"Ted",
|
284
|
+
"last_name":"Cruz",
|
285
|
+
"url":"https://www.tedcruz.org/",
|
286
|
+
"campaign_name":"Cruz for President",
|
287
|
+
"slogans":["Courageous Conservatives Reigniting the Promise of America"],
|
288
|
+
"social_urls":[
|
289
|
+
"https://www.facebook.com/tedcruzpage",
|
290
|
+
"https://twitter.com/tedcruz",
|
291
|
+
"https://www.youtube.com/user/TedCruzforSenate"
|
292
|
+
],
|
293
|
+
"support_groups":[]
|
294
|
+
}
|
295
|
+
]
|
@@ -0,0 +1,47 @@
|
|
1
|
+
require 'pry'
|
2
|
+
|
3
|
+
module TwentySixteen
|
4
|
+
RSpec.describe Candidate do
|
5
|
+
describe '#all' do
|
6
|
+
it "parses a valid candidates.json file returns an array of ruby hashes" do
|
7
|
+
candidates = TwentySixteen::Candidate.all
|
8
|
+
expect(candidates).to be_kind_of(Array)
|
9
|
+
expect(candidates).not_to be_empty
|
10
|
+
expect(candidates.first).to be_kind_of(Hash)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe '#democrat' do
|
15
|
+
it "returns an array of matching candidates, dems only" do
|
16
|
+
dems = TwentySixteen::Candidate.democrat
|
17
|
+
expect(dems).to be_kind_of(Array)
|
18
|
+
expect(dems).not_to be_empty
|
19
|
+
expect(dems.first).to be_kind_of(Hash)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#republican' do
|
24
|
+
it "returns an array of matching candidates, reps only" do
|
25
|
+
reps = TwentySixteen::Candidate.republican
|
26
|
+
expect(reps).to be_kind_of(Array)
|
27
|
+
expect(reps).not_to be_empty
|
28
|
+
expect(reps.first).to be_kind_of(Hash)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe '#find_by_url' do
|
33
|
+
it "returns a candidate whose campaign url matches the paramater" do
|
34
|
+
hrc = TwentySixteen::Candidate.find_by_url("https://www.hillaryclinton.com/")
|
35
|
+
expect(hrc).to be_kind_of(Hash)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#find_by_last_name' do
|
40
|
+
it "returns a candidate whose last name matches the paramater" do
|
41
|
+
pending "announcement by the VP..."
|
42
|
+
joe = TwentySixteen::Candidate.find_by_last_name("Biden")
|
43
|
+
expect(joe).to be_kind_of(Hash)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'twenty_sixteen'
|
2
|
+
|
3
|
+
# This file was generated by the `rspec --init` command. Conventionally, all
|
4
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
5
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
6
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
7
|
+
# files.
|
8
|
+
#
|
9
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
10
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
11
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
12
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
13
|
+
# a separate helper file that requires the additional dependencies and performs
|
14
|
+
# the additional setup, and require it from the spec files that actually need
|
15
|
+
# it.
|
16
|
+
#
|
17
|
+
# The `.rspec` file also contains a few flags that are not defaults but that
|
18
|
+
# users commonly want.
|
19
|
+
#
|
20
|
+
# See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
21
|
+
RSpec.configure do |config|
|
22
|
+
# rspec-expectations config goes here. You can use an alternate
|
23
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
24
|
+
# assertions if you prefer.
|
25
|
+
config.expect_with :rspec do |expectations|
|
26
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
27
|
+
# and `failure_message` of custom matchers include text for helper methods
|
28
|
+
# defined using `chain`, e.g.:
|
29
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
30
|
+
# # => "be bigger than 2 and smaller than 4"
|
31
|
+
# ...rather than:
|
32
|
+
# # => "be bigger than 2"
|
33
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
34
|
+
end
|
35
|
+
|
36
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
37
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
38
|
+
config.mock_with :rspec do |mocks|
|
39
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
40
|
+
# a real object. This is generally recommended, and will default to
|
41
|
+
# `true` in RSpec 4.
|
42
|
+
mocks.verify_partial_doubles = true
|
43
|
+
end
|
44
|
+
|
45
|
+
# The settings below are suggested to provide a good initial experience
|
46
|
+
# with RSpec, but feel free to customize to your heart's content.
|
47
|
+
=begin
|
48
|
+
# These two settings work together to allow you to limit a spec run
|
49
|
+
# to individual examples or groups you care about by tagging them with
|
50
|
+
# `:focus` metadata. When nothing is tagged with `:focus`, all examples
|
51
|
+
# get run.
|
52
|
+
config.filter_run :focus
|
53
|
+
config.run_all_when_everything_filtered = true
|
54
|
+
|
55
|
+
# Allows RSpec to persist some state between runs in order to support
|
56
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
57
|
+
# you configure your source control system to ignore this file.
|
58
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
59
|
+
|
60
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
61
|
+
# recommended. For more details, see:
|
62
|
+
# - http://myronmars.to/n/dev-blog/2012/06/rspecs-new-expectation-syntax
|
63
|
+
# - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/
|
64
|
+
# - http://myronmars.to/n/dev-blog/2014/05/notable-changes-in-rspec-3#new__config_option_to_disable_rspeccore_monkey_patching
|
65
|
+
config.disable_monkey_patching!
|
66
|
+
|
67
|
+
# This setting enables warnings. It's recommended, but in some cases may
|
68
|
+
# be too noisy due to issues in dependencies.
|
69
|
+
config.warnings = true
|
70
|
+
|
71
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
72
|
+
# file, and it's useful to allow more verbose output when running an
|
73
|
+
# individual spec file.
|
74
|
+
if config.files_to_run.one?
|
75
|
+
# Use the documentation formatter for detailed output,
|
76
|
+
# unless a formatter has already been configured
|
77
|
+
# (e.g. via a command-line flag).
|
78
|
+
config.default_formatter = 'doc'
|
79
|
+
end
|
80
|
+
|
81
|
+
# Print the 10 slowest examples and example groups at the
|
82
|
+
# end of the spec run, to help surface which specs are running
|
83
|
+
# particularly slow.
|
84
|
+
config.profile_examples = 10
|
85
|
+
|
86
|
+
# Run specs in random order to surface order dependencies. If you find an
|
87
|
+
# order dependency and want to debug it, you can fix the order by providing
|
88
|
+
# the seed, which is printed after each run.
|
89
|
+
# --seed 1234
|
90
|
+
config.order = :random
|
91
|
+
|
92
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
93
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
94
|
+
# test failures related to randomization by passing the same `--seed` value
|
95
|
+
# as the one that triggered the failure.
|
96
|
+
Kernel.srand config.seed
|
97
|
+
=end
|
98
|
+
end
|
data/twenty_sixteen.gemspec
CHANGED
@@ -20,4 +20,8 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.7"
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec", "~> 3.3"
|
24
|
+
spec.add_development_dependency "pry", "~> 0.10"
|
25
|
+
|
26
|
+
spec.add_dependency "json", "~> 1.8.3"
|
23
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: twenty_sixteen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- MJ Rossetti (@s2t2)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -38,6 +38,48 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pry
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.10'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.10'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: json
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 1.8.3
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 1.8.3
|
41
83
|
description: A source for data about the 2016 United States Presidential election.
|
42
84
|
Includes a "candidates" endpoint.
|
43
85
|
email:
|
@@ -47,6 +89,7 @@ extensions: []
|
|
47
89
|
extra_rdoc_files: []
|
48
90
|
files:
|
49
91
|
- ".gitignore"
|
92
|
+
- ".rspec"
|
50
93
|
- CREDITS.md
|
51
94
|
- Gemfile
|
52
95
|
- LICENSE.txt
|
@@ -54,7 +97,10 @@ files:
|
|
54
97
|
- Rakefile
|
55
98
|
- lib/twenty_sixteen.rb
|
56
99
|
- lib/twenty_sixteen/candidate.rb
|
100
|
+
- lib/twenty_sixteen/candidates.json
|
57
101
|
- lib/twenty_sixteen/version.rb
|
102
|
+
- spec/candidate_spec.rb
|
103
|
+
- spec/spec_helper.rb
|
58
104
|
- twenty_sixteen.gemspec
|
59
105
|
homepage: https://github.com/debate-watch/twenty_sixteen
|
60
106
|
licenses:
|
@@ -80,4 +126,6 @@ rubygems_version: 2.2.2
|
|
80
126
|
signing_key:
|
81
127
|
specification_version: 4
|
82
128
|
summary: A source for data about the 2016 United States Presidential election.
|
83
|
-
test_files:
|
129
|
+
test_files:
|
130
|
+
- spec/candidate_spec.rb
|
131
|
+
- spec/spec_helper.rb
|