lita-onewheel-election-cnn 3.2.0 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b3bb1422abe3d459298c1eddf84b05980aa807c0
4
- data.tar.gz: f263abdc2c27528407fae3b274c1d4e296bbb27d
3
+ metadata.gz: ffe46ecc24acb12499fd220c6894dc32049b0af4
4
+ data.tar.gz: 5a413221549f207f01761a66a1beee902b1b89e7
5
5
  SHA512:
6
- metadata.gz: 9d578ac031eb79186d3ffb39c2aefd86dfdd672e7f81777947a83d763f88ec29a3fa2aeeac2c1da71086d1963e3a050350c30d84708f1085793614d3b8aa37be
7
- data.tar.gz: 0b026e66640dec66a32dd109d113b535a75a7620872a06ae5dcbbcb058c555ca6cdc9920fee5b53394fddd987f61fe0612fcb1a5461f5ba8b0d8335b91bbb742
6
+ metadata.gz: ef4c2a4c1f89ad4a2f26dd07d6514ff0b181350920eb2d53616fd31ed552a8b49ebaf9c63868c6ade7ab0efb75e4bb31c96d7db00a23e6d5d510127eec208f96
7
+ data.tar.gz: aee9ef5bbca0369f139b9cf4087b70a521c5289d1b02532afd73acd08b7806bebe85e39634ae891fba24d69fc31c8143dd754659809c5ad7da211e4f37442980
@@ -21,6 +21,11 @@ module Lita
21
21
  :election_by_state,
22
22
  command: true
23
23
 
24
+ route /^ansielection$/i,
25
+ :ansielection,
26
+ command: true,
27
+ help: {'ansielection' => 'pretty colors'}
28
+
24
29
  def election(response)
25
30
  Lita.logger.debug 'Getting election data'
26
31
  results = JSON.parse(RestClient.get('http://data.cnn.com/ELECTION/2016/full/P.full.json'))
@@ -124,6 +129,29 @@ module Lita
124
129
  end
125
130
  end
126
131
 
132
+ def ansielection(response)
133
+ results = JSON.parse(RestClient.get('http://data.cnn.com/ELECTION/2016/full/P.full.json'))
134
+
135
+ reds = 0
136
+ blues = 0
137
+ results['candidates'].each do |candidate|
138
+ if candidate['lname'] == 'Clinton'
139
+ blues = candidate['evotes'] / 10
140
+ end
141
+ if candidate['lname'] == 'Trump'
142
+ reds = candidate['evotes'] / 10
143
+ end
144
+ end
145
+
146
+ reply = ''
147
+ extras = 54 - blues - reds
148
+ blues.times { reply += 'b' }
149
+ extras.times { reply += '-'}
150
+ reds.times { reply += 'r' }
151
+
152
+ response.reply reply
153
+ end
154
+
127
155
  Lita.register_handler(self)
128
156
  end
129
157
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'lita-onewheel-election-cnn'
3
- spec.version = '3.2.0'
3
+ spec.version = '3.3.0'
4
4
  spec.authors = ['Andrew Kreps']
5
5
  spec.email = ['andrew.kreps@gmail.com']
6
6
  spec.description = %q{Lita interface to CNN's 2016 Presidential Election JSON.}
@@ -5,6 +5,7 @@ describe Lita::Handlers::OnewheelElectionCnn, lita_handler: true do
5
5
  it { is_expected.to route_command('e') }
6
6
  it { is_expected.to route_command('election ny') }
7
7
  it { is_expected.to route_command('e ny') }
8
+ it { is_expected.to route_command('ansielection') }
8
9
 
9
10
  it 'shows the current election results' do
10
11
  mock = File.open('spec/fixtures/election.json').read
@@ -50,4 +51,9 @@ describe Lita::Handlers::OnewheelElectionCnn, lita_handler: true do
50
51
  expect(replies[1]).to eq("Hillary Clinton: 0.0%")
51
52
  expect(replies[2]).to eq("Donald Trump: 0.0%")
52
53
  end
54
+
55
+ it 'ansis' do
56
+ send_command 'ansielection'
57
+ expect(replies.last).to eq('bbbbbbbbbbbb--------------------------rrrrrrrrrrrrrrrr')
58
+ end
53
59
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-onewheel-election-cnn
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0
4
+ version: 3.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kreps