faa 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
1
  require 'rubygems'
2
2
  require 'rake'
3
3
  require 'rake/testtask'
4
- require 'metric_fu'
4
+ # require 'metric_fu'
5
5
 
6
6
  # Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
7
7
 
@@ -9,25 +9,25 @@ Rake::TestTask.new(:test) do |t|
9
9
  t.test_files = FileList['test/*_test.rb']
10
10
  end
11
11
 
12
- MetricFu::Configuration.run do |config|
13
- config.metrics = [:churn, :saikuro, :flog, :flay, :reek, :roodi]
14
- config.flay = { :dirs_to_flay => ['lib'] }
15
- config.flog = { :dirs_to_flog => ['lib'] }
16
- config.reek = { :dirs_to_reek => ['lib'] }
17
- config.roodi = { :dirs_to_roodi => ['lib'] }
18
- config.saikuro = { :output_directory => 'tmp/scratch/saikuro',
19
- :input_directory => ['lib'],
20
- :cyclo => "",
21
- :filter_cyclo => "0",
22
- :warn_cyclo => "5",
23
- :error_cyclo => "7",
24
- :formater => "text"} #this needs to be set to "text"
25
- config.churn = { :start_date => "1 year ago", :minimum_churn_count => 10}
26
- config.rcov = { :test_files => ['spec/*_spec.rb'],
27
- :rcov_opts => ["--sort coverage",
28
- "--no-html",
29
- "--text-coverage",
30
- "--no-color",
31
- "--profile",
32
- "--exclude /gems/,/Library/,spec"]}
33
- end
12
+ # MetricFu::Configuration.run do |config|
13
+ # config.metrics = [:churn, :saikuro, :flog, :flay, :reek, :roodi]
14
+ # config.flay = { :dirs_to_flay => ['lib'] }
15
+ # config.flog = { :dirs_to_flog => ['lib'] }
16
+ # config.reek = { :dirs_to_reek => ['lib'] }
17
+ # config.roodi = { :dirs_to_roodi => ['lib'] }
18
+ # config.saikuro = { :output_directory => 'tmp/scratch/saikuro',
19
+ # :input_directory => ['lib'],
20
+ # :cyclo => "",
21
+ # :filter_cyclo => "0",
22
+ # :warn_cyclo => "5",
23
+ # :error_cyclo => "7",
24
+ # :formater => "text"} #this needs to be set to "text"
25
+ # config.churn = { :start_date => "1 year ago", :minimum_churn_count => 10}
26
+ # config.rcov = { :test_files => ['spec/*_spec.rb'],
27
+ # :rcov_opts => ["--sort coverage",
28
+ # "--no-html",
29
+ # "--text-coverage",
30
+ # "--no-color",
31
+ # "--profile",
32
+ # "--exclude /gems/,/Library/,spec"]}
33
+ # 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.1'
7
+ VERSION = '0.0.3'
8
8
  end
9
9
 
10
10
  require 'faa/airport'
@@ -18,5 +18,6 @@ require 'faa/delay/ground_delay'
18
18
  require 'faa/delay/ground_stop'
19
19
  require 'faa/delay/airspace_flow'
20
20
  require 'faa/delay/airspace_flow/line'
21
- require 'faa/delay/airspace_flow/polygon'
22
21
  require 'faa/delay/airspace_flow/circle'
22
+ require 'faa/delay/airspace_flow/polygon'
23
+ require 'faa/delay/airspace_flow/polygon/point_list'
@@ -1,17 +1,16 @@
1
1
  class FAA::Delay::AirspaceFlow::Polygon < FAA::Delay::AirspaceFlow
2
2
 
3
- attr_accessor :points
3
+ attr_accessor :point_lists
4
4
 
5
5
  def initialize
6
- @points = []
6
+ @point_lists = []
7
7
  end
8
8
 
9
- def self.parse(xml)
9
+ def self.from_xml(xml)
10
10
  poly = new
11
11
  xml.children.each do |child|
12
- if child.name == "Point"
13
- poly.points << {'latitude' => child.attributes['Lat'].to_f,
14
- 'longitude' => child.attributes['Long'].to_f}
12
+ if child.name == "PointsList"
13
+ poly.point_lists << PointsList.from_xml(child)
15
14
  end
16
15
  end
17
16
  poly
@@ -0,0 +1,20 @@
1
+ class FAA::Delay::AirspaceFlow::Polygon::PointsList
2
+
3
+ attr_accessor :points
4
+
5
+ def initialize
6
+ @points = []
7
+ end
8
+
9
+ def self.from_xml(xml)
10
+ list = new
11
+ xml.children.each do |child|
12
+ if child.name == "Point"
13
+ list.points << {'latitude' => child.attributes['Lat'].to_f,
14
+ 'longitude' => child.attributes['Long'].to_f}
15
+ end
16
+ end
17
+ list
18
+ end
19
+
20
+ end
@@ -71,6 +71,7 @@ class DelayFeedTest < Test::Unit::TestCase
71
71
  :body => File.read("#{File.dirname(__FILE__)}/responses/various_delays_with_air_flow_program.xml"))
