twenty_sixteen 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -23
- data/lib/twenty_sixteen/candidate.rb +4 -0
- data/lib/twenty_sixteen/version.rb +1 -1
- data/spec/candidate_spec.rb +9 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ebb50875827843f9ea6ce824bc284ad57269e2e
|
4
|
+
data.tar.gz: 92446ac9056d8f529c941c8545d80b254a70589e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4893c77a65f89c19bbe32fa5f1b5354c97b49cff8d30c597e157b67ac1940005ddc4879e793828195e219cc85e68782bd19ecd477ba888b75e88e9b6558873b9
|
7
|
+
data.tar.gz: fcd82194c3886dd17f8c8adb218e94eb6c01f47140bba7b296cf41951459d3ea662e90ad890aea1e4892261e1d6b0c704faf66d2a85bfd985eb0fc4e59a13583
|
data/README.md
CHANGED
@@ -24,10 +24,7 @@ Or install it yourself as:
|
|
24
24
|
|
25
25
|
### Client-side
|
26
26
|
|
27
|
-
|
28
|
-
+ https://raw.githubusercontent.com/debate-watch/twenty_sixteen/master/lib/twenty_sixteen/candidates.json
|
29
|
-
|
30
|
-
Thanks to GitHub for hosting.
|
27
|
+
Request the [hosted JSON data file](https://raw.githubusercontent.com/debate-watch/twenty_sixteen/master/lib/twenty_sixteen/candidates.json).
|
31
28
|
|
32
29
|
### Server-side
|
33
30
|
|
@@ -37,37 +34,21 @@ List all candidates running for President.
|
|
37
34
|
|
38
35
|
```` rb
|
39
36
|
candidates = TwentySixteen::Candidate.all
|
40
|
-
candidates.each do |candidate|
|
41
|
-
puts candidate
|
42
|
-
#=> {
|
43
|
-
# :party=>"Democrat",
|
44
|
-
# :first_name=>"Jim",
|
45
|
-
# :last_name=>"Webb",
|
46
|
-
# :url=>"http://www.webb2016.com/",
|
47
|
-
# :campaign_name=>nil,
|
48
|
-
# :slogans=>["Leadership You Can Trust"],
|
49
|
-
# :social_urls=>
|
50
|
-
# ["http://www.facebook.com/IHeardMyCountryCalling",
|
51
|
-
# "http://instagram.com/webb2016/",
|
52
|
-
# "http://www.twitter.com/jimwebbusa",
|
53
|
-
# "https://www.youtube.com/channel/UC-Cs55IKt_UoYTMyioTSPww"],
|
54
|
-
# :support_groups=>[{:name=>"Born Fighting PAC", :url=>"http://www.bornfighting.com"}]
|
55
|
-
#}
|
56
|
-
end
|
57
37
|
````
|
58
38
|
|
59
39
|
Filter candidates.
|
60
40
|
|
61
41
|
```` rb
|
62
|
-
reps = TwentySixteen::Candidate.republican
|
63
42
|
dems = TwentySixteen::Candidate.democrat
|
43
|
+
reps = TwentySixteen::Candidate.republican
|
44
|
+
indies = TwentySixteen::Candidate.independent
|
64
45
|
````
|
65
46
|
|
66
47
|
Find a specific candidate.
|
67
48
|
|
68
49
|
```` rb
|
69
50
|
hrc = TwentySixteen::Candidate.find_by_url("https://www.hillaryclinton.com/")
|
70
|
-
|
51
|
+
donald = TwentySixteen::Candidate.find_by_last_name("Trump")
|
71
52
|
````
|
72
53
|
|
73
54
|
## Contributing
|
@@ -17,6 +17,10 @@ module TwentySixteen
|
|
17
17
|
all.select{|candidate| candidate[:party] == "Republican"}
|
18
18
|
end
|
19
19
|
|
20
|
+
def self.independent
|
21
|
+
all.select{|candidate| candidate[:party] == "Independent"}
|
22
|
+
end
|
23
|
+
|
20
24
|
def self.find_by_url(url)
|
21
25
|
all.find{|candidate| candidate[:url] == url}
|
22
26
|
end
|
data/spec/candidate_spec.rb
CHANGED
@@ -29,6 +29,15 @@ module TwentySixteen
|
|
29
29
|
end
|
30
30
|
end
|
31
31
|
|
32
|
+
describe '#independent' do
|
33
|
+
it "returns an array of matching candidates, indies only" do
|
34
|
+
indies = TwentySixteen::Candidate.independent
|
35
|
+
expect(indies).to be_kind_of(Array)
|
36
|
+
expect(indies).not_to be_empty
|
37
|
+
expect(indies.first).to be_kind_of(Hash)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
32
41
|
describe '#find_by_url' do
|
33
42
|
it "returns a candidate whose campaign url matches the paramater" do
|
34
43
|
hrc = TwentySixteen::Candidate.find_by_url("https://www.hillaryclinton.com/")
|