faa 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,12 @@
1
1
  class FAA::DelayFeed
2
2
  FEED_URI = 'http://www.fly.faa.gov/flyfaa/xmlAirportStatus.jsp'
3
+ END_TAG = '</AIRPORT_STATUS_INFORMATION>'
3
4
 
4
5
  attr_reader :updated_at, :delays, :raw
5
6
 
6
7
  def initialize(raw=nil)
7
- @raw = raw ? raw : FAA::DelayFeed.raw_feed.read
8
+ raw = raw ? raw : FAA::DelayFeed.raw_feed.read
9
+ @raw = raw[0..raw.index(END_TAG)+END_TAG.length-1]
8
10
  @delays = []
9
11
  parse_xml_feed
10
12
  end
data/lib/faa.rb CHANGED
@@ -4,7 +4,7 @@ require 'uri'
4
4
  require 'time'
5
5
 
6
6
  module FAA
7
- VERSION = '0.0.3'
7
+ VERSION = '0.0.4'
8
8
  end
9
9
 
10
10
  require 'faa/airport'
@@ -106,27 +106,27 @@ class DelayFeedTest < Test::Unit::TestCase
106
106
  delays = FAA::DelayFeed.current_delays.select { |x| x.class == FAA::Delay::GeneralDeparture }
107
107
  assert_equal 6, delays.size
108
108
  end
109
-
109
+
110
110
  def test_delay_feed_should_find_a_polygon_air_flow_program
111
- FakeWeb.register_uri(:get, "http://www.fly.faa.gov/flyfaa/xmlAirportStatus.jsp",
112
- :body => File.read("#{File.dirname(__FILE__)}/responses/polygon_airspace_flow.xml"))
113
- delays = FAA::DelayFeed.current_delays.select { |x| x.is_a? FAA::Delay::AirspaceFlow }
114
- flow = delays.first
115
- assert_equal(flow.class, FAA::Delay::AirspaceFlow::Polygon)
116
- assert_equal 1, delays.size
117
- assert_equal 'FCAMU1', flow.control_element
118
- assert_equal 'VOLUME / VOLUME', flow.reason
119
- assert_equal Time.utc(2009, 12, 16, 12, 0, 0), flow.fca_start_time
120
- assert_equal Time.utc(2009, 12, 23, 23, 59, 0), flow.fca_end_time
121
- assert_equal Time.utc(2009, 12, 16, 15, 0, 0), flow.afp_start_time
122
- assert_equal Time.utc(2009, 12, 23, 21, 59, 0), flow.afp_end_time
123
- assert_equal 6, flow.average
124
- assert_equal 0, flow.floor
125
- assert_equal 600, flow.ceiling
126
- assert_equal flow.point_lists.first.class, FAA::Delay::AirspaceFlow::Polygon::PointsList
127
- assert_equal flow.point_lists.first.points, [ {'latitude' => 2103, 'longitude' => 8698},
128
- {'latitude' => 2113.0, 'longitude' => 8687.0},
129
- {'latitude' => 2093.0, 'longitude' => 8680.0}]
130
- end
111
+ FakeWeb.register_uri(:get, "http://www.fly.faa.gov/flyfaa/xmlAirportStatus.jsp",
112
+ :body => File.read("#{File.dirname(__FILE__)}/responses/polygon_airspace_flow.xml"))
113
+ delays = FAA::DelayFeed.current_delays.select { |x| x.is_a? FAA::Delay::AirspaceFlow }
114
+ flow = delays.first
115
+ assert_equal(flow.class, FAA::Delay::AirspaceFlow::Polygon)
116
+ assert_equal 1, delays.size
117
+ assert_equal 'FCAMU1', flow.control_element
118
+ assert_equal 'VOLUME / VOLUME', flow.reason
119
+ assert_equal Time.utc(2009, 12, 16, 12, 0, 0), flow.fca_start_time
120
+ assert_equal Time.utc(2009, 12, 23, 23, 59, 0), flow.fca_end_time
121
+ assert_equal Time.utc(2009, 12, 16, 15, 0, 0), flow.afp_start_time
122
+ assert_equal Time.utc(2009, 12, 23, 21, 59, 0), flow.afp_end_time
123
+ assert_equal 6, flow.average
124
+ assert_equal 0, flow.floor
125
+ assert_equal 600, flow.ceiling
126
+ assert_equal flow.point_lists.first.class, FAA::Delay::AirspaceFlow::Polygon::PointsList
127
+ assert_equal flow.point_lists.first.points, [ {'latitude' => 2103, 'longitude' => 8698},
128
+ {'latitude' => 2113.0, 'longitude' => 8687.0},
129
+ {'latitude' => 2093.0, 'longitude' => 8680.0}]
130
+ end
131
131
 
132
132
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - FlightCaster