72
72
  delays = FAA::DelayFeed.current_delays.select { |x| x.is_a? FAA::Delay::AirspaceFlow }
73
73
  flow = delays.first
74
+ assert_equal(flow.class, FAA::Delay::AirspaceFlow::Line)
74
75
  assert_equal 2, delays.size
75
76
  assert_equal 'FCAA05', flow.control_element
76
77
  assert_equal 'WEATHER / THUNDERSTORMS', flow.reason
@@ -105,5 +106,27 @@ class DelayFeedTest < Test::Unit::TestCase
105
106
  delays = FAA::DelayFeed.current_delays.select { |x| x.class == FAA::Delay::GeneralDeparture }
106
107
  assert_equal 6, delays.size
107
108
  end
109
+
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
108
131
 
109
132
  end
@@ -0,0 +1,61 @@
1
+ <?xml version="1.0" encoding="ISO-8859-1"?>
2
+ <!DOCTYPE AIRPORT_STATUS_INFORMATION SYSTEM "http://www.fly.faa.gov/AirportStatus.dtd">
3
+
4
+ <AIRPORT_STATUS_INFORMATION>
5
+ <Update_Time>Fri Dec 18 18:16:56 2009 GMT+00:00</Update_Time>
6
+ <Dtd_File>http://www.fly.faa.gov/AirportStatus.dtd</Dtd_File>
7
+ <Delay_type>
8
+ <Name>Ground Delay Programs</Name>
9
+ <Ground_Delay_List>
10
+ <Ground_Delay>
11
+ <ARPT>ATL</ARPT>
12
+ <Reason>WEATHER / LOW CEILINGS</Reason>
13
+ <Avg>1 hour and 3 minutes</Avg>
14
+ <Max>0 minutes</Max>
15
+ </Ground_Delay>
16
+ <Ground_Delay>
17
+ <ARPT>ORD</ARPT>
18
+ <Reason>WEATHER / LOW VISIBILITY</Reason>
19
+ <Avg>1 hour and 21 minutes</Avg>
20
+ <Max>0 minutes</Max>
21
+ </Ground_Delay>
22
+ </Ground_Delay_List>
23
+ </Delay_type>
24
+ <Delay_type>
25
+ <Name>Airspace Flow Programs</Name>
26
+ <Airspace_Flow_List>
27
+ <Airspace_Flow>
28
+ <CTL_Element>FCAMU1</CTL_Element>
29
+ <Reason>VOLUME / VOLUME</Reason>
30
+ <FCA_Start_DateTime>20091216120000</FCA_Start_DateTime>
31
+ <FCA_End_DateTime>20091223235900</FCA_End_DateTime>
32
+ <AFP_StartTime>1500</AFP_StartTime>
33
+ <AFP_EndTime>2159</AFP_EndTime>
34
+ <Polygon>
35
+ <PointsList>
36
+ <Point Lat="2103" Long="8698" />
37
+ <Point Lat="2113" Long="8687" />
38
+ <Point Lat="2093" Long="8680" />
39
+ </PointsList>
40
+ </Polygon>
41
+ <Avg>6 minutes</Avg>
42
+ <Floor>000</Floor>
43
+ <Ceiling>600</Ceiling>
44
+ </Airspace_Flow>
45
+ </Airspace_Flow_List>
46
+ </Delay_type>
47
+ <Delay_type>
48
+ <Name>General Arrival/Departure Delay Info</Name>
49
+ <Arrival_Departure_Delay_List>
50
+ <Delay>
51
+ <ARPT>MIA</ARPT>
52
+ <Reason>WX:Thunderstorms</Reason>
53
+ <Arrival_Departure Type="Departure">
54
+ <Min>1 hour and 1 minute</Min>
55
+ <Max>1 hour and 15 minutes</Max>
56
+ <Trend>Increasing</Trend>
57
+ </Arrival_Departure>
58
+ </Delay>
59
+ </Arrival_Departure_Delay_List>
60
+ </Delay_type>
61
+ </AIRPORT_STATUS_INFORMATION>
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.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - FlightCaster
@@ -38,6 +38,7 @@ files:
38
38
  - lib/faa/airport.rb
39
39
  - lib/faa/delay/airspace_flow/circle.rb
40
40
  - lib/faa/delay/airspace_flow/line.rb
41
+ - lib/faa/delay/airspace_flow/polygon/point_list.rb
41
42
  - lib/faa/delay/airspace_flow/polygon.rb
42
43
  - lib/faa/delay/airspace_flow.rb
43
44
  - lib/faa/delay/general.rb
@@ -52,6 +53,7 @@ files:
52
53
  - test/test_helper.rb
53
54
  - test/responses/delays_with_icao_code.xml
54
55
  - test/responses/no_delays.xml
56
+ - test/responses/polygon_airspace_flow.xml
55
57
  - test/responses/various_delays.xml
56
58
  - test/responses/various_delays_with_air_flow_program.xml
57
59
  has_rdoc: true