fossil 0.3.32 → 0.3.33
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/fossil.gemspec +2 -2
- data/lib/models/trip.rb +7 -13
- data/lib/models/trip_leg.rb +13 -1
- data/spec/models/trip_leg_spec.rb +53 -16
- data/spec/spec_helper.rb +2 -2
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.33
|
data/fossil.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{fossil}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.33"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Patrick Lardin, Daniel Sudol"]
|
12
|
-
s.date = %q{2010-04-
|
12
|
+
s.date = %q{2010-04-03}
|
13
13
|
s.description = %q{Access FOS/betrieve db with this Sequel based orm wrapper}
|
14
14
|
s.email = %q{plardin@xojet.com}
|
15
15
|
s.files = [
|
data/lib/models/trip.rb
CHANGED
@@ -40,16 +40,16 @@ class Trip < Sequel::Model(:'trips')
|
|
40
40
|
one_to_many :all_comments, :class=>:Comment, :dataset=>proc{Comment.filter( :kid_date=>kid_date, :kid_time=>kid_time, :kid_user=>kid_user, :kid_mult=>kid_mult, :kid_comm=>(kid_comm*10)..(kid_comm*10+9))}
|
41
41
|
|
42
42
|
# Code associations
|
43
|
-
code_association :
|
44
|
-
code_association :
|
45
|
-
code_association :
|
46
|
-
code_association :
|
43
|
+
code_association :department_value, :'department code', :department
|
44
|
+
code_association :company_value, :'company code', :company
|
45
|
+
code_association :division_value, :'division code', :division
|
46
|
+
code_association :purpose_value, :'purpose code', :purpose
|
47
47
|
code_association :trip_type_value, :'trip type code', :trip_type
|
48
|
-
code_association :
|
49
|
-
code_association :
|
48
|
+
code_association :rate_type_value, :'rate type code', :aircraft_rate
|
49
|
+
code_association :base_value, :'base code', :location
|
50
50
|
code_association :cancellation_code, :'cancel code', :cancellation_code
|
51
51
|
code_association :passenger_rate, :'pax rate', :passenger_rate
|
52
|
-
code_association :
|
52
|
+
code_association :approval_value, :'approval_code', :trip_approval
|
53
53
|
code_association :special_qualification, :'specialqualification', :special_qualification
|
54
54
|
|
55
55
|
#### BEGIN GENERATED SECTION ####
|
@@ -267,10 +267,4 @@ class Trip < Sequel::Model(:'trips')
|
|
267
267
|
column_alias :reserved_3, :'reserved 3'
|
268
268
|
#### END GENERATED SECTION ####
|
269
269
|
|
270
|
-
def passenger_list
|
271
|
-
return '' unless passengers
|
272
|
-
pax_list = passengers.collect{|v| (v.lead_pax==1 ? "Lead Pax " : '' ) + v.name}.uniq
|
273
|
-
pax_list ? pax_list.join(" : ") : ''
|
274
|
-
end
|
275
|
-
|
276
270
|
end
|
data/lib/models/trip_leg.rb
CHANGED
@@ -626,7 +626,6 @@ class TripLeg < Sequel::Model(:'trip legs')
|
|
626
626
|
|
627
627
|
# delegators
|
628
628
|
delegate :lead_pax, :to => :trip
|
629
|
-
delegate :passenger_list, :to => :trip
|
630
629
|
|
631
630
|
# Column views
|
632
631
|
column_view :dept_date_act_gmt, :date, :actual_departure_date_gmt
|
@@ -715,6 +714,19 @@ class TripLeg < Sequel::Model(:'trip legs')
|
|
715
714
|
Time.from_minutes(minutes_between)
|
716
715
|
end
|
717
716
|
|
717
|
+
def is_deadhead?
|
718
|
+
status==1 and (deadhead==1 or pax_count==0) and [107, 115, 108, 104].include? leg_type_code
|
719
|
+
end
|
720
|
+
|
721
|
+
def passenger_list
|
722
|
+
return '' if trip__passengers.empty? or is_deadhead?
|
723
|
+
trip__passengers.collect do |p|
|
724
|
+
if (leg_number >= p.departure_leg_number and leg_number <= p.arrival_leg_number)
|
725
|
+
p.name + (p.lead_pax==1 ? " (lead pax)" : '' )
|
726
|
+
end
|
727
|
+
end.compact.join(' , ')
|
728
|
+
end
|
729
|
+
|
718
730
|
#### aliases and special methods #####
|
719
731
|
# This method guarantees an icao for a view that needs one. If there is an icao, use it, otherwise make
|
720
732
|
# it from the prefix and airport_id .. which works as an icao, but beware, because these put together
|
@@ -1,39 +1,76 @@
|
|
1
1
|
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
2
|
|
3
3
|
describe TripLeg do
|
4
|
-
|
4
|
+
|
5
5
|
before do
|
6
6
|
end
|
7
7
|
|
8
8
|
it "ebt_time method produces correct Time with minutes" do
|
9
|
-
dept_date_act_gmt = Date.new(2000,1,1)
|
9
|
+
dept_date_act_gmt = Date.new(2000, 1, 1)
|
10
10
|
tl = TripLeg.new(:arrival_date_gmt=>dept_date_act_gmt.to_fos_days, :eta_gmt=>40,
|
11
11
|
:dept_date_gmt=>dept_date_act_gmt.to_fos_days, :etd_gmt=>20)
|
12
12
|
tl.ebt_time.should == Time.from_minutes(20)
|
13
13
|
end
|
14
14
|
|
15
15
|
it "actual take off date_time dates are after dept_date_act_gmt if take off time is less than depart time" do
|
16
|
-
dept_date_act_gmt = Date.new(1900,1,1)
|
17
|
-
tl = TripLeg.new(:dept_date_act_gmt=>dept_date_act_gmt.to_fos_days
|
18
|
-
tl.actual_takeoff_date_time_gmt.should == DateTime.new(1900,1,2,0,20,0)
|
16
|
+
dept_date_act_gmt = Date.new(1900, 1, 1)
|
17
|
+
tl = TripLeg.new(:dept_date_act_gmt=>dept_date_act_gmt.to_fos_days, :t_o_time_act_gmt=>20, :dept_time_act_gmt=>1420)
|
18
|
+
tl.actual_takeoff_date_time_gmt.should == DateTime.new(1900, 1, 2, 0, 20, 0)
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
dept_date_act_gmt = Date.new(1900,1,1)
|
23
|
-
tl = TripLeg.new(:dept_date_act_gmt=>dept_date_act_gmt.to_fos_days
|
24
|
-
tl.actual_takeoff_date_time_gmt.should == DateTime.new(1900,1,1,0,40,0)
|
25
|
-
|
21
|
+
it "actual take off date_time dates are the same as dept_date_act_gmt if take off time is not less than depart time" do
|
22
|
+
dept_date_act_gmt = Date.new(1900, 1, 1)
|
23
|
+
tl = TripLeg.new(:dept_date_act_gmt=>dept_date_act_gmt.to_fos_days, :t_o_time_act_gmt=>40, :dept_time_act_gmt=>20)
|
24
|
+
tl.actual_takeoff_date_time_gmt.should == DateTime.new(1900, 1, 1, 0, 40, 0)
|
25
|
+
end
|
26
26
|
|
27
27
|
it "actual landing date_time dates are before arr_date_act_gmt if on time time is greater than landing time" do
|
28
|
-
arr_date_act_gmt = Date.new(1900,1,2)
|
29
|
-
tl = TripLeg.new(:arrival_date_gmt=>arr_date_act_gmt.to_fos_days
|
30
|
-
tl.actual_land_date_time_gmt.should == DateTime.new(1900,1,1,23,40,0)
|
28
|
+
arr_date_act_gmt = Date.new(1900, 1, 2)
|
29
|
+
tl = TripLeg.new(:arrival_date_gmt=>arr_date_act_gmt.to_fos_days, :land_time_act_gmt=>1420, :arriv_time_act_gmt=>20)
|
30
|
+
tl.actual_land_date_time_gmt.should == DateTime.new(1900, 1, 1, 23, 40, 0)
|
31
31
|
end
|
32
32
|
|
33
33
|
it "actual landing date_time dates are the same as arr_date_act_gmt if on time time is not greater than landing time" do
|
34
|
-
arr_date_act_gmt = Date.new(1900,1,2)
|
35
|
-
tl = TripLeg.new(:arrival_date_gmt=>arr_date_act_gmt.to_fos_days
|
36
|
-
tl.actual_land_date_time_gmt.should == DateTime.new(1900,1,2,0,20,0)
|
34
|
+
arr_date_act_gmt = Date.new(1900, 1, 2)
|
35
|
+
tl = TripLeg.new(:arrival_date_gmt=>arr_date_act_gmt.to_fos_days, :land_time_act_gmt=>20, :arriv_time_act_gmt=>40)
|
36
|
+
tl.actual_land_date_time_gmt.should == DateTime.new(1900, 1, 2, 0, 20, 0)
|
37
37
|
end
|
38
38
|
|
39
|
+
describe "should find correct passenger list" do
|
40
|
+
before :each do
|
41
|
+
@p1 = TripPassenger.new(:name=>"dan", :departure_leg_number=>0, :arrival_leg_number=>0)
|
42
|
+
@p2 = TripPassenger.new(:name=>"rob", :lead_pax=>1, :departure_leg_number=>1, :arrival_leg_number=>1)
|
43
|
+
@p3 = TripPassenger.new(:name=>"eric", :departure_leg_number=>1, :arrival_leg_number=>2)
|
44
|
+
@t = Trip.new(:trip_number=>100)
|
45
|
+
end
|
46
|
+
|
47
|
+
it "when leg has no passengers" do
|
48
|
+
mock(@t).passengers {[]}
|
49
|
+
tl = TripLeg.new(:trip_number=>100,:leg_number=>1, :trip=>@t)
|
50
|
+
tl.passenger_list.should == ''
|
51
|
+
end
|
52
|
+
|
53
|
+
it "when leg has no pax/deadhead" do
|
54
|
+
tl = TripLeg.new(:trip_number=>100,:leg_number=>1, :trip=>@t, :status=>1,:deadhead=>1)
|
55
|
+
tl.passenger_list.should == ''
|
56
|
+
end
|
57
|
+
|
58
|
+
it "when leg has some in range" do
|
59
|
+
stub(@t).passengers {[@p1, @p2, @p3]}
|
60
|
+
tl = TripLeg.new(:trip_number=>100,:leg_number=>1, :trip=>@t)
|
61
|
+
tl.passenger_list.should == "rob (lead pax) , eric"
|
62
|
+
end
|
63
|
+
|
64
|
+
it "when leg has 1 in range" do
|
65
|
+
stub(@t).passengers {[@p1, @p2, @p3]}
|
66
|
+
tl = TripLeg.new(:trip_number=>100,:leg_number=>2, :trip=>@t)
|
67
|
+
tl.passenger_list.should == "eric"
|
68
|
+
end
|
69
|
+
|
70
|
+
it "when leg has none in range" do
|
71
|
+
stub(@t).passengers {[@p1, @p2, @p3]}
|
72
|
+
tl = TripLeg.new(:trip_number=>100,:leg_number=>3, :trip=>@t)
|
73
|
+
tl.passenger_list.should == ""
|
74
|
+
end
|
75
|
+
end
|
39
76
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -4,10 +4,10 @@ require 'rr'
|
|
4
4
|
require 'pp'
|
5
5
|
|
6
6
|
unless defined?(DB_DEMO)
|
7
|
-
DB_DEMO = Sequel.odbc('
|
7
|
+
DB_DEMO = Sequel.odbc('demodata')#, :loggers=>[Logger.new($stdout)])
|
8
8
|
DB_DEMO.extend(Sequel::Pervasive::DatabaseMethods)
|
9
9
|
|
10
|
-
DB_FOS = Sequel.odbc('
|
10
|
+
DB_FOS = Sequel.odbc('fos')#, :loggers=>[Logger.new($stdout)])
|
11
11
|
DB_FOS.extend(Sequel::Pervasive::DatabaseMethods)
|
12
12
|
end
|
13
13
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fossil
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.33
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick Lardin, Daniel Sudol
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-04-
|
12
|
+
date: 2010-04-03 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|