cstock 0.4.1 → 0.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Gemfile +4 -0
- data/Rakefile +1 -0
- data/lib/cstock/stock.rb +3 -0
- data/lib/cstock/version.rb +1 -1
- data/spec/cstock_spec.rb +3 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e0315ba814b65cfc27b1d1fabe2be64eba8c66c
|
4
|
+
data.tar.gz: b94b807edac4e43126ad4db54443fd56ae5ab583
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 492074f1e2d41e73c6b0b0fb7c10c5cef7dad73c0c6e0b05cfd3ac5e64d4e284ea18e4030c87ab6d7aaebb65bfc0d59c2ac520ffd5d0a5c914d6b5e8f752d04a
|
7
|
+
data.tar.gz: da89bb54b5b05c6fd7990cb7e310c31a53b83eb6032a4775fb94932cc8a6fe4c641a1021c9adfb3f2ccaf640e8f82205d84ddcba742d70870adeb9707de7a8b9
|
data/.gitignore
CHANGED
data/Gemfile
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'bundler/gem_tasks'
|
data/lib/cstock/stock.rb
CHANGED
@@ -46,6 +46,8 @@ module CStock
|
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
|
+
##
|
50
|
+
# block can yield after each stock refresh
|
49
51
|
def self.refresh(stocks)
|
50
52
|
stocks = [stocks] if not stocks.respond_to?(:each)
|
51
53
|
stock_codes = stocks.map(&:code)
|
@@ -53,6 +55,7 @@ module CStock
|
|
53
55
|
quote(stock_codes) do |datas|
|
54
56
|
datas.each_with_index do |data, index|
|
55
57
|
stocks[index].set_fields data
|
58
|
+
yield stocks[index] if block_given?
|
56
59
|
end
|
57
60
|
end
|
58
61
|
stocks
|
data/lib/cstock/version.rb
CHANGED
data/spec/cstock_spec.rb
CHANGED
@@ -47,7 +47,9 @@ describe CStock::Stock do
|
|
47
47
|
it "refresh muti stocks at one quote" do
|
48
48
|
expect(@s.name).to eq("name")
|
49
49
|
expect(@s2.name).to eq("name")
|
50
|
-
CStock::Stock.refresh(@stocks)
|
50
|
+
CStock::Stock.refresh(@stocks) do |s|
|
51
|
+
expect(s.name).not_to eq("name")
|
52
|
+
end.each do |stock|
|
51
53
|
expect(@s.name).to eq("浦发银行")
|
52
54
|
expect(@s2.name).to eq("大北农")
|
53
55
|
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.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aston Fu
|
@@ -61,8 +61,10 @@ extra_rdoc_files: []
|
|
61
61
|
files:
|
62
62
|
- .gitignore
|
63
63
|
- .rspec
|
64
|
+
- Gemfile
|
64
65
|
- LICENSE
|
65
66
|
- README.md
|
67
|
+
- Rakefile
|
66
68
|
- bin/cstock
|
67
69
|
- cstock.gemspec
|
68
70
|
- lib/cstock.rb
|