lita-onewheel-finance 0.5.0 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86924c83a1b54b7034f09552a2ff66c46723de2baa4c3b061efbdfc9bcb39d70
4
- data.tar.gz: 4b2908349083d6dc6c740fd5c2ddc4b18e7cd90d6180fc672644c09be07530cc
3
+ metadata.gz: '0650867d30743080da877fdbad93bd7ddbd9f525a7921fa566c7da0a64d9850c'
4
+ data.tar.gz: 0ad45310e357e2e5ed9b2e10bb1721cd0ba91da863507ff5a4dc728b10f14bd9
5
5
  SHA512:
6
- metadata.gz: 750a2b4e836adfaf7bea9913051037a6277c8f26787861fe14ae38389c5479c5e97e8412a9a1cd3251d4c6ad451914cf42776c400d1e97babf88adcdcdbfb4d9
7
- data.tar.gz: d67f291c283fc66939cb3a3c59b2954247f7d807c4ba208c8beda96bc4ac6c5c504823dae63f31d944f1f43a6a3cbb51ba40f718a31f39eeb15bc725dd5aed6f
6
+ metadata.gz: 495d556d163bf461fa1d521ed7176054636a591c1fb2772fcad41634740bc54d5bc4c8d8a464dc936a58d9eb2d6066336fed012bed60e292949bdc5344b3e677
7
+ data.tar.gz: 9b7bc63735e850c56bfe52dd83d39cce2979be507b400237dea7b5f30b50ba35fad55dd5f24fe220b9f927da241295ac65dd73a41426f23bc93a2cc99b933be6
@@ -21,7 +21,23 @@ class IrcColors
21
21
  @reset = prefix
22
22
 
23
23
  class << self
24
- attr_reader :white, :black, :blue, :green, :red, :brown, :purple, :orange, :yellow, :lime, :teal, :aqua, :royal, :pink, :grey, :silver, :reset
24
+ attr_reader :white,
25
+ :black,
26
+ :blue,
27
+ :green,
28
+ :red,
29
+ :brown,
30
+ :purple,
31
+ :orange,
32
+ :yellow,
33
+ :lime,
34
+ :teal,
35
+ :aqua,
36
+ :royal,
37
+ :pink,
38
+ :grey,
39
+ :silver,
40
+ :reset
25
41
  end
26
42
 
27
43
  def initialize
@@ -68,7 +84,7 @@ class AlphaVantageQuote
68
84
  end
69
85
 
70
86
  class WorldTradeDataQuote
71
- attr_reader :open, :high, :low, :price, :volume, :trading_day, :prev_close, :change, :change_percent, :exchange, :error, :name, :message
87
+ attr_reader :open, :high, :low, :price, :volume, :trading_day, :prev_close, :change, :change_percent, :exchange, :error, :name, :message, :is_index
72
88
  attr_accessor :symbol
73
89
 
74
90
  def initialize(symbol, api_key)
@@ -80,6 +96,12 @@ class WorldTradeDataQuote
80
96
  (@exchange, @symbol) = @symbol.split /:/
81
97
  end
82
98
 
99
+ if @symbol['^']
100
+ @is_index = true
101
+ else
102
+ @is_index = false
103
+ end
104
+
83
105
  self.call_api
84
106
 
85
107
  hash = JSON.parse(@response)
@@ -137,6 +159,10 @@ class WorldTradeDataQuote
137
159
  @name = quote[key]
138
160
  end
139
161
  end
162
+
163
+ def is_index?
164
+ is_index
165
+ end
140
166
  end
141
167
 
142
168
  # Let's see what we can get from the api.
@@ -202,13 +228,18 @@ module Lita
202
228
  str = "`#{stock.symbol}` not found on any stock exchange."
203
229
  end
204
230
  else
205
- str = "#{IrcColors::grey}#{stock.exchange} - #{IrcColors::reset}#{stock.symbol}: #{IrcColors::blue}$#{stock.price}#{IrcColors::reset} "
231
+ dollar_sign = '$'
232
+ if stock.is_index?
233
+ dollar_sign = ''
234
+ end
235
+
236
+ str = "#{IrcColors::grey}#{stock.exchange} - #{IrcColors::reset}#{stock.symbol}: #{IrcColors::blue}#{dollar_sign}#{stock.price}#{IrcColors::reset} "
206
237
  if stock.change >= 0
207
238
  # if irc
