juhe_ruby 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +83 -0
- data/Rakefile +9 -0
- data/juhe_ruby.gemspec +23 -0
- data/lib/juhe_ruby/express.rb +46 -0
- data/lib/juhe_ruby/version.rb +3 -0
- data/lib/juhe_ruby.rb +8 -0
- metadata +81 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 684f19c825860c8b271bdc072aa07967d537ee94
|
|
4
|
+
data.tar.gz: f56c7b9b7eb8448ac3128ed8fd5df7ccd5aa6a29
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 74bdf713ce1a3f79e9adfd72c87fd564359e231ef1e9063da027323df058b19f2dd93e34c2b2837a730830c55732ee76e4dd0d800988860e6ac9c57410aafb35
|
|
7
|
+
data.tar.gz: 2c3e65b1dc430ee01019c606394eea931aca858c2f1252230ccbdb898176cbb3e3438cc3e528c9905c645b40a51c737e8ad62b25626296a5bc1ea855108b2584
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Copyright (c) 2014 sunday35034
|
|
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,83 @@
|
|
|
1
|
+
# JuheRuby
|
|
2
|
+
|
|
3
|
+
[聚合](http://www.juhe.cn/)ruby api,目前完成了以下功能:
|
|
4
|
+
|
|
5
|
+
- 常用快递查询
|
|
6
|
+
|
|
7
|
+
## 安装
|
|
8
|
+
|
|
9
|
+
在Gemfile里加入这行:
|
|
10
|
+
```ruby
|
|
11
|
+
gem 'juhe_ruby'
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
然后执行:
|
|
15
|
+
```ruby
|
|
16
|
+
$ bundle
|
|
17
|
+
```
|
|
18
|
+
或者自行安装:
|
|
19
|
+
```ruby
|
|
20
|
+
$ gem install juhe_ruby
|
|
21
|
+
```
|
|
22
|
+
## 用法
|
|
23
|
+
|
|
24
|
+
### 常用快递查询
|
|
25
|
+
为app_key一次赋值,多次查询
|
|
26
|
+
```ruby
|
|
27
|
+
Juhe.app_key = "d85fa433fb8f30419dc1b3697b035b3d" # 注册时,聚合提供的app_key
|
|
28
|
+
Juhe::Express.search("顺丰", "575677355677")
|
|
29
|
+
```
|
|
30
|
+
或者直接将app_key作为参数:
|
|
31
|
+
```ruby
|
|
32
|
+
Juhe::Express.search("顺丰", "575677355677", "d85fa433fb8f30419dc1b3697b035b3d")
|
|
33
|
+
```
|
|
34
|
+
返回Hash数组:
|
|
35
|
+
```ruby
|
|
36
|
+
[
|
|
37
|
+
{
|
|
38
|
+
"datetime":"2013-06-25 10:44:05",# 时间
|
|
39
|
+
"remark":"已收件",# 描述
|
|
40
|
+
"zone":"台州市"# 区域
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"datetime":"2013-06-25 11:05:21",
|
|
44
|
+
"remark":"快件在 台州 ,准备送往下一站 台州集散中心 ",
|
|
45
|
+
"zone":"台州市"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"datetime":"2013-06-25 20:36:02",
|
|
49
|
+
"remark":"快件在 台州集散中心 ,准备送往下一站 台州集散中心 ",
|
|
50
|
+
"zone":"台州市"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"datetime":"2013-06-25 21:17:36",
|
|
54
|
+
"remark":"快件在 台州集散中心 ,准备送往下一站 杭州集散中心 ",
|
|
55
|
+
"zone":"台州市"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"datetime":"2013-06-26 12:20:00",
|
|
59
|
+
"remark":"快件在 杭州集散中心 ,准备送往下一站 西安集散中心 ",
|
|
60
|
+
"zone":"杭州市"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"datetime":"2013-06-27 05:48:42",
|
|
64
|
+
"remark":"快件在 西安集散中心 ,准备送往下一站 西安 ",
|
|
65
|
+
"zone":"西安市/咸阳市"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"datetime":"2013-06-27 08:03:03",
|
|
69
|
+
"remark":"正在派件..",
|
|
70
|
+
"zone":"西安市/咸阳市"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"datetime":"2013-06-27 08:51:33",
|
|
74
|
+
"remark":"派件已签收",
|
|
75
|
+
"zone":"西安市/咸阳市"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"datetime":"2013-06-27 08:51",
|
|
79
|
+
"remark":"签收人是:已签收 ",
|
|
80
|
+
"zone":"西安市/咸阳市"
|
|
81
|
+
}
|
|
82
|
+
]
|
|
83
|
+
```
|
data/Rakefile
ADDED
data/juhe_ruby.gemspec
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'juhe_ruby/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = "juhe_ruby"
|
|
8
|
+
spec.version = JuheRuby::VERSION
|
|
9
|
+
spec.authors = ["linuxnerd"]
|
|
10
|
+
spec.email = ["lwc_evale@hotmail.com"]
|
|
11
|
+
spec.description = %q{"聚合ruby api"}
|
|
12
|
+
spec.summary = %q{"聚合ruby api"}
|
|
13
|
+
spec.homepage = "https://github.com/linuxnerd/juhe_ruby"
|
|
14
|
+
spec.license = "MIT"
|
|
15
|
+
|
|
16
|
+
spec.files = `git ls-files`.split($/)
|
|
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.3"
|
|
22
|
+
spec.add_development_dependency "rake"
|
|
23
|
+
end
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
require "open-uri"
|
|
2
|
+
require "json"
|
|
3
|
+
|
|
4
|
+
module Juhe
|
|
5
|
+
|
|
6
|
+
module ExpressCompany
|
|
7
|
+
BASE_URL = "http://v.juhe.cn/exp/com"
|
|
8
|
+
|
|
9
|
+
def self.included(base)
|
|
10
|
+
base.extend ClassMethods
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
module ClassMethods
|
|
14
|
+
def company_code_of(company_name, app_key = nil)
|
|
15
|
+
app_key ||= Juhe.app_key
|
|
16
|
+
result = JSON.parse(open(BASE_URL+"?key="+app_key).read)
|
|
17
|
+
raise result["reason"] if result["resultcode"] != "200"
|
|
18
|
+
|
|
19
|
+
result["result"].each do |company|
|
|
20
|
+
return company["no"] if company["com"] == company_name
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
module Express
|
|
27
|
+
include ExpressCompany
|
|
28
|
+
|
|
29
|
+
BASE_URL = "http://v.juhe.cn/exp/index"
|
|
30
|
+
|
|
31
|
+
def self.search(company_name, number, app_key = nil)
|
|
32
|
+
app_key ||= Juhe.app_key
|
|
33
|
+
url = BASE_URL \
|
|
34
|
+
+ "?key=" \
|
|
35
|
+
+ app_key \
|
|
36
|
+
+ "&no=" + number \
|
|
37
|
+
+ "&com=" + company_code_of(company_name, app_key)
|
|
38
|
+
|
|
39
|
+
result = JSON.parse(open(url).read)
|
|
40
|
+
raise result["reason"].to_s if result["resultcode"] != "200"
|
|
41
|
+
result["result"]
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
end
|
data/lib/juhe_ruby.rb
ADDED
metadata
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: juhe_ruby
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- linuxnerd
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2014-05-23 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.3'
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - ~>
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: '1.3'
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: rake
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - '>='
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - '>='
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
description: '"聚合ruby api"'
|
|
42
|
+
email:
|
|
43
|
+
- lwc_evale@hotmail.com
|
|
44
|
+
executables: []
|
|
45
|
+
extensions: []
|
|
46
|
+
extra_rdoc_files: []
|
|
47
|
+
files:
|
|
48
|
+
- .gitignore
|
|
49
|
+
- Gemfile
|
|
50
|
+
- LICENSE.txt
|
|
51
|
+
- README.md
|
|
52
|
+
- Rakefile
|
|
53
|
+
- juhe_ruby.gemspec
|
|
54
|
+
- lib/juhe_ruby.rb
|
|
55
|
+
- lib/juhe_ruby/express.rb
|
|
56
|
+
- lib/juhe_ruby/version.rb
|
|
57
|
+
homepage: https://github.com/linuxnerd/juhe_ruby
|
|
58
|
+
licenses:
|
|
59
|
+
- MIT
|
|
60
|
+
metadata: {}
|
|
61
|
+
post_install_message:
|
|
62
|
+
rdoc_options: []
|
|
63
|
+
require_paths:
|
|
64
|
+
- lib
|
|
65
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
66
|
+
requirements:
|
|
67
|
+
- - '>='
|
|
68
|
+
- !ruby/object:Gem::Version
|
|
69
|
+
version: '0'
|
|
70
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - '>='
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '0'
|
|
75
|
+
requirements: []
|
|
76
|
+
rubyforge_project:
|
|
77
|
+
rubygems_version: 2.1.10
|
|
78
|
+
signing_key:
|
|
79
|
+
specification_version: 4
|
|
80
|
+
summary: '"聚合ruby api"'
|
|
81
|
+
test_files: []
|