mcoin 0.3.0 → 0.4.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: ea7433590b7f0979f367b292a76590eacd5db058
4
- data.tar.gz: d42319799e8e2248f12c1a52a2eeeed85ee69aca
3
+ metadata.gz: 49ab57d9100eb27a91c752e1ca71d72571d31cfa
4
+ data.tar.gz: e66056a6d6595342fb59062de0929bbe38710e7d
5
5
  SHA512:
6
- metadata.gz: 1d7b9d7616dcf7b429098dc2657da4e577eeec167c6ef7f84fbd78fa54d8f4a35a0cff8dcea9ce4a91b18f916538c5b2621bbdaa1580d258c02ab7d4cbb2a5a8
7
- data.tar.gz: 698c2c86862ea27a2e4a32f60168a04d0423a4102fd27f3b9e47a7ececde1b5ad6fd57e08d2ffddfe5adc85f0733f0b9169375652e41b7cc877f4bffc7fd07e8
6
+ metadata.gz: b82b09b1360b95b54af7db305522c35280e680928a2c6418235c7616493f752799b34ee160dbc845081819127249cf0046966e55a1163a0ae1f747ba18022684
7
+ data.tar.gz: 366117743778be55ca0c074e34df2d88d5e520837aeb969ba286a1610bfd5836a49e9751712a5d74d8436181eec2bc29d1a24416fcf0342fdc609e08d2ee3b05
data/.gitignore CHANGED
@@ -6,3 +6,5 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
+
10
+ Gemfile.lock
data/README.md CHANGED
@@ -58,7 +58,7 @@ Please note, the ticker is async pull data from market, the timestamp may not to
58
58
  * [x] Fetch ticker
59
59
  * [x] Fetch in parallels
60
60
  * [x] Fetch from multiple market
61
- * [ ] Fetch multiple coin type via specify `pair`
61
+ * [x] Fetch multiple coin type via specify `pair`
62
62
  * [ ] Support more public API command
63
63
  * [ ] Improve printer
64
64
  * [ ] Generalize database save interface
@@ -12,7 +12,7 @@ module Mcoin
12
12
  autoload :Ticker, 'mcoin/command/ticker'
13
13
 
14
14
  autoload :HasMarket, 'mcoin/command/ext/has_market'
15
- autoload :HasType, 'mcoin/command/ext/has_type'
15
+ autoload :HasPair, 'mcoin/command/ext/has_pair'
16
16
  autoload :Saveable, 'mcoin/command/ext/saveable'
17
17
 
18
18
  class << self
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Mcoin
4
+ module Command
5
+ # :nodoc:
6
+ module HasPair
7
+ def self.included(base)
8
+ base.option(:multiple, :pair, '-P', '--pair BTC-USD')
9
+ end
10
+ end
11
+ end
12
+ end
@@ -5,7 +5,7 @@ module Mcoin
5
5
  # :nodoc:
6
6
  class Ticker < Base
7
7
  include HasMarket
8
- include HasType
8
+ include HasPair
9
9
  include Saveable
10
10
 
11
11
  attr_reader :option
@@ -19,7 +19,7 @@ module Mcoin
19
19
  end
20
20
 
21
21
  def print
22
- tickers = Parallel.map(markets, :fetch).map(&:to_ticker)
22
+ tickers = Parallel.map(markets, :fetch).compact.map(&:to_ticker)
23
23
  Printer.new(tickers).print
24
24
  end
25
25
 
@@ -29,9 +29,17 @@ module Mcoin
29
29
 
30
30
  def markets
31
31
  @markets ||= option.market.map do |name|
32
- Market
33
- .pick(name)
34
- .new(option.type, option.currency)
32
+ pairs.map do |pair|
33
+ Market
34
+ .pick(name)
35
+ .new(*pair)
36
+ end
37
+ end.flatten
38
+ end
39
+
40
+ def pairs
41
+ @pairs ||= (option.pair || ['BTC-USD']).uniq.map do |pair|
42
+ pair.split('-').map(&:to_sym)
35
43
  end
36
44
  end
37
45
 
@@ -39,8 +47,7 @@ module Mcoin
39
47
 
40
48
  def prepare
41
49
  super
42
- option.type = :BTC
43
- option.currency = :USD
50
+ option.pair ||= []
44
51
  end
45
52
  end
46
53
  end
@@ -22,7 +22,7 @@ module Mcoin
22
22
  @data ||= JSON.parse(Net::HTTP.get(uri))
23
23
  self
24
24
  rescue JSON::ParserError
25
- raise if @retries >= 3
25
+ return nil if @retries >= 3
26
26
  @retries += 1
27
27
  retry
28
28
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Mcoin
4
- VERSION = '0.3.0'
4
+ VERSION = '0.4.0'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mcoin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - 蒼時弦也
@@ -50,7 +50,6 @@ files:
50
50
  - ".rubocop.yml"
51
51
  - ".travis.yml"
52
52
  - Gemfile
53
- - Gemfile.lock
54
53
  - README.md
55
54
  - Rakefile
56
55
  - bin/console
@@ -61,7 +60,7 @@ files:
61
60
  - lib/mcoin/command/base.rb
62
61
  - lib/mcoin/command/common.rb
63
62
  - lib/mcoin/command/ext/has_market.rb
64
- - lib/mcoin/command/ext/has_type.rb
63
+ - lib/mcoin/command/ext/has_pair.rb
65
64
  - lib/mcoin/command/ext/saveable.rb
66
65
  - lib/mcoin/command/ticker.rb
67
66
  - lib/mcoin/data.rb
@@ -1,26 +0,0 @@
1
- PATH
2
- remote: .
3
- specs:
4
- mcoin (0.3.0)
5
-
6
- GEM
7
- remote: https://rubygems.org/
8
- specs:
9
- coderay (1.1.2)
10
- method_source (0.9.0)
11
- pry (0.11.3)
12
- coderay (~> 1.1.0)
13
- method_source (~> 0.9.0)
14
- rake (10.5.0)
15
-
16
- PLATFORMS
17
- ruby
18
-
19
- DEPENDENCIES
20
- bundler (~> 1.16)
21
- mcoin!
22
- pry
23
- rake (~> 10.0)
24
-
25
- BUNDLED WITH
26
- 1.16.1
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Mcoin
4
- module Command
5
- # :nodoc:
6
- module HasType
7
- def self.included(base)
8
- base.option(:single, :type, '-t', '--type TYPE',
9
- Mcoin::TYPES, "Available: #{Mcoin::TYPES.join(', ')}")
10
- base.option(:single, :currency, '-c', '--currency CURRENCY',
11
- Mcoin::CURRENCY, "Available: #{Mcoin::CURRENCY.join(', ')}")
12
- end
13
- end
14
- end
15
- end