xxbao 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.gitignore +17 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +29 -0
- data/Rakefile +1 -0
- data/bin/xxbao +4 -0
- data/lib/xxbao/config.rb +40 -0
- data/lib/xxbao/version.rb +3 -0
- data/lib/xxbao.rb +73 -0
- data/xxbao.gemspec +26 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NWIwYjVmNmEzYmEzNjE0YmY4MjliYzRkNDFlY2UzMWI4NTllYmU0Mw==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
ZDI3MzMzMmZjOWIwYzQ4NzVlNmQ1ZTZkNjY1YjhjNDIzMWFiMDUzZQ==
|
7
|
+
SHA512:
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NDYzNTA4ZGE2MDFhYTExNjYwZDY5YTBiN2Y0MDhjODk1MTVkZGQwOTA1MWFk
|
10
|
+
MjAzMDY4ZjE4MjRhNzNhOTdjMGNiMzQ3ZmIzNjQ0MzJlMDI1NzdlOGRlOGU0
|
11
|
+
YTA1ZGQ2YzliMjQ1Y2ZkMWExOTlhMjcxNDBkNGJlYzZkY2YwMDM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
NjhmZmM4Y2M1MGZjYTIxNjM0NTliOTE1NmRkOWJlNmY5MDUwMjRlNjE0NmU3
|
14
|
+
NWEzNjUxNGFkOGMyNzlhMWM2Yjk4OGM2YjVlYmQzYTUzMGMzYjRhZGM2MDJi
|
15
|
+
YTM5MjI1NmVhZThiZjQ3NzZmNTg2YWMwOTRkOGRjOGU0NGM1NzE=
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2014 Spirit
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
# Xxbao
|
2
|
+
|
3
|
+
TODO: Write a gem description
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'xxbao'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install xxbao
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
TODO: Write usage instructions here
|
22
|
+
|
23
|
+
## Contributing
|
24
|
+
|
25
|
+
1. Fork it ( http://github.com/<my-github-username>/xxbao/fork )
|
26
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
27
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
28
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
29
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/xxbao
ADDED
data/lib/xxbao/config.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
module Xxbao
|
4
|
+
module Config
|
5
|
+
BaseUrl = 'http://jingzhi.funds.hexun.com/'
|
6
|
+
Regex = /<font.+><span>(\d\.\d+)<\/span>.+\r\n.+<font.+>(\d\.\d+%)<\/font>/
|
7
|
+
Funds = {
|
8
|
+
"000343" => {
|
9
|
+
bao: "CaiFuBao",
|
10
|
+
platform: "WeChat",
|
11
|
+
},
|
12
|
+
"000397" => {
|
13
|
+
bao: "QuanEBao",
|
14
|
+
platform: "WeChat",
|
15
|
+
},
|
16
|
+
"000330" => {
|
17
|
+
bao: "XianJinBao",
|
18
|
+
platform: "Netease",
|
19
|
+
},
|
20
|
+
"000198" => {
|
21
|
+
bao: "YuEBao",
|
22
|
+
platform: "Alipay",
|
23
|
+
},
|
24
|
+
"003003" => {
|
25
|
+
bao: "BaiZhuan",
|
26
|
+
platform: "Baidu",
|
27
|
+
},
|
28
|
+
"000464" => {
|
29
|
+
bao: "BaiZhuan(ligunli)",
|
30
|
+
platform: "Baidu",
|
31
|
+
},
|
32
|
+
"000389" => {
|
33
|
+
bao: "LingQianBao",
|
34
|
+
platform: "Suning",
|
35
|
+
}
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
data/lib/xxbao.rb
ADDED
@@ -0,0 +1,73 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require "xxbao/version"
|
4
|
+
require "xxbao/config"
|
5
|
+
|
6
|
+
require "net/http"
|
7
|
+
require "command_line_reporter"
|
8
|
+
|
9
|
+
module Xxbao
|
10
|
+
class Base
|
11
|
+
include Config
|
12
|
+
include CommandLineReporter
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@funds = Config::Funds
|
16
|
+
fetch_funds
|
17
|
+
end
|
18
|
+
|
19
|
+
def output
|
20
|
+
@table = CommandLineReporter::Table.new(border: true, width: :auto)
|
21
|
+
@table.add(first_row)
|
22
|
+
@funds.values.each { |f| @table.add(fund_row(f)) }
|
23
|
+
@table.output
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def fetch_funds
|
29
|
+
@funds.map do |code, fund|
|
30
|
+
Thread.new { fetch_fund(code, fund) }
|
31
|
+
end.each { |t| t.join }
|
32
|
+
end
|
33
|
+
|
34
|
+
def fetch_fund code, fund
|
35
|
+
uri = URI(Config::BaseUrl + "#{code}.shtml")
|
36
|
+
if Net::HTTP.get(uri) =~ Regex
|
37
|
+
fund[:per_million] ||= $1
|
38
|
+
fund[:seven_yield] ||= $2
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def first_row
|
43
|
+
row = CommandLineReporter::Row.new(bold: true)
|
44
|
+
[
|
45
|
+
CommandLineReporter::Column.new('Name', align: 'center'),
|
46
|
+
CommandLineReporter::Column.new('Platform', align: 'center'),
|
47
|
+
CommandLineReporter::Column.new('SevenYearRateOfReturn', align: 'center'),
|
48
|
+
CommandLineReporter::Column.new('PerMillionFundNetRevenue', align: 'center')
|
49
|
+
].each { |c| row.add(c) }
|
50
|
+
row
|
51
|
+
end
|
52
|
+
|
53
|
+
def fund_row fund
|
54
|
+
row = CommandLineReporter::Row.new
|
55
|
+
[
|
56
|
+
CommandLineReporter::Column.new(fund[:bao]),
|
57
|
+
CommandLineReporter::Column.new(fund[:platform]),
|
58
|
+
CommandLineReporter::Column.new(fund[:seven_yield]),
|
59
|
+
CommandLineReporter::Column.new(fund[:per_million])
|
60
|
+
].each { |c| row.add(c) }
|
61
|
+
row
|
62
|
+
end
|
63
|
+
|
64
|
+
# patch for CommandLineReporter
|
65
|
+
# a row will not inherit bold & color from other row
|
66
|
+
class ::CommandLineReporter::Table
|
67
|
+
def inherit_column_attrs(row)
|
68
|
+
row.columns.each_with_index { |c, i| use_positional_attrs(c, i) }
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
data/xxbao.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'xxbao/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "xxbao"
|
8
|
+
spec.version = Xxbao::VERSION
|
9
|
+
spec.authors = ["Spirit"]
|
10
|
+
spec.email = ["neverlandxy.naix@gmail.com"]
|
11
|
+
spec.summary = %q{xxbao commandline-tool}
|
12
|
+
spec.description = %q{A commandline-tool to check the xxbao fund income}
|
13
|
+
spec.homepage = "https://github.com/NaixSpirit/xxbao"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0")
|
17
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
spec.add_development_dependency "rspec", "~> 2.14"
|
24
|
+
|
25
|
+
spec.add_dependency "command_line_reporter", "~> 3.3"
|
26
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: xxbao
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Spirit
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-04-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.5'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.5'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '2.14'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2.14'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: command_line_reporter
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.3'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.3'
|
69
|
+
description: A commandline-tool to check the xxbao fund income
|
70
|
+
email:
|
71
|
+
- neverlandxy.naix@gmail.com
|
72
|
+
executables:
|
73
|
+
- xxbao
|
74
|
+
extensions: []
|
75
|
+
extra_rdoc_files: []
|
76
|
+
files:
|
77
|
+
- .gitignore
|
78
|
+
- .rspec
|
79
|
+
- Gemfile
|
80
|
+
- LICENSE.txt
|
81
|
+
- README.md
|
82
|
+
- Rakefile
|
83
|
+
- bin/xxbao
|
84
|
+
- lib/xxbao.rb
|
85
|
+
- lib/xxbao/config.rb
|
86
|
+
- lib/xxbao/version.rb
|
87
|
+
- xxbao.gemspec
|
88
|
+
homepage: https://github.com/NaixSpirit/xxbao
|
89
|
+
licenses:
|
90
|
+
- MIT
|
91
|
+
metadata: {}
|
92
|
+
post_install_message:
|
93
|
+
rdoc_options: []
|
94
|
+
require_paths:
|
95
|
+
- lib
|
96
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
|
+
requirements:
|
98
|
+
- - ! '>='
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '0'
|
101
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ! '>='
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
requirements: []
|
107
|
+
rubyforge_project:
|
108
|
+
rubygems_version: 2.2.2
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: xxbao commandline-tool
|
112
|
+
test_files: []
|