Alohaha 0.0.3 → 0.0.5
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 +4 -4
- data/README.md +1 -1
- data/alohaha.gemspec +1 -1
- data/lib/alohaha.rb +20 -4
- data/lib/alohaha/flight.rb +8 -8
- data/lib/alohaha/flight_helper.rb +32 -0
- data/lib/alohaha/flight_parse.rb +2 -2
- data/lib/alohaha/settings.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eba3048a00ea1fb3b68c9eaff2ad729d6ea3a8a1
|
4
|
+
data.tar.gz: 348e19efc00271490b902b58a3aadef12a49a037
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ffb910580f30d22895fbe52eecc81e9de7a090a5186c7726d53d70642f71b305d95e9309851bce5d41c2187de414e3bf9aea77e1f852aaf620d8e16f5a1163be
|
7
|
+
data.tar.gz: ac35d75fe1de9a3ea1dd86a74ed379a2c78f44a459b07170998c795d0ac0409d70ee97cc160cf29a374dc9b8f29e6855970db78a601c6c0952477d5a7eb19ce8
|
data/README.md
CHANGED
data/alohaha.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.7"
|
22
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
23
23
|
|
24
|
-
spec.add_dependency('
|
24
|
+
spec.add_dependency('curb')
|
25
25
|
spec.add_dependency('iconv')
|
26
26
|
spec.add_dependency('virtus')
|
27
27
|
end
|
data/lib/alohaha.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
require '
|
1
|
+
require 'curb'
|
2
2
|
require 'iconv'
|
3
3
|
require 'virtus'
|
4
4
|
|
5
5
|
require "alohaha/settings"
|
6
|
+
require "alohaha/flight_helper"
|
6
7
|
require "alohaha/flight"
|
7
8
|
require "alohaha/flight_parse"
|
8
9
|
|
@@ -19,11 +20,26 @@ class Alohaha
|
|
19
20
|
end
|
20
21
|
|
21
22
|
def arrivals
|
22
|
-
@flights.
|
23
|
+
@flights.arrivals
|
23
24
|
end
|
24
25
|
|
25
26
|
def departure
|
26
|
-
@flights.
|
27
|
+
@flights.departure
|
28
|
+
end
|
29
|
+
|
30
|
+
def yesterday
|
31
|
+
@flights.yesterday
|
32
|
+
end
|
33
|
+
|
34
|
+
def today
|
35
|
+
@flights.today
|
27
36
|
end
|
28
|
-
end
|
29
37
|
|
38
|
+
def tomorrow
|
39
|
+
@flights.tomorrow
|
40
|
+
end
|
41
|
+
|
42
|
+
def by_datetime(datetime = DateTime.now)
|
43
|
+
@flights.by_datetime(datetime)
|
44
|
+
end
|
45
|
+
end
|
data/lib/alohaha/flight.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
class
|
1
|
+
class DestinationHaha
|
2
2
|
include Virtus.model
|
3
3
|
|
4
4
|
attribute :iata, String
|
@@ -6,7 +6,7 @@ class Destination
|
|
6
6
|
attribute :zh, String
|
7
7
|
end
|
8
8
|
|
9
|
-
class
|
9
|
+
class FlightHaha
|
10
10
|
include Virtus.model
|
11
11
|
|
12
12
|
attribute :terminal, String #1: T1, 2:T2
|
@@ -19,11 +19,11 @@ class Flight
|
|
19
19
|
attribute :datetime, DateTime
|
20
20
|
attribute :expected_datetime, DateTime
|
21
21
|
|
22
|
-
attribute :destination,
|
22
|
+
attribute :destination, DestinationHaha
|
23
23
|
attribute :flight_status, String
|
24
24
|
|
25
25
|
attribute :aircraft_type, String
|
26
|
-
attribute :other_route,
|
26
|
+
attribute :other_route, DestinationHaha
|
27
27
|
attribute :baggage_carousel, String
|
28
28
|
attribute :check_in_counter, String
|
29
29
|
|
@@ -57,13 +57,13 @@ class Flight
|
|
57
57
|
self.gate = raw_data[5]
|
58
58
|
|
59
59
|
# datetime
|
60
|
-
self.datetime = "#{raw_data[6]} #{raw_data[7]}"
|
60
|
+
self.datetime = "#{raw_data[6]} #{raw_data[7]} +08:00"
|
61
61
|
|
62
62
|
# expected_datetime
|
63
|
-
self.expected_datetime = "#{raw_data[8]} #{raw_data[9]}"
|
63
|
+
self.expected_datetime = "#{raw_data[8]} #{raw_data[9]} +08:00"
|
64
64
|
|
65
65
|
# destination
|
66
|
-
self.destination =
|
66
|
+
self.destination = DestinationHaha.new(iata: raw_data[10], en: raw_data[11], zh: raw_data[12])
|
67
67
|
|
68
68
|
# flight_status
|
69
69
|
self.flight_status = raw_data[13]
|
@@ -72,7 +72,7 @@ class Flight
|
|
72
72
|
self.aircraft_type = raw_data[14]
|
73
73
|
|
74
74
|
# other_route
|
75
|
-
self.other_route =
|
75
|
+
self.other_route = DestinationHaha.new(iata: raw_data[15], en: raw_data[16], zh: raw_data[17])
|
76
76
|
|
77
77
|
# baggage_carousel
|
78
78
|
self.baggage_carousel = raw_data[18]
|
@@ -0,0 +1,32 @@
|
|
1
|
+
class Array
|
2
|
+
def arrivals
|
3
|
+
self.select {|flights| flights.kind == 'Arrivals' }
|
4
|
+
end
|
5
|
+
|
6
|
+
def departure
|
7
|
+
self.select {|flights| flights.kind == 'Departure' }
|
8
|
+
end
|
9
|
+
|
10
|
+
def yesterday
|
11
|
+
self.select {|flights| flights.datetime.to_time > Date.today.prev_day.to_time && flights.datetime.to_time < Date.today.to_time }
|
12
|
+
end
|
13
|
+
|
14
|
+
def today
|
15
|
+
self.select {|flights| flights.datetime.to_time > Date.today.to_time && flights.datetime.to_time < Date.today.next_day.to_time }
|
16
|
+
end
|
17
|
+
|
18
|
+
def tomorrow
|
19
|
+
self.select {|flights| flights.datetime.to_time > Date.today.next_day.to_time }
|
20
|
+
end
|
21
|
+
|
22
|
+
def by_datetime(datetime = DateTime.now)
|
23
|
+
self.select {|flights| flights.datetime > datetime }
|
24
|
+
end
|
25
|
+
|
26
|
+
def filter_kind
|
27
|
+
{
|
28
|
+
Arrivals: self.select {|flights| flights.kind == 'Arrivals'},
|
29
|
+
Departure: self.select {|flights| flights.kind == 'Departure'}
|
30
|
+
}
|
31
|
+
end
|
32
|
+
end
|
data/lib/alohaha/flight_parse.rb
CHANGED
@@ -9,9 +9,9 @@ module FlightParse
|
|
9
9
|
@flights = []
|
10
10
|
|
11
11
|
ic = Iconv.new('UTF-8', 'BIG5')
|
12
|
-
row_data = ic.iconv(
|
12
|
+
row_data = ic.iconv(Curl.get(@url).body_str)
|
13
13
|
row_data.each_line do |line|
|
14
|
-
@flights <<
|
14
|
+
@flights << FlightHaha.new(line.split(',').map {|al| al = al.strip})
|
15
15
|
end
|
16
16
|
end
|
17
17
|
end
|
data/lib/alohaha/settings.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: Alohaha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jiunjiun
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '10.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: curb
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -95,6 +95,7 @@ files:
|
|
95
95
|
- alohaha.gemspec
|
96
96
|
- lib/alohaha.rb
|
97
97
|
- lib/alohaha/flight.rb
|
98
|
+
- lib/alohaha/flight_helper.rb
|
98
99
|
- lib/alohaha/flight_parse.rb
|
99
100
|
- lib/alohaha/settings.rb
|
100
101
|
homepage: ''
|
@@ -117,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
118
|
version: '0'
|
118
119
|
requirements: []
|
119
120
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.4.
|
121
|
+
rubygems_version: 2.4.8
|
121
122
|
signing_key:
|
122
123
|
specification_version: 4
|
123
124
|
summary: Alohaha
|