apb_shuttle_api 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +14 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +71 -0
- data/Rakefile +2 -0
- data/apb_shuttle_api.gemspec +23 -0
- data/lib/apb_shuttle_api/version.rb +3 -0
- data/lib/apb_shuttle_api.rb +53 -0
- metadata +80 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a71ffe9a36113227a9077b01e60202a1f33ecaf0
|
4
|
+
data.tar.gz: 075891da225ebda831e0ef9f7f90253ce5b87679
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ceb5b1b7dd3dec2e54b2bc42d383b7770cf6c197bcfee82b38855090619c0448f7ec754018926ca4f5a59de2929e2206c427c053f3221ce9785df6efac2e8863
|
7
|
+
data.tar.gz: fa2ce93b6b01ff9e0bb869c0b22586e63976b221f405368f8a1236ee331a4b2a59cd3bdc5acf5fbc4bb33d16dc274341e8a3632ba666acebca5dc5efa6fba401
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 jiunjiun
|
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,71 @@
|
|
1
|
+
# ApbShuttleApi
|
2
|
+
|
3
|
+
This API helps developers easy get APB Shuttle info.
|
4
|
+
|
5
|
+
Details document: [http://apb-shuttle.info/api/doc](http://apb-shuttle.info/api/doc)
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'apb_shuttle_api'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install apb_shuttle_api
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
* 最新車表 - Now
|
26
|
+
* 下一班車表 - Next
|
27
|
+
* 全部車表 - All
|
28
|
+
* 其他資訊 - Info
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
require 'apb_shuttle_api'
|
32
|
+
```
|
33
|
+
|
34
|
+
### 最新車表 - Now
|
35
|
+
```ruby
|
36
|
+
ApbShuttleApi.now
|
37
|
+
```
|
38
|
+
|
39
|
+
### 下一班車表 - Next
|
40
|
+
```ruby
|
41
|
+
ApbShuttleApi.next(1) # next 1
|
42
|
+
ApbShuttleApi.next(5) # next 5
|
43
|
+
```
|
44
|
+
|
45
|
+
### 全部車表 - All
|
46
|
+
```ruby
|
47
|
+
ApbShuttleApi.all
|
48
|
+
ApbShuttleApi.all(1) # limit = 1
|
49
|
+
```
|
50
|
+
|
51
|
+
#### 全部車表 - All APB
|
52
|
+
```ruby
|
53
|
+
ApbShuttleApi.all_apb
|
54
|
+
ApbShuttleApi.all_apb(1) # limit = 1
|
55
|
+
```
|
56
|
+
|
57
|
+
#### 全部車表 - All Orange (亞通客運)
|
58
|
+
```ruby
|
59
|
+
ApbShuttleApi.all_orange
|
60
|
+
ApbShuttleApi.all_orange(1) # limit = 1
|
61
|
+
```
|
62
|
+
|
63
|
+
### 其他資訊 - Info
|
64
|
+
```ruby
|
65
|
+
ApbShuttleApi.info
|
66
|
+
```
|
67
|
+
|
68
|
+
|
69
|
+
## Copyright / License
|
70
|
+
* Copyright (c) 2015 jiunjiun (quietmes At gmail.com)
|
71
|
+
* Licensed under [MIT](https://github.com/jiunjiun/apb-shuttle/blob/master/LICENSE) licenses.
|
data/Rakefile
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 'apb_shuttle_api/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "apb_shuttle_api"
|
8
|
+
spec.version = ApbShuttleApi::VERSION
|
9
|
+
spec.authors = ["jiunjiun"]
|
10
|
+
spec.email = ["quietmes@gmail.com"]
|
11
|
+
spec.summary = %q{APB-Shuttle API}
|
12
|
+
spec.description = %q{This API helps developers easy get APB Shuttle info.}
|
13
|
+
spec.homepage = ""
|
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.7"
|
22
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
23
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "apb_shuttle_api/version"
|
3
|
+
|
4
|
+
require "open-uri"
|
5
|
+
require "json"
|
6
|
+
|
7
|
+
module ApbShuttleApi
|
8
|
+
@base_url = "http://apb-shuttle.info/api"
|
9
|
+
|
10
|
+
def self.now
|
11
|
+
JSON.load(open("#{@base_url}/now.json"))
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.next(next_num = 1)
|
15
|
+
JSON.load(open("#{@base_url}/next/#{next_num}.json"))
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.all(limit = nil)
|
19
|
+
get_all({limit: limit})
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.all_apb(limit = nil)
|
23
|
+
get_all({kind: 'apb', limit: limit})
|
24
|
+
end
|
25
|
+
|
26
|
+
def self.all_orange(limit = nil)
|
27
|
+
get_all({kind: 'orange', limit: limit})
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.info
|
31
|
+
JSON.load(open("#{@base_url}/info.json"))
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
def self.get_all(option = {})
|
36
|
+
limit = option[:limit]
|
37
|
+
limit = nil if limit.to_s.length == 0
|
38
|
+
limit = limit.to_s if limit == true || limit == false
|
39
|
+
|
40
|
+
limit = "/#{limit}" if !limit.nil?
|
41
|
+
|
42
|
+
case option[:kind]
|
43
|
+
when 'apb'
|
44
|
+
JSON.load(open("#{@base_url}/all/apb#{limit}.json"))
|
45
|
+
when 'orange'
|
46
|
+
JSON.load(open("#{@base_url}/all/orange#{limit}.json"))
|
47
|
+
else
|
48
|
+
JSON.load(open("#{@base_url}/all#{limit}.json"))
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
private_class_method :get_all
|
53
|
+
end
|
metadata
ADDED
@@ -0,0 +1,80 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: apb_shuttle_api
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- jiunjiun
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-07-22 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.7'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
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
|
+
description: This API helps developers easy get APB Shuttle info.
|
42
|
+
email:
|
43
|
+
- quietmes@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- apb_shuttle_api.gemspec
|
54
|
+
- lib/apb_shuttle_api.rb
|
55
|
+
- lib/apb_shuttle_api/version.rb
|
56
|
+
homepage: ''
|
57
|
+
licenses:
|
58
|
+
- MIT
|
59
|
+
metadata: {}
|
60
|
+
post_install_message:
|
61
|
+
rdoc_options: []
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
requirements: []
|
75
|
+
rubyforge_project:
|
76
|
+
rubygems_version: 2.4.5
|
77
|
+
signing_key:
|
78
|
+
specification_version: 4
|
79
|
+
summary: APB-Shuttle API
|
80
|
+
test_files: []
|