cstock 0.5.0 → 0.5.1

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: 0396bc11b41a947ddbcef36f1ac9eb01302c8ddd
4
- data.tar.gz: 4361d7248eeeb9a096af43045dc893ed454b271d
3
+ metadata.gz: 387ed4929610308f06eff131dfb90d4b346b0ac9
4
+ data.tar.gz: 86440cee74bcf3998f83f6f3f2239133cb629f80
5
5
  SHA512:
6
- metadata.gz: da8a1fd32a80ba4a716a6a3832e26002e5d5349d89ff171b737c6c6cd526e4011013ce1d5a6cef82ca78615667f7d084c356bb914f093da56ae03b44351000be
7
- data.tar.gz: 71810a5d5016a8a7490790930dee3a0ca74d6b74d2ec2f4247c25c53889b24d573de939c340323a65f17ec58f5757064a372db4a63168a8ee37048744cdffc41
6
+ metadata.gz: 942dddc69faec6dc7278400522e940a48357127df8d90e7bd0bda1856809ec71edd2d88821e61ef79ae53eb63f1bac485d09b8305c3e83e43e9e5c38e2fb625c
7
+ data.tar.gz: 6ac939d2298a2cea96cb3b026cce97a6378abf5f97ee24f7a94e5aa96134eb879f2419bd4df1e694eb66584ad12b32b40feb347e907fa418f4b5d19b36aa1268
data/README.md CHANGED
@@ -34,8 +34,20 @@ stock = CStock::Stock.new('600000')
34
34
  stock.name #=> 浦发银行
35
35
  stock.股票名 #=> 浦发银行
36
36
  stock. open_price #=> 16.00
37
+
38
+ # wrong stock code, its attrs will be nil
39
+ stock = CStock::Stock.new('错误的')
40
+ stock.name #=> nil
41
+
42
+ # refresh data
43
+ stock.refresh
44
+
45
+ # refresh multi stocks at one quote
46
+ CStock::Stock.refresh([stock1, stock2])
37
47
  ```
38
48
 
49
+ Read spec for more usage.
50
+
39
51
  ## in terminal
40
52
 
41
53
  ```bash
@@ -77,5 +89,4 @@ stock. open_price #=> 16.00
77
89
  ```
78
90
  # TODO
79
91
 
80
- * stock code without 'sh' or 'ss'
81
92
  * more indicator
data/bin/cstock CHANGED
@@ -11,4 +11,10 @@ end
11
11
  code = ARGV[0]
12
12
 
13
13
  stock = CStock::Stock.new(code)
14
- stock.description
14
+
15
+ if stock.name.nil?
16
+ puts "没有这支股票!"
17
+ puts "No This Stock!"
18
+ else
19
+ stock.description
20
+ end
@@ -85,6 +85,7 @@ module CStock
85
85
  end
86
86
 
87
87
  def self.parse_stock_code(stock_code)
88
+ return "sz0" if /^\d{6}$/.match(stock_code).nil? # so it can continue quote and return nil
88
89
  prefix = (stock_code.to_i < 600000) ? "sz" : "sh"
89
90
  prefix + stock_code.to_s
90
91
  end
@@ -1,4 +1,4 @@
1
1
  # =>CStock::VERSION
2
2
  module CStock
3
- VERSION = '0.5.0'
3
+ VERSION = '0.5.1'
4
4
  end
@@ -77,4 +77,13 @@ describe CStock::Stock do
77
77
  expect(s2.name).to eq("浦发银行")
78
78
  end
79
79
  end
80
+
81
+ describe "wrong stock code" do
82
+ it "return nil when refresh" do
83
+ s = CStock::Stock.new("1")
84
+ expect(s.name).to eq(nil)
85
+ s = CStock::Stock.new("错误")
86
+ expect(s.name).to eq(nil)
87
+ end
88
+ end
80
89
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cstock
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aston Fu