faa 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/lib/faa.rb CHANGED
@@ -2,6 +2,7 @@ require 'libxml'
2
2
  require 'net/http'
3
3
  require 'uri'
4
4
  require 'time'
5
+ require 'date'
5
6
 
6
7
  module FAA
7
8
  VERSION = '0.0.4'
@@ -4,12 +4,12 @@ class FAA::Delay
4
4
 
5
5
  class << self
6
6
 
7
- def from_xml(node)
7
+ def from_xml(node, updated_at)
8
8
  delays = []
9
9
  node.children.each do |delay_list|
10
10
  case delay_list.name
11
11
  when 'Ground_Stop_List'
12
- delays += FAA::Delay::GroundStop.from_xml(delay_list)
12
+ delays += FAA::Delay::GroundStop.from_xml(delay_list, updated_at)
13
13
  when 'Ground_Delay_List'
14
14
  delays += FAA::Delay::GroundDelay.from_xml(delay_list)
15
15
  when 'Airspace_Flow_List'
@@ -2,7 +2,7 @@ class FAA::Delay::GroundStop < FAA::Delay
2
2
 
3
3
  attr_accessor :end_time
4
4
 
5
- def self.from_xml(xml)
5
+ def self.from_xml(xml, updated_at)
6
6
  delays = []
7
7
 
8
8
  xml.children.each do |node|
@@ -14,7 +14,11 @@ class FAA::Delay::GroundStop < FAA::Delay
14
14
  when 'Reason'
15
15
  delay.reason = child.content.strip
16
16
  when 'End_Time'
17
- delay.end_time = Time.parse(child.content)
17
+ updated_at = updated_at.utc
18
+ end_time = Time.parse(child.content).utc
19
+ end_time = Time.utc(updated_at.year, updated_at.month, updated_at.day, end_time.hour, end_time.min)
20
+ end_time = end_time + 60*60*24 if end_time < updated_at
21
+ delay.end_time = end_time
18
22
  end
19
23
  end
20
24
  delays << delay
@@ -21,7 +21,7 @@ class FAA::DelayFeed
21
21
  node.content =~ /([a-z]+) (\d+) (\d{2}):(\d{2}):(\d{2}) (\d{4})/i
22
22
  @updated_at = Time.utc($6.to_i, Date::ABBR_MONTHNAMES.index($1), $2.to_i, $3.to_i, $4.to_i, $5.to_i)
23
23
  when 'Delay_type'
24
- @delays += FAA::Delay.from_xml(node)
24
+ @delays += FAA::Delay.from_xml(node, @updated_at)
25
25
  end
26
26
  end
27
27
  end
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 5
9
+ version: 0.0.5
5
10
  platform: ruby
6
11
  authors:
7
12
  - FlightCaster
@@ -15,14 +20,18 @@ default_executable:
15
20
  dependencies:
16
21
  - !ruby/object:Gem::Dependency
17
22
  name: libxml-ruby
18
- type: :runtime
19
- version_requirement:
20
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
21
25
  requirements:
22
26
  - - ">="
23
27
  - !ruby/object:Gem::Version
28
+ segments:
29
+ - 1
30
+ - 1
31
+ - 3
24
32
  version: 1.1.3
25
- version:
33
+ type: :runtime
34
+ version_requirements: *id001
26
35
  description:
27
36
  email: dev@flightcaster.com
28
37
  executables: []
@@ -69,18 +78,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
69
78
  requirements:
70
79
  - - ">="
71
80
  - !ruby/object:Gem::Version
81
+ segments:
82
+ - 0
72
83
  version: "0"
73
- version:
74
84
  required_rubygems_version: !ruby/object:Gem::Requirement
75
85
  requirements:
76
86
  - - ">="
77
87
  - !ruby/object:Gem::Version
88
+ segments:
89
+ - 0
78
90
  version: "0"
79
- version:
80
91
  requirements: []
81
92
 
82
93
  rubyforge_project:
83
- rubygems_version: 1.3.5
94
+ rubygems_version: 1.3.6
84
95
  signing_key:
85
96
  specification_version: 3
86
97
  summary: A wrapper for the FAA Data Sources