lita-bitcoin 1.0.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 +7 -0
- data/.gitignore +1 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +49 -0
- data/LICENSE +19 -0
- data/README.md +21 -0
- data/lib/lita-bitcoin.rb +1 -0
- data/lib/lita/handlers/bitcoin.rb +41 -0
- data/lita-bitcoin.gemspec +21 -0
- data/spec/lita/handlers/bitcoin_spec.rb +17 -0
- data/spec/spec_helper.rb +2 -0
- metadata +99 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a7ab46be40c0eb4634a63e118def1094c0185a5f
|
4
|
+
data.tar.gz: be48ad8972c78085eb87cf71db4ae5328a180bc7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c613e08b97469e6ff547802b6832acde5bc64fa33037a736d4d3cba725b46557f57beb914fd5a6c86398dd54af741bde7da7fcf2d70c707bac311a38cdb0295e
|
7
|
+
data.tar.gz: 05010b627c3ede64fd7901e3d14b0a4ab6d948c75eaec884e6b8ecb9d20ef975046630af6d383e9b2ceb63a18e89990f23f47754c103d82cd11d443b478d7c18
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
*.gem
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
lita-bitcoin (1.0.0)
|
5
|
+
lita (~> 2.0)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
daemons (1.1.9)
|
11
|
+
diff-lcs (1.2.5)
|
12
|
+
eventmachine (1.0.3)
|
13
|
+
faraday (0.9.0)
|
14
|
+
multipart-post (>= 1.2, < 3)
|
15
|
+
lita (2.7.2)
|
16
|
+
bundler (>= 1.3)
|
17
|
+
faraday (>= 0.8.7)
|
18
|
+
multi_json (>= 1.7.7)
|
19
|
+
rack (>= 1.5.2)
|
20
|
+
redis-namespace (>= 1.3.0)
|
21
|
+
thin (>= 1.5.1)
|
22
|
+
thor (>= 0.18.1)
|
23
|
+
multi_json (1.8.4)
|
24
|
+
multipart-post (2.0.0)
|
25
|
+
rack (1.5.2)
|
26
|
+
redis (3.0.7)
|
27
|
+
redis-namespace (1.4.1)
|
28
|
+
redis (~> 3.0.4)
|
29
|
+
rspec (2.14.1)
|
30
|
+
rspec-core (~> 2.14.0)
|
31
|
+
rspec-expectations (~> 2.14.0)
|
32
|
+
rspec-mocks (~> 2.14.0)
|
33
|
+
rspec-core (2.14.7)
|
34
|
+
rspec-expectations (2.14.5)
|
35
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
36
|
+
rspec-mocks (2.14.5)
|
37
|
+
thin (1.6.1)
|
38
|
+
daemons (>= 1.0.9)
|
39
|
+
eventmachine (>= 1.0.0)
|
40
|
+
rack (>= 1.0.0)
|
41
|
+
thor (0.18.1)
|
42
|
+
|
43
|
+
PLATFORMS
|
44
|
+
ruby
|
45
|
+
|
46
|
+
DEPENDENCIES
|
47
|
+
bundler (~> 1.3)
|
48
|
+
lita-bitcoin!
|
49
|
+
rspec (~> 2.14)
|
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2014 Marcel de Graaf
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# lita-bitcoin
|
2
|
+
|
3
|
+
**lita-bitcoin** is a handler for [Lita](https://github.com/jimmycuadra/lita) that checks the current exchange rate of BTC/USD.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add lita-bitcoin to your Lita instance's Gemfile:
|
8
|
+
|
9
|
+
``` ruby
|
10
|
+
gem "lita-bitcoin"
|
11
|
+
```
|
12
|
+
|
13
|
+
## Usage
|
14
|
+
|
15
|
+
```
|
16
|
+
Lita: btc
|
17
|
+
```
|
18
|
+
|
19
|
+
## License
|
20
|
+
|
21
|
+
[MIT](http://opensource.org/licenses/MIT)
|
data/lib/lita-bitcoin.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "lita/handlers/bitcoin"
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "lita"
|
2
|
+
|
3
|
+
module Lita
|
4
|
+
module Handlers
|
5
|
+
class Bitcoin < Handler
|
6
|
+
|
7
|
+
URL = "http://data.mtgox.com/api/1/BTCUSD/ticker"
|
8
|
+
|
9
|
+
route(/btc/i, :reply, command: true, help: {
|
10
|
+
"btc" => "Returns the current BTC/USD exchange rate."
|
11
|
+
})
|
12
|
+
|
13
|
+
def self.default_config(handler_config)
|
14
|
+
end
|
15
|
+
|
16
|
+
def reply(response)
|
17
|
+
response.reply "1 BTC is currently worth #{rate}"
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def rate
|
23
|
+
if data && data["return"] && data["return"]["sell"]
|
24
|
+
data["return"]["sell"]["display"]
|
25
|
+
else
|
26
|
+
"UNKNOWN"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def data
|
31
|
+
MultiJson.load(ticker_response.body)
|
32
|
+
end
|
33
|
+
|
34
|
+
def ticker_response
|
35
|
+
http.get(URL)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
Lita.register_handler(Bitcoin)
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
Gem::Specification.new do |spec|
|
2
|
+
spec.name = "lita-bitcoin"
|
3
|
+
spec.version = "1.0.0"
|
4
|
+
spec.authors = ["Marcel de Graaf"]
|
5
|
+
spec.email = ["mail@marceldegraaf.net"]
|
6
|
+
spec.description = %q{A Lita handler to check the current BTC/USD exchange rate}
|
7
|
+
spec.summary = %q{A Lita handler to check the current BTC/USD exchange rate}
|
8
|
+
spec.homepage = "https://github.com/marceldegraaf/lita-bitcoin"
|
9
|
+
spec.license = "MIT"
|
10
|
+
spec.metadata = { "lita_plugin_type" => "handler" }
|
11
|
+
|
12
|
+
spec.files = `git ls-files`.split($/)
|
13
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
14
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
15
|
+
spec.require_paths = ["lib"]
|
16
|
+
|
17
|
+
spec.add_runtime_dependency "lita", "~> 2.0"
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
20
|
+
spec.add_development_dependency "rspec", "~> 2.14"
|
21
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Lita::Handlers::Bitcoin, lita_handler: true do
|
4
|
+
it { routes_command("btc").to(:reply) }
|
5
|
+
|
6
|
+
let!(:body) { %Q{ {"result":"success","return":{"high":{"value":"600.00000","value_int":"60000000","display":"$600.00","display_short":"$600.00","currency":"USD"},"low":{"value":"511.77000","value_int":"51177000","display":"$511.77","display_short":"$511.77","currency":"USD"},"avg":{"value":"552.76876","value_int":"55276876","display":"$552.77","display_short":"$552.77","currency":"USD"},"vwap":{"value":"549.70256","value_int":"54970256","display":"$549.70","display_short":"$549.70","currency":"USD"},"vol":{"value":"21148.57793549","value_int":"2114857793549","display":"21,148.58\u00a0BTC","display_short":"21,148.58\u00a0BTC","currency":"BTC"},"last_local":{"value":"527.10000","value_int":"52710000","display":"$527.10","display_short":"$527.10","currency":"USD"},"last_orig":{"value":"527.10000","value_int":"52710000","display":"$527.10","display_short":"$527.10","currency":"USD"},"last_all":{"value":"527.10000","value_int":"52710000","display":"$527.10","display_short":"$527.10","currency":"USD"},"last":{"value":"527.10000","value_int":"52710000","display":"$527.10","display_short":"$527.10","currency":"USD"},"buy":{"value":"527.10000","value_int":"52710000","display":"$527.10","display_short":"$527.10","currency":"USD"},"sell":{"value":"533.04755","value_int":"53304755","display":"$533.05","display_short":"$533.05","currency":"USD"},"item":"BTC","now":"1392212682920166"}} } }
|
7
|
+
let!(:response) { double(:response, body: body) }
|
8
|
+
|
9
|
+
describe "#btc" do
|
10
|
+
it "replies to the 'btc' command" do
|
11
|
+
Lita::Handlers::Bitcoin.any_instance.stub(:ticker_response).and_return(response)
|
12
|
+
|
13
|
+
send_command("btc")
|
14
|
+
expect(replies.last).to eq("1 BTC is currently worth $533.05")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,99 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: lita-bitcoin
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Marcel de Graaf
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-02-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: lita
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.3'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.14'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.14'
|
55
|
+
description: A Lita handler to check the current BTC/USD exchange rate
|
56
|
+
email:
|
57
|
+
- mail@marceldegraaf.net
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- .gitignore
|
63
|
+
- Gemfile
|
64
|
+
- Gemfile.lock
|
65
|
+
- LICENSE
|
66
|
+
- README.md
|
67
|
+
- lib/lita-bitcoin.rb
|
68
|
+
- lib/lita/handlers/bitcoin.rb
|
69
|
+
- lita-bitcoin.gemspec
|
70
|
+
- spec/lita/handlers/bitcoin_spec.rb
|
71
|
+
- spec/spec_helper.rb
|
72
|
+
homepage: https://github.com/marceldegraaf/lita-bitcoin
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata:
|
76
|
+
lita_plugin_type: handler
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options: []
|
79
|
+
require_paths:
|
80
|
+
- lib
|
81
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 2.0.0
|
94
|
+
signing_key:
|
95
|
+
specification_version: 4
|
96
|
+
summary: A Lita handler to check the current BTC/USD exchange rate
|
97
|
+
test_files:
|
98
|
+
- spec/lita/handlers/bitcoin_spec.rb
|
99
|
+
- spec/spec_helper.rb
|