lita-onewheel-election-cnn 5.0.1 → 5.1.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: 47b44b4ebd1e5b3153867585b0859aa47676b483
4
- data.tar.gz: 17db4eaf216708bf308e84199f02e295a1525c4f
3
+ metadata.gz: 8ef69c78d23943b79a6fdc916296f49169e1b4d4
4
+ data.tar.gz: d9cd668c9c77381af8f61710ca2f43d145e3fef6
5
5
  SHA512:
6
- metadata.gz: 479d4a23f39c1f8183ddc4d5280518d505d18be621fa3f98f361e9e6d5bebe0c20b7c1182f87a9a4efeb7f79d16b10f66d52bd52663b1210cd072b5dc737e84e
7
- data.tar.gz: 9c5deba4678cc842d1ef263b2a35765038b86f4a327472ad7814a7f4af9b2fddace1e9898375296d30e85e44743d754e6f3d6cc9e4c34f4a4a326008ea930fa7
6
+ metadata.gz: fe9eb10292cf0f03339b662395be448beff61c54656548693ec08ac8b098700633be37dd89149618177f50f6640e0d4913bd2b3bc6e15b61d9901599fb568dd2
7
+ data.tar.gz: fbcff4cba1fe1cde67edbe862dc2d4079b5baa80827eb623b013ae7a96b187c2408214fd3b61f794008d0ba2347d4537b32102d261cea6ca07d91d5c60f1a6ea
@@ -21,11 +21,6 @@ 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
-
29
24
  def election(response)
30
25
  Lita.logger.debug 'Getting election data'
31
26
  results = JSON.parse(RestClient.get('http://data.cnn.com/ELECTION/2016/full/P.full.json'))
@@ -50,6 +45,8 @@ module Lita
50
45
 
51
46
  blueredstr = get_blueredstr(votes)
52
47
  response.reply "\x0300Clinton #{votes['blue']['percentage']}% #{votes['blue']['popular']} |#{blueredstr}\x0300| Trump #{votes['red']['percentage']}% #{votes['red']['popular']}"
48
+
49
+ ansielection(response, results)
53
50
  end
54
51
 
55
52
  def get_blueredstr(votes)
@@ -166,9 +163,7 @@ module Lita
166
163
  end
167
164
  end
168
165
 
169
- def ansielection(response)
170
- results = JSON.parse(RestClient.get('http://data.cnn.com/ELECTION/2016/full/P.full.json'))
171
-
166
+ def ansielection(response, results)
172
167
  reds = 0
173
168
  blues = 0
174
169
  results['candidates'].each do |candidate|
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'lita-onewheel-election-cnn'
3
- spec.version = '5.0.1'
3
+ spec.version = '5.1.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,7 +5,6 @@ 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') }
9
8
 
10
9
  it 'shows the current election results' do
11
10
  mock = File.open('spec/fixtures/election.json').read
@@ -13,6 +12,7 @@ describe Lita::Handlers::OnewheelElectionCnn, lita_handler: true do
13
12
  send_command 'election'
14
13
  expect(replies[0]).to eq("\x0300United States 2016 Presidential Election, 1% reporting.")
15
14
  expect(replies[1]).to eq("\x0300Clinton 0.0% 0 |\u000312\u000300--------------------------------------------------\u000304\u000300| Trump 0.0% 0")
15
+ expect(replies[2]).to eq("\x0300Clinton 0 |\u000312\u000300----------------------------👽-------------------------\u000304█\u000300| Trump 19")
16
16
  end
17
17
 
18
18
  it 'shows a winner' do
@@ -46,11 +46,4 @@ describe Lita::Handlers::OnewheelElectionCnn, lita_handler: true do
46
46
  expect(replies[0]).to eq("\x0300NEW YORK, 29 electoral votes, 0% reporting")
47
47
  expect(replies[1]).to eq("\x0300Clinton 0.0% 0 |\u000312\u000300--------------------------------------------------\u000304\u000300| Trump 0.0% 0")
48
48
  end
49
-
50
- it 'ansis' do
51
- mock = File.open('spec/fixtures/election.json').read
52
- allow(RestClient).to receive(:get) { mock }
53
- send_command 'ansielection'
54
- expect(replies.last).to eq("\x0300Clinton 0 |\u000312\u000300----------------------------👽-------------------------\u000304█\u000300| Trump 19")
55
- end
56
49
  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: 5.0.1
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kreps