juhe_ruby 0.0.6 → 0.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 317df830696a11b089b438d33a4976da9a5c9e68
4
- data.tar.gz: 76bd7e89a12cc556222571c814ac790776ff6f35
3
+ metadata.gz: 2185e8396199bc6c7b44f83fb063409ed1aa756f
4
+ data.tar.gz: f9e4e0d00869542fd2d6d3d6444a19e66fbd7d18
5
5
  SHA512:
6
- metadata.gz: 96bf34892b17a588d26c51c93f4178c29c2b87ec8c7ce870909d55dae6b8b1cdfe2da690b25f64838ca209679065476e271386592e1266732b716d4770564f1d
7
- data.tar.gz: 0f43e12afc26428c5fb3f2e4e2f2e6c904e82f9a6f7377953134e951486fc22f28793a2aa547f5326b6bc2f9a8ea9e433601b123896d40e7c17a09414820b611
6
+ metadata.gz: 6ed4d548601732ff04aaa48a5457b74b1032a0efdc58ff620847623b6ac88de6472e811280cda9a0c466bd5e8eb296a905a513671844a3cfa16da9c3dbc545b5
7
+ data.tar.gz: 0e8b31e90f5204a053eedb47408b995d1a90ad407bf26778a9cdd4551609d0bb655574fac4e4b280ae45f5d0e5450c79ef5702ffc3999ce303a1073976866bd9
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # JuheRuby
2
+ [![Gem Version](https://badge.fury.io/rb/juhe_ruby.svg)](http://badge.fury.io/rb/juhe_ruby)
2
3
 
3
4
  [聚合](http://www.juhe.cn/)ruby api,目前完成了以下功能:
4
5
 
@@ -103,6 +104,82 @@ Juhe::Boxoffice.latest("HK") # 香港最新票房榜
103
104
  # 或者app_key直接作为参数
104
105
  Juhe::Boxoffice.latest("HK", app_key: "d85fa433fd8430419dc1b3697b035b3d") # 香港最新票房榜
105
106
  ```
107
+ 返回Hash数组:
108
+ ```ruby
109
+ [
110
+ {
111
+ "rid":"1",
112
+ "name":"中国合伙人",
113
+ "wk":"2013.5.20--2013.5.26(单位:人民币)",
114
+ "wboxoffice":"¥20900万",
115
+ "tboxoffice":"¥31700万"
116
+ },
117
+ {
118
+ "rid":"2",
119
+ "name":"钢铁侠3",
120
+ "wk":"2013.5.20--2013.5.26(单位:人民币)",
121
+ "wboxoffice":"¥4480万",
122
+ "tboxoffice":"¥74480万"
123
+ },
124
+ {
125
+ "rid":"3",
126
+ "name":"疯狂原始人",
127
+ "wk":"2013.5.20--2013.5.26(单位:人民币)",
128
+ "wboxoffice":"¥3050万",
129
+ "tboxoffice":"¥35240万"
130
+ },
131
+ {
132
+ "rid":"4",
133
+ "name":"遗落战境",
134
+ "wk":"2013.5.20--2013.5.26(单位:人民币)",
135
+ "wboxoffice":"¥2680万",
136
+ "tboxoffice":"¥13980万"
137
+ },
138
+ {
139
+ "rid":"5",
140
+ "name":"致我们终将逝去的青春",
141
+ "wk":"2013.5.20--2013.5.26(单位:人民币)",
142
+ "wboxoffice":"¥2290万",
143
+ "tboxoffice":"¥71206万"
144
+ },
145
+ {
146
+ "rid":"6",
147
+ "name":"圣诞玫瑰(new)",
148
+ "wk":"2013.5.20--2013.5.26(单位:人民币)",
149
+ "wboxoffice":"¥1390万",
150
+ "tboxoffice":"¥1390万"
151
+ },
152
+ {
153
+ "rid":"7",
154
+ "name":"一路狂奔(new)",
155
+ "wk":"2013.5.20--2013.5.26(单位:人民币)",
156
+ "wboxoffice":"¥350万",
157
+ "tboxoffice":"¥350万"
158
+ },
159
+ {
160
+ "rid":"8",
161
+ "name":"被解救的姜戈",
162
+ "wk":"2013.5.20--2013.5.26(单位:人民币)",
163
+ "wboxoffice":"¥309万",
164
+ "tboxoffice":"¥1664万"
165
+ },
166
+ {
167
+ "rid":"9",
168
+ "name":"临终囧事",
169
+ "wk":"2013.5.20--2013.5.26(单位:人民币)",
170
+ "wboxoffice":"¥285万",
171
+ "tboxoffice":"¥660万"
172
+ },
173
+ {
174
+ "rid":"10",
175
+ "name":"西柏坡2:王二小",
176
+ "wk":"2013.5.20--2013.5.26(单位:人民币)",
177
+ "wboxoffice":"¥25万",
178
+ "tboxoffice":"¥45万"
179
+ }
180
+ ]
181
+ ```
182
+
106
183
  #### 网票票房
107
184
  示例:
108
185
  ```ruby
@@ -110,4 +187,29 @@ Juhe::Boxoffice.app_key = "d85fa433fd8430419dc1b3697b035b3d"
110
187
  Juhe::Boxoffice.wp # 网票票房
111
188
  # 或者app_key直接作为参数
112
189
  Juhe::Boxoffice.wp(app_key: "d85fa433fd8430419dc1b3697b035b3d") # 网票票房
113
- ```
190
+ ```
191
+ 返回Hash数组:
192
+ ```ruby
193
+ [
194
+ {
195
+ "name": "惊天危机(数字)", /*影片名称*/
196
+ "totals": "2262", /*总场次*/
197
+ "statistics": "1111", /*统计场次*/
198
+ "averaging": "27", /*场均*/
199
+ "attendance": "15%", /*上座率*/
200
+ "people": "29999", /*人次*/
201
+ "fare": "39", /*票价(元)*/
202
+ "boxoffice": "1164731" /*票房(元)*/
203
+ },
204
+ {
205
+ "name": "大明猩(数字3D)",
206
+ "totals": "1278",
207
+ "statistics": "613",
208
+ "averaging": "21",
209
+ "attendance": "13%",
210
+ "people": "12726",
211
+ "fare": "48",
212
+ "boxoffice": "607759"
213
+ }
214
+ ]
215
+ ```
data/juhe_ruby.gemspec CHANGED
@@ -13,6 +13,14 @@ Gem::Specification.new do |spec|
13
13
  spec.homepage = "https://github.com/linuxnerd/juhe_ruby"
14
14
  spec.license = "MIT"
15
15
 
16
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
17
+ # delete this section to allow pushing this gem to any host.
18
+ if spec.respond_to?(:metadata)
19
+ spec.metadata['allowed_push_host'] = "TODO: Set to 'http://mygemserver.com'"
20
+ else
21
+ raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
22
+ end
23
+
16
24
  spec.files = `git ls-files`.split($/)
17
25
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
26
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
@@ -0,0 +1,30 @@
1
+ require "open-uri"
2
+ require "json"
3
+
4
+ module Juhe
5
+ module Boxoffice
6
+
7
+ def self.latest(area, options = nil)
8
+ app_key = (options[:app_key] if options) || Juhe::Boxoffice.app_key
9
+
10
+ url = BASE_URL \
11
+ + "/rank?key=" + app_key \
12
+ + "&area=" + area
13
+ result = JSON.parse(open(url).read)
14
+ raise result["reason"] if result["resultcode"] != "200"
15
+ result["result"]
16
+ end
17
+
18
+
19
+ def self.wp(options = nil)
20
+ app_key = (options[:app_key] if options) || Juhe::Boxoffice.app_key
21
+
22
+ url = BASE_URL \
23
+ + "/wp?key=" + app_key
24
+ result = JSON.parse(open(url).read)
25
+ raise result["reason"] if result["resultcode"] != "200"
26
+ result["result"]
27
+ end
28
+
29
+ end
30
+ end
@@ -3,10 +3,12 @@ require "json"
3
3
 
4
4
  module Juhe
5
5
  module Express
6
+
6
7
  class << self
7
8
  attr_accessor :companies
8
9
  end
9
10
 
11
+
10
12
  def self.search(company_name, number, options = nil)
11
13
  app_key = (options[:app_key] if options) || Juhe::Express.app_key
12
14
  url = BASE_URL \
@@ -19,6 +21,7 @@ module Juhe
19
21
  result["result"]
20
22
  end
21
23
 
24
+
22
25
  def self.company_code_of(company_name, options = nil)
23
26
  refresh_companies(options) if @companies.nil?
24
27
 
@@ -27,6 +30,7 @@ module Juhe
27
30
  end
28
31
  end
29
32
 
33
+
30
34
  def self.refresh_companies(options)
31
35
  app_key = (options[:app_key] if options) || Juhe::Express.app_key
32
36
  result = JSON.parse(open(BASE_URL+"/com?key="+app_key).read)
@@ -1,3 +1,3 @@
1
1
  module JuheRuby
2
- VERSION = "0.0.6"
2
+ VERSION = "0.1.0"
3
3
  end
data/lib/juhe_ruby.rb CHANGED
@@ -1,11 +1,15 @@
1
1
  require "juhe_ruby/version"
2
2
  require "juhe_ruby/express"
3
3
  require "juhe_ruby/boxoffice"
4
+ require "juhe_ruby/idcard"
5
+ require "juhe_ruby/id_verify"
4
6
 
5
7
  module Juhe
6
8
  URLS = {
7
9
  Express: "http://v.juhe.cn/exp", # 常用快递查询
8
- Boxoffice: "http://v.juhe.cn/boxoffice" # 电影票房
10
+ Boxoffice: "http://v.juhe.cn/boxoffice", # 电影票房
11
+ IdCard: "http://apis.juhe.cn/idcard", # 身份证查询
12
+ IdVerify: "http://op.juhe.cn/idcard" # 实名认证
9
13
  }
10
14
 
11
15
  class << self
@@ -0,0 +1,32 @@
1
+ require "test_helper.rb"
2
+
3
+ class Juhe::BoxofficeTest < Minitest::Test
4
+ def setup
5
+ Juhe::Boxoffice.app_key = "8b5f6d4adb46123938ebad000ca09300"
6
+ end
7
+
8
+ def test_app_key
9
+ Juhe::Boxoffice.app_key = "123456"
10
+ assert_equal(Juhe::Boxoffice.app_key, "123456")
11
+ end
12
+
13
+ def test_latest_without_app_key
14
+ assert_not_nil(Juhe::Boxoffice.latest("hk").first["rid"])
15
+ end
16
+
17
+ def test_latest_with_app_key
18
+ Juhe::Boxoffice.app_key = ""
19
+ result = Juhe::Boxoffice.latest("hk", app_key: "8b5f6d4adb46123938ebad000ca09300")
20
+ assert_not_nil(result.first["rid"])
21
+ end
22
+
23
+ def test_wp_without_app_key
24
+ assert_not_nil(Juhe::Boxoffice.wp.first["name"])
25
+ end
26
+
27
+ def test_wp_with_app_key
28
+ Juhe::Boxoffice.app_key = ""
29
+ result = Juhe::Boxoffice.wp(app_key: "8b5f6d4adb46123938ebad000ca09300")
30
+ assert_not_nil(result.first["name"])
31
+ end
32
+ end
@@ -1,6 +1,6 @@
1
1
  require "test_helper"
2
2
 
3
- class Juhe::ExpressTest < Test::Unit::TestCase
3
+ class Juhe::ExpressTest < Minitest::Test
4
4
  def setup
5
5
  Juhe::Express.app_key = "d85fa433fd8f30419dc1b3697b035b3d"
6
6
  end
data/test/test_helper.rb CHANGED
@@ -1,2 +1,2 @@
1
- require 'test/unit'
1
+ require 'minitest/autorun'
2
2
  require "juhe_ruby"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: juhe_ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - linuxnerd
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-05-26 00:00:00.000000000 Z
11
+ date: 2016-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,14 +52,17 @@ files:
52
52
  - Rakefile
53
53
  - juhe_ruby.gemspec
54
54
  - lib/juhe_ruby.rb
55
+ - lib/juhe_ruby/boxoffice.rb
55
56
  - lib/juhe_ruby/express.rb
56
57
  - lib/juhe_ruby/version.rb
58
+ - test/boxoffice/boxoffice_test.rb
57
59
  - test/express/express_test.rb
58
60
  - test/test_helper.rb
59
61
  homepage: https://github.com/linuxnerd/juhe_ruby
60
62
  licenses:
61
63
  - MIT
62
- metadata: {}
64
+ metadata:
65
+ allowed_push_host: 'TODO: Set to ''http://mygemserver.com'''
63
66
  post_install_message:
64
67
  rdoc_options: []
65
68
  require_paths:
@@ -76,10 +79,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
76
79
  version: '0'
77
80
  requirements: []
78
81
  rubyforge_project:
79
- rubygems_version: 2.1.11
82
+ rubygems_version: 2.0.14.1
80
83
  signing_key:
81
84
  specification_version: 4
82
85
  summary: '"聚合ruby api"'
83
86
  test_files:
87
+ - test/boxoffice/boxoffice_test.rb
84
88
  - test/express/express_test.rb
85
89
  - test/test_helper.rb