mcoin 0.2.1 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +2 -2
- data/README.md +16 -0
- data/lib/mcoin.rb +1 -0
- data/lib/mcoin/parallel.rb +6 -0
- data/lib/mcoin/subscriber.rb +30 -0
- data/lib/mcoin/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ea7433590b7f0979f367b292a76590eacd5db058
|
4
|
+
data.tar.gz: d42319799e8e2248f12c1a52a2eeeed85ee69aca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d7b9d7616dcf7b429098dc2657da4e577eeec167c6ef7f84fbd78fa54d8f4a35a0cff8dcea9ce4a91b18f916538c5b2621bbdaa1580d258c02ab7d4cbb2a5a8
|
7
|
+
data.tar.gz: 698c2c86862ea27a2e4a32f60168a04d0423a4102fd27f3b9e47a7ececde1b5ad6fd57e08d2ffddfe5adc85f0733f0b9169375652e41b7cc877f4bffc7fd07e8
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -37,6 +37,22 @@ mcoin ticker -m Bitfinex -d monitor -e http://localhsot:8086
|
|
37
37
|
|
38
38
|
To get more information please use `-h` option.
|
39
39
|
|
40
|
+
### Subscriber
|
41
|
+
|
42
|
+
If you want to subscribe market in your project, you can use `Subscriber`
|
43
|
+
|
44
|
+
```ruby
|
45
|
+
require 'mcoin'
|
46
|
+
|
47
|
+
# Leave blank to subscribe all available market
|
48
|
+
subscriber = Mcoin::Subscriber.new([:Bitinfex], :BTC, :USD)
|
49
|
+
subscriber.start do |ticker|
|
50
|
+
# Deal with Mcoin::Data::Ticker object
|
51
|
+
end
|
52
|
+
```
|
53
|
+
|
54
|
+
Please note, the ticker is async pull data from market, the timestamp may not totally same when you receive it.
|
55
|
+
|
40
56
|
## Roadmap
|
41
57
|
|
42
58
|
* [x] Fetch ticker
|
data/lib/mcoin.rb
CHANGED
data/lib/mcoin/parallel.rb
CHANGED
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Mcoin
|
4
|
+
class Subscriber
|
5
|
+
attr_reader :markets
|
6
|
+
|
7
|
+
def initialize(picked = Market.available, type = :BTC, currency = :USD)
|
8
|
+
@markets = markets_from(picked, type, currency)
|
9
|
+
end
|
10
|
+
|
11
|
+
def start(interval = 1, &block)
|
12
|
+
loop do
|
13
|
+
Parallel.async(markets, :fetch) do |result|
|
14
|
+
yield result.to_ticker
|
15
|
+
end
|
16
|
+
sleep interval
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
protected
|
21
|
+
|
22
|
+
def markets_from(picked, type, currency)
|
23
|
+
@markets ||= picked.map do |name|
|
24
|
+
Market
|
25
|
+
.pick(name)
|
26
|
+
.new(type, currency)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/mcoin/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mcoin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- 蒼時弦也
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-04-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -74,6 +74,7 @@ files:
|
|
74
74
|
- lib/mcoin/market/kraken.rb
|
75
75
|
- lib/mcoin/parallel.rb
|
76
76
|
- lib/mcoin/printer.rb
|
77
|
+
- lib/mcoin/subscriber.rb
|
77
78
|
- lib/mcoin/version.rb
|
78
79
|
- mcoin.gemspec
|
79
80
|
homepage: https://github.com/elct9620/mcoin
|
@@ -95,7 +96,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
96
|
version: '0'
|
96
97
|
requirements: []
|
97
98
|
rubyforge_project:
|
98
|
-
rubygems_version: 2.6.
|
99
|
+
rubygems_version: 2.6.14
|
99
100
|
signing_key:
|
100
101
|
specification_version: 4
|
101
102
|
summary: The BTC market monitor tool
|