208
- str += "#{IrcColors::green} ⬆$#{stock.change}#{IrcColors::reset}, #{IrcColors::green}#{stock.change_percent}%#{IrcColors::reset} "
239
+ str += "#{IrcColors::green} ⬆#{dollar_sign}#{stock.change}#{IrcColors::reset}, #{IrcColors::green}#{stock.change_percent}%#{IrcColors::reset} "
209
240
  str += "#{IrcColors::grey}(#{stock.name})#{IrcColors::reset}"
210
241
  else
211
- str += "#{IrcColors::red} ↯$#{stock.change}#{IrcColors::reset}, #{IrcColors::red}#{stock.change_percent}%#{IrcColors::reset} "
242
+ str += "#{IrcColors::red} ↯#{dollar_sign}#{stock.change}#{IrcColors::reset}, #{IrcColors::red}#{stock.change_percent}%#{IrcColors::reset} "
212
243
  str += "#{IrcColors::grey}(#{stock.name})#{IrcColors::reset}"
213
244
  end
214
245
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-onewheel-finance"
3
- spec.version = "0.5.0"
3
+ spec.version = "0.6.0"
4
4
  spec.authors = ["Andrew Kreps"]
5
5
  spec.email = ["andrew.kreps@gmail.com"]
6
6
  spec.description = "Wee li'l stock quote bot"
@@ -0,0 +1,32 @@
1
+ {
2
+ "symbols_requested": 1,
3
+ "symbols_returned": 1,
4
+ "data": [
5
+ {
6
+ "symbol": "^DJI",
7
+ "name": "Dow Jones Industrial Average",
8
+ "currency": "N/A",
9
+ "price": "25766.64",
10
+ "price_open": "26526.00",
11
+ "day_high": "26775.31",
12
+ "day_low": "25752.82",
13
+ "52_week_high": "29568.57",
14
+ "52_week_low": "24680.57",
15
+ "day_change": "-1190.95",
16
+ "change_pct": "-4.42",
17
+ "close_yesterday": "26957.59",
18
+ "market_cap": "N/A",
19
+ "volume": "664922874",
20
+ "volume_avg": "N/A",
21
+ "shares": "N/A",
22
+ "stock_exchange_long": "",
23
+ "stock_exchange_short": "INDEXDJX",
24
+ "timezone": "EST",
25
+ "timezone_name": "America/New_York",
26
+ "gmt_offset": "-18000",
27
+ "last_trade_time": "2020-02-27 16:17:34",
28
+ "pe": "N/A",
29
+ "eps": "N/A"
30
+ }
31
+ ]
32
+ }
@@ -31,6 +31,12 @@ describe Lita::Handlers::OnewheelFinance, lita_handler: true do
31
31
  expect(replies.last).to include("\u000314NASDAQ - \u0003LULU: \u000302$233.01\u0003")
32
32
  end
33
33
 
34
+ it 'removes $ from ^ reqs' do
35
+ mock_up 'worldtradedata-quote-dji'
36
+ send_command 'q ^dji'
37
+ expect(replies.last).to include("\u000314INDEXDJX - \u0003^DJI: \u00030225766.64\u0003 \u000304 ↯-1190.95\u0003, \u000304-4.42%\u0003 \u000314(Dow Jones Industrial Average)\u0003")
38
+ end
39
+
34
40
  #it 'errors' do
35
41
  # mock_up 'worldtradedata-error'
36
42
  # send_command 'quote in'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-onewheel-finance
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kreps
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-03 00:00:00.000000000 Z
11
+ date: 2020-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita
@@ -142,6 +142,7 @@ files:
142
142
  - spec/fixtures/alphavantage-quote-down.json
143
143
  - spec/fixtures/effr.html
144
144
  - spec/fixtures/worldtradedata-error.json
145
+ - spec/fixtures/worldtradedata-quote-dji.json
145
146
  - spec/fixtures/worldtradedata-quote-down.json
146
147
  - spec/fixtures/worldtradedata-quote-up.json
147
148
  - spec/fixtures/worldtradedata-search-1.json
@@ -176,6 +177,7 @@ test_files:
176
177
  - spec/fixtures/alphavantage-quote-down.json
177
178
  - spec/fixtures/effr.html
178
179
  - spec/fixtures/worldtradedata-error.json
180
+ - spec/fixtures/worldtradedata-quote-dji.json
179
181
  - spec/fixtures/worldtradedata-quote-down.json
180
182
  - spec/fixtures/worldtradedata-quote-up.json
181
183
  - spec/fixtures/worldtradedata-search-1.json