xxbao 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/README.md +9 -12
- data/lib/xxbao.rb +25 -6
- data/lib/xxbao/config.rb +26 -30
- data/lib/xxbao/version.rb +1 -1
- data/xxbao.gemspec +1 -0
- metadata +29 -15
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
ZDI3MzMzMmZjOWIwYzQ4NzVlNmQ1ZTZkNjY1YjhjNDIzMWFiMDUzZQ==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: bac056405ea8d8d8652026d317dfd644f681efba
|
4
|
+
data.tar.gz: 2a1cf0491151930f6a58ec9d22d1b199344d93ea
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
MjAzMDY4ZjE4MjRhNzNhOTdjMGNiMzQ3ZmIzNjQ0MzJlMDI1NzdlOGRlOGU0
|
11
|
-
YTA1ZGQ2YzliMjQ1Y2ZkMWExOTlhMjcxNDBkNGJlYzZkY2YwMDM=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NjhmZmM4Y2M1MGZjYTIxNjM0NTliOTE1NmRkOWJlNmY5MDUwMjRlNjE0NmU3
|
14
|
-
NWEzNjUxNGFkOGMyNzlhMWM2Yjk4OGM2YjVlYmQzYTUzMGMzYjRhZGM2MDJi
|
15
|
-
YTM5MjI1NmVhZThiZjQ3NzZmNTg2YWMwOTRkOGRjOGU0NGM1NzE=
|
6
|
+
metadata.gz: 2248400f0d9ddcaf810101a9408478941bd6e302b4e0b1aaa157901902bef863896f42f426569a34c897a2827b26fb876763b0d3b35e0a58e16767a4c998d825
|
7
|
+
data.tar.gz: 2aa548c137da7f137bf6ffab8076a736536e43317a297890fd438740250b5aa508939a04e162d0045dda6b625999cb67673519b2426bc1f0b655c5adf6336680
|
data/README.md
CHANGED
@@ -1,28 +1,25 @@
|
|
1
1
|
# Xxbao
|
2
2
|
|
3
|
-
|
3
|
+
播报"xx宝"收益的命令行工具(Ruby版)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
Add this line to your application's Gemfile:
|
5
|
+
受到 [xxb](https://github.com/coolzilj/xxb) 的启发, 由于 Node 版本的 xxb 速度较慢, 大概需要 2s 左右, 所以编写一个 Ruby 版本的 xxbao, 采用多线程, 所需时间 0.6s 左右, 在此感谢 [xxb](https://github.com/coolzilj/xxb) 的作者 [Liu Jin](https://github.com/coolzilj)
|
8
6
|
|
9
|
-
|
7
|
+
![screenshot](http://naixspirit.com/images/xxbao.png)
|
10
8
|
|
11
|
-
|
12
|
-
|
13
|
-
$ bundle
|
9
|
+
## Installation
|
14
10
|
|
15
|
-
|
11
|
+
install it yourself as:
|
16
12
|
|
17
13
|
$ gem install xxbao
|
18
14
|
|
19
|
-
|
15
|
+
### Usage
|
16
|
+
Just run `xxbao` , you will get the pretty table.
|
20
17
|
|
21
|
-
|
18
|
+
$ xxbao
|
22
19
|
|
23
20
|
## Contributing
|
24
21
|
|
25
|
-
1. Fork it ( http://github.com
|
22
|
+
1. Fork it ( http://github.com/NaixSpirit/xxbao/fork )
|
26
23
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
24
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
25
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/xxbao.rb
CHANGED
@@ -5,6 +5,7 @@ require "xxbao/config"
|
|
5
5
|
|
6
6
|
require "net/http"
|
7
7
|
require "command_line_reporter"
|
8
|
+
require "unicode/display_width"
|
8
9
|
|
9
10
|
module Xxbao
|
10
11
|
class Base
|
@@ -21,6 +22,7 @@ module Xxbao
|
|
21
22
|
@table.add(first_row)
|
22
23
|
@funds.values.each { |f| @table.add(fund_row(f)) }
|
23
24
|
@table.output
|
25
|
+
puts "来源: http://fund.eastmoney.com/, 时间: #{Time.now.strftime("%F %T")}"
|
24
26
|
end
|
25
27
|
|
26
28
|
private
|
@@ -40,12 +42,12 @@ module Xxbao
|
|
40
42
|
end
|
41
43
|
|
42
44
|
def first_row
|
43
|
-
row = CommandLineReporter::Row.new(bold: true)
|
45
|
+
row = CommandLineReporter::Row.new(bold: true, header: true, color: "red")
|
44
46
|
[
|
45
|
-
CommandLineReporter::Column.new('
|
46
|
-
CommandLineReporter::Column.new('
|
47
|
-
CommandLineReporter::Column.new('
|
48
|
-
CommandLineReporter::Column.new('
|
47
|
+
CommandLineReporter::Column.new('名称', align: 'center'),
|
48
|
+
CommandLineReporter::Column.new('平台', align: 'center'),
|
49
|
+
CommandLineReporter::Column.new('七日年化收益率', align: 'center'),
|
50
|
+
CommandLineReporter::Column.new('万份收益', align: 'center')
|
49
51
|
].each { |c| row.add(c) }
|
50
52
|
row
|
51
53
|
end
|
@@ -69,5 +71,22 @@ module Xxbao
|
|
69
71
|
end
|
70
72
|
end
|
71
73
|
|
74
|
+
class ::CommandLineReporter::Column
|
75
|
+
|
76
|
+
def required_width
|
77
|
+
self.text.to_s.display_size + 2 * self.padding
|
78
|
+
end
|
79
|
+
|
80
|
+
def aligned_cell(str)
|
81
|
+
case self.align
|
82
|
+
when 'left'
|
83
|
+
" " * (self.size - str.display_size) + str if self.size > str.display_size
|
84
|
+
when 'right'
|
85
|
+
str + " " * (self.size - str.display_size) if self.size > str.display_size
|
86
|
+
when 'center'
|
87
|
+
" " * ((self.size - str.display_size) / 2.0).floor + str + " " * ((self.size - str.display_size) / 2.0).ceil
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
72
91
|
end
|
73
|
-
end
|
92
|
+
end
|
data/lib/xxbao/config.rb
CHANGED
@@ -3,36 +3,32 @@
|
|
3
3
|
module Xxbao
|
4
4
|
module Config
|
5
5
|
BaseUrl = 'http://jingzhi.funds.hexun.com/'
|
6
|
-
Regex
|
7
|
-
Funds
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
"000389" => {
|
33
|
-
bao: "LingQianBao",
|
34
|
-
platform: "Suning",
|
35
|
-
}
|
6
|
+
Regex = /<font.+><span>(\d\.\d+)<\/span>.+\r\n.+<font.+>(\d\.\d+%)<\/font>/
|
7
|
+
Funds = {
|
8
|
+
"000343" => {
|
9
|
+
bao: "财富宝",
|
10
|
+
platform: "微信",
|
11
|
+
},
|
12
|
+
"000330" => {
|
13
|
+
bao: "现金宝",
|
14
|
+
platform: "网易理财",
|
15
|
+
},
|
16
|
+
"000198" => {
|
17
|
+
bao: "余额宝",
|
18
|
+
platform: "支付宝",
|
19
|
+
},
|
20
|
+
"003003" => {
|
21
|
+
bao: "百赚",
|
22
|
+
platform: "百度理财",
|
23
|
+
},
|
24
|
+
"000464" => {
|
25
|
+
bao: "百赚利滚利版",
|
26
|
+
platform: "百度理财",
|
27
|
+
},
|
28
|
+
"000389" => {
|
29
|
+
bao: "零钱宝",
|
30
|
+
platform: "苏宁",
|
31
|
+
}
|
36
32
|
}
|
37
33
|
end
|
38
34
|
end
|
data/lib/xxbao/version.rb
CHANGED
data/xxbao.gemspec
CHANGED
metadata
CHANGED
@@ -1,71 +1,85 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: xxbao
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Spirit
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - ~>
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '1.5'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - ~>
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '10.0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - ~>
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '2.14'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - ~>
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '2.14'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: command_line_reporter
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - ~>
|
59
|
+
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '3.3'
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - ~>
|
66
|
+
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '3.3'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: unicode-display_width
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.1.1
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.1.1
|
69
83
|
description: A commandline-tool to check the xxbao fund income
|
70
84
|
email:
|
71
85
|
- neverlandxy.naix@gmail.com
|
@@ -74,8 +88,8 @@ executables:
|
|
74
88
|
extensions: []
|
75
89
|
extra_rdoc_files: []
|
76
90
|
files:
|
77
|
-
- .gitignore
|
78
|
-
- .rspec
|
91
|
+
- ".gitignore"
|
92
|
+
- ".rspec"
|
79
93
|
- Gemfile
|
80
94
|
- LICENSE.txt
|
81
95
|
- README.md
|
@@ -95,17 +109,17 @@ require_paths:
|
|
95
109
|
- lib
|
96
110
|
required_ruby_version: !ruby/object:Gem::Requirement
|
97
111
|
requirements:
|
98
|
-
- -
|
112
|
+
- - ">="
|
99
113
|
- !ruby/object:Gem::Version
|
100
114
|
version: '0'
|
101
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
116
|
requirements:
|
103
|
-
- -
|
117
|
+
- - ">="
|
104
118
|
- !ruby/object:Gem::Version
|
105
119
|
version: '0'
|
106
120
|
requirements: []
|
107
121
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.
|
122
|
+
rubygems_version: 2.4.2
|
109
123
|
signing_key:
|
110
124
|
specification_version: 4
|
111
125
|
summary: xxbao commandline-tool
|