lita-coin-info 0.1.0 → 0.2.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
- SHA1:
3
- metadata.gz: db77c0e2e379bd528c6128c15f4aee27d55f1752
4
- data.tar.gz: ac0424987a96863a1b3c7ffaccfddea67ffbee4e
2
+ SHA256:
3
+ metadata.gz: c4eacf071bc4fca8492bcd8833ad64c5f5cf297ce5ea859cb280cc7833c53e86
4
+ data.tar.gz: ebf0cb2bd440407efc02d7203a07c0ce1016585958517c58e651bd0a78d0d344
5
5
  SHA512:
6
- metadata.gz: 071ecea61bb6fe27d3d864b9112c0776c954a33099fe0db3bf45c459fc0b00832a6667847d19e3d937b24be6cfb7d0a3503bf43b68a19252d13d98102fd260d6
7
- data.tar.gz: 3fe881df1dc8eefdc0c9a9eb747f927b09c7ee730168fc1ad7ba507c32d2d1c94fcd71986f83f6bdbd064631c502f3841fab2eeb558792efd982a9f58603974b
6
+ metadata.gz: 3cbce306bdb555c551960fc1deaec5dfe8d34ebb5d9096e08edfc98dbaff853bd55ff9b3a907380a320c9a19f7a076ba1c30cfaf3be605c2276fbfe82d7a27b9
7
+ data.tar.gz: 04daa0c4c3dd0d8faf391252304abadb4d9b69182e0d27e8f2bcda58bf924e8f69f1fcd83646e3d14b4c46db0d873785ccef2c104394094d1af9a24ef8877433
@@ -0,0 +1,10 @@
1
+ # Change Log
2
+
3
+ ## 0.2.0
4
+
5
+ - Add `<bot_name> diff` -> Get current difficulty target for BTC
6
+
7
+ ## 0.1.0
8
+
9
+ - Initial Release
10
+ - `<bot_name> COIN price` -> Get current current COIN (btc, ltc, eth) spot price from coinbase.
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2017 Andrew Bowerman
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
+
1
2
  # lita-coin-info
3
+ [![Gem Version](https://badge.fury.io/rb/lita-coin-info.svg)](https://badge.fury.io/rb/lita-coin-info)
2
4
 
3
5
  A Lita handler for getting cryptocurrency info
4
6
 
@@ -15,10 +17,6 @@ See https://docs.lita.io/getting-started/plugins/ for more info.
15
17
  ## Usage
16
18
 
17
19
  Works with BTC, ETH, and LTC
18
- ```
19
- <bot> <coin> price
20
- ```
21
- ->
22
- ```
23
- $XX.XX
24
- ```
20
+
21
+ `<bot_name> COIN price` -> Get current current COIN (btc, ltc, eth) spot price from coinbase.
22
+ `<bot_name> diff` -> Get current difficulty target for BTC
@@ -2,19 +2,38 @@ module Lita
2
2
  module Handlers
3
3
  class CoinInfo < Handler
4
4
 
5
- route(/^(btc|ltc|eth) price/, :coin, command: true, help: {
6
- 'COIN price' => 'Replies back with current COIN (btc, ltc, eth) spot price from coinbase.'
5
+ route(/^(btc|ltc|eth) price/, :price, command: true, help: {
6
+ 'COIN price' => 'Get current current COIN (btc, ltc, eth) spot price from coinbase.'
7
7
  })
8
8
 
9
- def coin response
9
+ def price response
10
10
  coin = response.matches[0][0]
11
11
  currency_pair = "#{ coin }-USD"
12
12
  url = "https://api.coinbase.com/v2/prices/#{ currency_pair }/spot"
13
13
 
14
+ price_json = get_and_parse_data url
15
+
16
+ response.reply "$#{ price_json[:data][:amount] }"
17
+ end
18
+
19
+ route(/^(diff)/, :diff, command: true, help: {
20
+ 'diff' => 'Get current difficulty target.'
21
+ })
22
+
23
+ def diff response
24
+ url = 'https://blockchain.info/q/getdifficulty'
25
+
26
+ diff = get_data url
27
+
28
+ response.reply diff.to_f.to_s
29
+ end
30
+
31
+ def get_data url
14
32
  HTTParty.get(url, format: :plain)
15
- http_response = JSON.parse HTTParty.get(url).to_s, symbolize_names: true
33
+ end
16
34
 
17
- response.reply "$#{ http_response[:data][:amount] }"
35
+ def get_and_parse_data url
36
+ JSON.parse HTTParty.get(url, format: :plain), symbolize_names: true
18
37
  end
19
38
 
20
39
  Lita.register_handler(self)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "lita-coin-info"
3
- spec.version = "0.1.0"
3
+ spec.version = "0.2.0"
4
4
  spec.authors = ["Andrew Bowerman"]
5
5
  spec.email = ["me@andrewbowerman.com"]
6
6
  spec.description = "A Lita handler for getting cryptocurrency info"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-coin-info
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Bowerman
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-08 00:00:00.000000000 Z
11
+ date: 2017-11-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita
@@ -116,7 +116,9 @@ extensions: []
116
116
  extra_rdoc_files: []
117
117
  files:
118
118
  - ".gitignore"
119
+ - CHANGELOG.md
119
120
  - Gemfile
121
+ - LICENSE
120
122
  - README.md
121
123
  - Rakefile
122
124
  - lib/lita-coin-info.rb
@@ -147,7 +149,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
149
  version: '0'
148
150
  requirements: []
149
151
  rubyforge_project:
150
- rubygems_version: 2.6.11
152
+ rubygems_version: 2.7.1
151
153
  signing_key:
152
154
  specification_version: 4
153
155
  summary: A Lita handler for getting cryptocurrency info