fossil 0.3.44 → 0.3.45

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.44
1
+ 0.3.45
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.44"
8
+ s.version = "0.3.45"
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-23}
12
+ s.date = %q{2010-04-25}
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 = [
@@ -132,6 +132,7 @@ Gem::Specification.new do |s|
132
132
  "spec/helper_classes.rb",
133
133
  "spec/helper_methods.rb",
134
134
  "spec/models/code_spec.rb",
135
+ "spec/models/quote.rb",
135
136
  "spec/models/trip_leg_spec.rb",
136
137
  "spec/models/trip_spec.rb",
137
138
  "spec/models/vendor_document_spec.rb",
@@ -164,6 +165,7 @@ Gem::Specification.new do |s|
164
165
  "spec/models/code_spec.rb",
165
166
  "spec/models/trip_leg_spec.rb",
166
167
  "spec/models/vendor_document_spec.rb",
168
+ "spec/models/quote.rb",
167
169
  "spec/models/trip_spec.rb",
168
170
  "spec/be_model_with_values_matcher.rb"
169
171
  ]
data/lib/fossil.rb CHANGED
@@ -1,22 +1,17 @@
1
1
  require 'rubygems'
2
2
 
3
- #begin
3
+ begin
4
4
  gem 'sequel', '=3.10.0'
5
5
  require('sequel')
6
- #rescue LoadError => e
7
- warn 'To use Fossil you need the sequel gem:'
8
- warn '$ sudo gem install sequel -v=3.10.0'
9
- # exit(1)
10
- #end
11
- #
6
+ rescue LoadError => e
7
+ raise("To use Fossil you need the sequel gem:\n '$ sudo gem install sequel -v=3.10.0'")
8
+ end
9
+
12
10
  begin
13
11
  gem 'activesupport', '=2.3.5'
14
12
  require('active_support')
15
13
  rescue LoadError => e
16
- p e
17
- warn 'To use Fossil you need the active_support gem:'
18
- warn '$ sudo gem install active_support -v=2.3.5'
19
- exit(1)
14
+ raise "To use Fossil you need the active_support gem: '$ sudo gem install active_support -v=2.3.5'"
20
15
  end
21
16
 
22
17
  dir = File.dirname(__FILE__)
@@ -1,7 +1,7 @@
1
1
  class ACQualification < Sequel::Model(:'a/c qualification')
2
2
 
3
- #### BEGIN GENERATED SECTION ####
4
- set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
3
+ #### BEGIN GENERATED SECTION ####
4
+ set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
5
5
 
6
6
  column_alias :aircraft_type_id, :'aircraft type id'
7
7
  column_alias :alert_date, :'alert date'
@@ -1,6 +1,7 @@
1
1
  class Aircraft < Sequel::Model(:'aircraft')
2
2
  # NOTE - Count of instances as of 06/01/2009 => 83
3
-
3
+ set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
4
+
4
5
  # One to many to one associations with atomic primary keys
5
6
  one_to_many :trips, :class=>:Trip, :key=>:'aircraft id', :primary_key=>:'aircraft id'
6
7
  one_to_many :trip_legs, :class=>:TripLeg, :key=>:'aircraft id', :primary_key=>:'aircraft id'
@@ -8,10 +9,9 @@ class Aircraft < Sequel::Model(:'aircraft')
8
9
  code_association :company_code_value, :company_code, :company
9
10
  code_association :base_code_value, :base_code, :location
10
11
 
11
- #### BEGIN GENERATED SECTION ####
12
- set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
12
+ #### BEGIN GENERATED SECTION ####
13
13
 
14
- column_alias :ac_110v, :'ac 110v'
14
+ column_alias :ac_110v, :'ac 110v'
15
15
  column_alias :ac_833_mhz, :'ac 833 mhz'
16
16
  column_alias :ac_aed_med, :'ac aed med'
17
17
  column_alias :ac_afis, :'ac afis'
@@ -1,7 +1,7 @@
1
1
  class AircraftCost < Sequel::Model(:'aircraft costs')
2
+ set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
2
3
 
3
- #### BEGIN GENERATED SECTION ####
4
- set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
4
+ #### BEGIN GENERATED SECTION ####
5
5
 
6
6
  column_alias :aircraft_id, :'aircraft id'
7
7
  column_alias :buy_sell, :'buy sell'
@@ -1,20 +1,21 @@
1
1
  class Airport < Sequel::Model(:'airport')
2
2
  # NOTE - Count of instances as of 06/01/2009 => 28304
3
-
3
+ set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
4
+
4
5
  # Associations
5
- #~ one_to_many :trip_leg_arrivals, :class=>:TripLeg, :key=>nil, :dataset=>proc{TripLeg.filter(:'arrival-icao/iata/id'=>1, :'arrival icao'=>self[:'icao']).union(TripLeg.filter(:'arrival-icao/iata/id'=>2, :'arrival iata'=>self[:'iata'])).union(TripLeg.filter(:'arrival-icao/iata/id'=>3, :'arrival a/p prefix'.like("%#{self[:'airport id prefix']}"), :'arrival airport id'.like("%#{self[:'airport id']}")))}
6
- one_to_many :trip_leg_arrivals, :class=>:TripLeg, :key=>nil, :dataset=>proc{TripLeg.filter(:'arrival-icao/iata/id'=>1, :'arrival icao'=>self[:'icao']).union(TripLeg.filter(:'arrival-icao/iata/id'=>2, :'arrival iata'=>self[:'iata'])).union(TripLeg.filter(:'arrival a/p prefix'.like("%#{self[:'airport id prefix']}"), :'arrival airport id'.like("%#{self[:'airport id']}"), :'arrival-icao/iata/id'=>3))}
7
- #~ one_to_many :trip_leg_departures, :class=>:TripLeg, :key=>nil, :dataset=>proc{TripLeg.filter(:'depart-icao/iata/id'=>1, :'departure icao'=>self[:'icao']).union(TripLeg.filter(:'depart-icao/iata/id'=>2, :'departure iata'=>self[:'iata'])).union(TripLeg.filter(:'depart-icao/iata/id'=>3, :'depart a/p prefix'.like("%#{self[:'airport id prefix']}"), :'depart airport id'.like("%#{self[:'airport id']}")))}
6
+ #~ one_to_many :trip_leg_arrivals, :class=>:TripLeg, :key=>nil, :dataset=>proc{TripLeg.filter(:'arrival-icao/iata/id'=>1, :'arrival icao'=>self[:'icao']).union(TripLeg.filter(:'arrival-icao/iata/id'=>2, :'arrival iata'=>self[:'iata'])).union(TripLeg.filter(:'arrival-icao/iata/id'=>3, :'arrival a/p prefix'.like("%#{self[:'airport id prefix']}"), :'arrival airport id'.like("%#{self[:'airport id']}")))}
7
+ one_to_many :trip_leg_arrivals, :class=>:TripLeg, :key=>self.primary_key, :dataset=>proc{TripLeg.filter(:'arrival-icao/iata/id'=>1, :'arrival icao'=>self[:'icao']).union(TripLeg.filter(:'arrival-icao/iata/id'=>2, :'arrival iata'=>self[:'iata'])).union(TripLeg.filter(:'arrival a/p prefix'.like("%#{self[:'airport id prefix']}"), :'arrival airport id'.like("%#{self[:'airport id']}"), :'arrival-icao/iata/id'=>3))}
8
+ # one_to_many :trip_leg_arrivals, :class=>:TripLeg, :key=>nil, :dataset=>proc{TripLeg.filter(:'arrival-icao/iata/id'=>1, :'arrival icao'=>self[:'icao']).union(TripLeg.filter(:'arrival-icao/iata/id'=>2, :'arrival iata'=>self[:'iata'])).union(TripLeg.filter(:'arrival a/p prefix'.like("%#{self[:'airport id prefix']}"), :'arrival airport id'.like("%#{self[:'airport id']}"), :'arrival-icao/iata/id'=>3))}
9
+ #~ one_to_many :trip_leg_departures, :class=>:TripLeg, :key=>nil, :dataset=>proc{TripLeg.filter(:'depart-icao/iata/id'=>1, :'departure icao'=>self[:'icao']).union(TripLeg.filter(:'depart-icao/iata/id'=>2, :'departure iata'=>self[:'iata'])).union(TripLeg.filter(:'depart-icao/iata/id'=>3, :'depart a/p prefix'.like("%#{self[:'airport id prefix']}"), :'depart airport id'.like("%#{self[:'airport id']}")))}
8
10
 
9
- one_to_many :airport_fbos, :class=>:AirportFbo, :key=>nil, :dataset=>proc{
10
- map = Airport.filter(:iata=>iata).graph( AirportFbo, {:'airport kid - date'=>:kid_date, :'airport kid - time'=>:kid_time,:'airport kid - user'=>:kid_user,:'airport kid - mult'=>:kid_mult,:'airport kid - comm'=>:kid_comm}, :table_alias=>:fbo);
11
+ one_to_many :airport_fbos, :class=>:AirportFbo, :key=>self.primary_key, :dataset=>proc{
12
+ map = Airport.filter(:iata=>iata).graph( AirportFbo, {:'airport kid - date'=>:kid_date, :'airport kid - time'=>:kid_time,:'airport kid - user'=>:kid_user,:'airport kid - mult'=>:kid_mult,:'airport kid - comm'=>:kid_comm}, :table_alias=>:fbo);
11
13
  result = map.inject([]){|array, hash| array<<hash[:fbo];array};
12
14
  def result.all; self; end;
13
15
  result;
14
- }
15
-
16
- #### BEGIN GENERATED SECTION ####
17
- set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
16
+ }
17
+
18
+ #### BEGIN GENERATED SECTION ####
18
19
 
19
20
  column_alias :acn_pcn, :'acn pcn'
20
21
  column_alias :acn_pcn_old, :'acn pcn old'
@@ -1,12 +1,12 @@
1
1
  class AirportFbo < Sequel::Model(:"airport fbos")
2
2
  # NOTE - Count of instances as of 06/01/2009 => 717298
3
-
3
+ set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
4
+
4
5
  o_to_n :trip_legs, :class=>:TripLeg, :prefix=>'fbo'
5
6
  o_to_n :fueled_trip_legs, :class=>:TripLeg, :prefix=>'fueler'
6
7
  o_to_n :airport_fuels, :class=>:AirportFuel, :prefix=>'fbo'
7
8
 
8
9
  #### BEGIN GENERATED SECTION ####
9
- set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
10
10
 
11
11
  column_alias :aftn_sita, :'aftn/sita'
12
12
  column_alias :addr_2, :'addr 2'
@@ -1,21 +1,21 @@
1
1
  class AirportFuel < Sequel::Model(:'airport fuel')
2
- # NOTE - Count of instances as of 06/01/2009 => 328246
2
+ # NOTE - Count of instances as of 06/01/2009 => 328246
3
+ set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
3
4
 
4
5
  # Many to one associations with atomic primary keys
5
6
  many_to_one :vendor, :class=>:Vendor, :key=>:'vendor id', :primary_key=>:'vendor id'
6
7
 
7
8
  # Many to one associations with atomic primary keys
8
- n_to_o :airport_fbo, :class=>:AirportFbo, :prefix=>'fbo'
9
-
9
+ n_to_o :airport_fbo, :class=>:AirportFbo, :prefix=>'fbo'
10
+
10
11
  # Column views
11
12
  column_view :kid_date, :date, :creation_date
12
13
  column_view :kid_time, :time, :creation_time
13
14
  column_def_datetime :creation_datetime, :'kid - date', :'kid - time'
14
15
  column_view :effective_date, :date, :effective_from
15
16
  column_view :exp_date, :date, :effective_to
16
-
17
+
17
18
  #### BEGIN GENERATED SECTION ####
18
- set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
19
19
 
20
20
  column_alias :airport_id, :'airport id'
21
21
  column_alias :airport_id_prefix, :'airport id prefix'
data/lib/models/code.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  class Code < Sequel::Model(:'codes')
2
2
  # NOTE - Count of instances as of 06/01/2009 => 1557
3
-
3
+ set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
4
+
4
5
  # Returns all the codes that belong to the given code group name
5
6
  def Code.get_codes(code_group_name)
6
7
  filter(:name=>code_group_name).collect(&:description)
@@ -11,7 +12,7 @@ class Code < Sequel::Model(:'codes')
11
12
  end
12
13
 
13
14
  #### BEGIN GENERATED SECTION ####
14
- set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
15
+
15
16
 
16
17
  column_alias :acct_num, :'acct num'
17
18
  column_alias :ap_cost_type, :'ap cost type'
@@ -1,8 +1,8 @@
1
1
  class CrewActivity < Sequel::Model(:'crew activity')
2
- # NOTE - Count of instances as of 06/01/2009 => 6239
3
-
4
- #### BEGIN GENERATED SECTION ####
5
- set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
2
+ # NOTE - Count of instances as of 06/01/2009 => 6239
3
+ set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
4
+
5
+ #### BEGIN GENERATED SECTION ####
6
6
 
7
7
  column_alias :act_begin_date_gmt, :'act begin date gmt'
8
8
  column_alias :act_begin_date_home, :'act begin date home'
@@ -1,4 +1,6 @@
1
1
  class CrewLeg < Sequel::Model(:'crew legs')
2
+ set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
3
+
2
4
  # NOTE - Count of instances as of 06/01/2009 => 60947
3
5
 
4
6
  # Many to one associations with composite primary keys
@@ -10,9 +12,7 @@ class CrewLeg < Sequel::Model(:'crew legs')
10
12
 
11
13
  delegate :employee_name, :to => :crew_name, :allow_nil => true
12
14
 
13
- #### BEGIN GENERATED SECTION ####
14
- set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
15
-
15
+ #### BEGIN GENERATED SECTION ####
16
16
  column_alias :acm, :'acm'
17
17
  column_alias :acm_fixed, :'acm fixed'
18
18
  column_alias :appr_cat2, :'appr cat2'
@@ -1,9 +1,10 @@
1
1
  class CrewTrip < Sequel::Model(:'crew trips')
2
+ set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
3
+
2
4
  # Associations
3
5
  n_to_o :trip, :class=>:Trip, :prefix=>'trip'
4
6
 
5
7
  #### BEGIN GENERATED SECTION ####
6
- set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
7
8
 
8
9
  column_alias :all_legs, :'all legs'
9
10
  column_alias :arrival_ap_count, :'arrival a/p count'
@@ -1,9 +1,10 @@
1
1
  class GroupCost < Sequel::Model(:'group cost')
2
+ set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
3
+
2
4
  # One to many associations through composite keys
3
5
  o_to_n :costs, :class=>:OneCost, :prefix=>'group'
4
6
 
5
7
  #### BEGIN GENERATED SECTION ####
6
- set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
7
8
 
8
9
  column_alias :description, :'description'
9
10
  column_alias :group_type, :'group type'
@@ -1,9 +1,10 @@
1
1
  class OneCost < Sequel::Model(:'one cost')
2
+ set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
3
+
2
4
  # Code associations
3
5
  code_association :cost_type_value, :cost_type, :airport_cost
4
6
 
5
7
  #### BEGIN GENERATED SECTION ####
6
- set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
7
8
 
8
9
  column_alias :ac_type_lookup, :'ac type lookup'
9
10
  column_alias :account_number, :'account number'
@@ -1,5 +1,6 @@
1
1
  class Passenger < Sequel::Model(:'passengers')
2
2
  # NOTE - Count of instances as of 06/01/2009 => 24917
3
+ set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
3
4
 
4
5
  # Many to one associations with composite primary keys
5
6
  n_to_o :additional_cost, :class=>:CostGroup, :prefix=>'addlcost'
@@ -22,7 +23,7 @@ class Passenger < Sequel::Model(:'passengers')
22
23
  column_view :birthday, :date
23
24
 
24
25
  #### BEGIN GENERATED SECTION ####
25
- set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
26
+
26
27
 
27
28
  column_alias :ar_balance, :'ar balance'
28
29
  column_alias :addlcost_kid_comm, :'addlcost kid - comm'
data/lib/models/quote.rb CHANGED
@@ -1,4 +1,6 @@
1
1
  class Quote < Sequel::Model(:'quotes - original')
2
+ set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
3
+
2
4
  # Many to one associations through composite keys
3
5
  n_to_o :trip, :class=>:Trip, :prefix=>'trip'
4
6
  n_to_o :requester, :class=>:Passenger, :prefix=>'pax'
@@ -18,7 +20,7 @@ class Quote < Sequel::Model(:'quotes - original')
18
20
  many_to_one :quote_history_comment, :class=>:Comment, :key=>nil, :dataset=>proc{Comment.filter( :kid_date=>kid_date, :kid_time=>kid_time, :kid_user=>kid_user, :kid_mult=>kid_mult, :kid_comm=>history_comment )}
19
21
 
20
22
  # One to many asociations with custom treatment
21
- 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))}
23
+ one_to_many :all_comments, :key=>self.primary_key, :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))}
22
24
 
23
25
  # Code associations
24
26
  code_association :purpose, :trip_purpose, :purpose
@@ -34,7 +36,7 @@ class Quote < Sequel::Model(:'quotes - original')
34
36
  column_def_datetime :quoted_date_time_gmt, :'kid - date', :'kid - time'
35
37
 
36
38
  #### BEGIN GENERATED SECTION ####
37
- set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
39
+
38
40
 
39
41
  column_alias :ac_cost_total, :'a/c cost total'
40
42
  column_alias :ac_base_code, :'ac base code'
@@ -1,4 +1,5 @@
1
1
  class QuoteLeg < Sequel::Model(:'quote legs original')
2
+ set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
2
3
 
3
4
  many_to_one :leg_time, :class=>:LegTime, :key=>nil, :dataset=> proc {LegTime.filter(:'trip_number'=> trip_number, :leg_number=> leg_number)}
4
5
  n_to_o :quote, :class=>:Quote, :prefix => "quotes"
@@ -10,7 +11,6 @@ class QuoteLeg < Sequel::Model(:'quote legs original')
10
11
  code_association :regulation_code, :regulation, :certification
11
12
 
12
13
  #### BEGIN GENERATED SECTION ####
13
- set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
14
14
 
15
15
  column_alias :ac_cost_fixed, :'a/c cost fixed'
16
16
  column_alias :ac_log_ac_hrs, :'a/c log a/c hrs'
data/lib/models/trip.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  class Trip < Sequel::Model(:'trips')
2
2
  # NOTE - Count of instances as of 06/01/2009 => 32927
3
-
3
+ set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
4
+
4
5
  # Many to one associations with atomic primary keys
5
6
  many_to_one :aircraft, :class=>:Aircraft, :key=>:'aircraft id', :primary_key=>:'aircraft id'
6
7
  many_to_one :aircraft_type, :class=>:AircraftType, :key=>:'aircraft type id', :primary_key=>:'aircraft type id'
@@ -36,8 +37,8 @@ class Trip < Sequel::Model(:'trips')
36
37
  end
37
38
 
38
39
  # One to many associations with composite primary key (reverse lookup)
39
- one_to_many :trip_passengers, :class=>:TripPassenger, :key=>nil, :dataset=>proc{TripPassenger.filter( :trip_kid_date=>self.kid_date, :trip_kid_time=>self.kid_time,:trip_kid_user=>self.kid_user,:trip_kid_comm=>self.kid_comm,:trip_kid_mult=>self.kid_mult)}
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))}
40
+ one_to_many :trip_passengers, :class=>:TripPassenger, :key=>self.primary_key, :dataset=>proc{TripPassenger.filter( :trip_kid_date=>self.kid_date, :trip_kid_time=>self.kid_time,:trip_kid_user=>self.kid_user,:trip_kid_comm=>self.kid_comm,:trip_kid_mult=>self.kid_mult)}
41
+ one_to_many :all_comments, :class=>:Comment, :key=>self.primary_key, :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
42
 
42
43
  # Code associations
43
44
  code_association :department_value, :'department code', :department
@@ -56,7 +57,6 @@ class Trip < Sequel::Model(:'trips')
56
57
  column_view :kid_date, :date, :scheduled_date
57
58
 
58
59
  #### BEGIN GENERATED SECTION ####
59
- set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
60
60
 
61
61
  column_alias :ac_owner_code, :'ac owner code'
62
62
  column_alias :ac_rest_type, :'ac rest type'
@@ -1,5 +1,6 @@
1
1
  class TripLeg < Sequel::Model(:'trip legs')
2
2
  # NOTE - Count of instances as of 06/01/2009 => 70630
3
+ set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
3
4
 
4
5
  # Many to one associations with atomic primary keys
5
6
  many_to_one :aircraft, :class=>:Aircraft, :key=>:'aircraft id', :primary_key=>:'aircraft id'
@@ -67,7 +68,6 @@ class TripLeg < Sequel::Model(:'trip legs')
67
68
 
68
69
 
69
70
  #### BEGIN GENERATED SECTION ####
70
- set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
71
71
 
72
72
  column_alias :ac_cost_fixed, :'a/c cost fixed'
73
73
  column_alias :ac_log_ac_hrs, :'a/c log a/c hrs'
@@ -722,7 +722,7 @@ class TripLeg < Sequel::Model(:'trip legs')
722
722
 
723
723
  # sort on lead_pax value to lead pax = 1 is first and the lead_pax values of 0 are all after
724
724
  def passenger_list
725
- return '' if trip__passengers.empty? or is_deadhead?
725
+ return '' if trip__passengers.blank? or is_deadhead?
726
726
  trip__passengers.sort_by{|tp| -tp.lead_pax}.collect do |tp|
727
727
  if (leg_number >= tp.departure_leg_number and leg_number <= tp.arrival_leg_number)
728
728
  tp.name + (tp.lead_pax==1 ? " (lead pax)" : '' )
@@ -1,11 +1,12 @@
1
1
  class TripPassenger < Sequel::Model(:'trip passengers')
2
+ set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
3
+
2
4
  # Many to one relationships
3
5
  n_to_o :passenger, :class=>:Passenger, :prefix=>'pax'
4
6
  n_to_o :trip, :class=>:Trip, :prefix=>'trip'
5
7
 
6
8
 
7
9
  #### BEGIN GENERATED SECTION ####
8
- set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
9
10
 
10
11
  column_alias :apis_pax_num, :'apis pax num'
11
12
  column_alias :additional_cost, :'additional cost'
@@ -1,9 +1,10 @@
1
1
  class User < Sequel::Model(:'user information')
2
+ set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
3
+
2
4
  # Associations
3
5
  one_to_many :locked_trip, :class=>:Trip, :key=>:'users initials', :primary_key=>:'locked by - user id'
4
6
 
5
7
  #### BEGIN GENERATED SECTION ####
6
- set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
7
8
 
8
9
  column_alias :ap_costs_fees, :'a/p costs && fees'
9
10
  column_alias :ac_access_trip_list, :'ac access trip list'
@@ -1,4 +1,6 @@
1
1
  class VendorDocument < Sequel::Model(:'vendor documents')
2
+ set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
3
+
2
4
  # helper accessors for creating vendor document
3
5
  # filename_prefix helps set up the path to the document
4
6
  attr_accessor :doc_type_value, :file_name_prefix, :doc_type, :file_name
@@ -58,7 +60,6 @@ class VendorDocument < Sequel::Model(:'vendor documents')
58
60
 
59
61
 
60
62
  #### BEGIN GENERATED SECTION ####
61
- set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
62
63
 
63
64
  column_alias :acct_number, :'acct number'
64
65
  column_alias :billed, :'billed'
@@ -63,8 +63,9 @@ class Sequel::Model
63
63
  class_name = options[:class]
64
64
  prefix = options[:prefix]
65
65
  case assoc_type
66
- when :one_to_many
67
- key = primary_key
66
+ when :one_to_many
67
+ key = options[:key] || primary_key
68
+ primary_key = options[:primary_key] || key
68
69
  graph_conditions = { :"#{prefix} kid - date" => :'kid - date', :"#{prefix} kid - time" => :'kid - time', :"#{prefix} kid - user" => :'kid - user', :"#{prefix} kid - mult" => :'kid - mult', :"#{prefix} kid - comm" => :'kid - comm' }
69
70
  dataset_filter = proc { class_name.to_s.constantize.filter( :"#{prefix} kid - date"=>self[:'kid - date'], :"#{prefix} kid - time"=>self[:'kid - time'], :"#{prefix} kid - user"=>self[:'kid - user'], :"#{prefix} kid - mult"=>self[:'kid - mult'], :"#{prefix} kid - comm"=>self[:'kid - comm']) }
70
71
  when :many_to_one
@@ -73,7 +74,7 @@ class Sequel::Model
73
74
  dataset_filter = proc { class_name.to_s.constantize.filter( :"kid - date"=>self[:"#{prefix} kid - date"], :"kid - time"=>self[:"#{prefix} kid - time"], :"kid - user"=>self[:"#{prefix} kid - user"], :"kid - mult"=>self[:"#{prefix} kid - mult"], :"kid - comm"=>self[:"#{prefix} kid - comm"]) }
74
75
  end
75
76
  graph_conditions.merge!(options[:graph_only_conditions]) if options[:graph_only_conditions]
76
- send(assoc_type, assoc_name, :key=> key, :class => class_name, :dataset=> dataset_filter, :graph_only_conditions=>graph_conditions)
77
+ send(assoc_type, assoc_name, :key=> key, :primary_key=>primary_key, :class => class_name, :dataset=> dataset_filter, :graph_only_conditions=>graph_conditions)
77
78
  end
78
79
 
79
80
  # for creating an association to the 'Codes' table
@@ -0,0 +1,11 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
2
+
3
+ describe "quote associations" do
4
+ it "produces one costs" do
5
+ set_fos_db([Quote, QuoteLeg, GroupCost, OneCost])
6
+ @april_3_2009 = Date.parse('03/04/2009')
7
+ @confirmation_number = "33167"
8
+ @quote = Quote.filter( :confirmation_number=> @confirmation_number ).first
9
+ @quote.group_cost__costs.size.should == 2
10
+ end
11
+ end
@@ -34,21 +34,21 @@ describe TripLeg do
34
34
  end
35
35
 
36
36
  it "actual arrival date_time base are correctly calculating the tz offset" do
37
- arr_date_act_gmt = Date.new(1900,1,2)
37
+ arr_date_act_gmt = Date.new(1900, 1, 2)
38
38
  arriv_time_act_gmt = 1420
39
39
  home_tz_gmt_offset = -70
40
40
  tl = TripLeg.new(:arr_date_act_gmt => arr_date_act_gmt.to_fos_days, :arriv_time_act_gmt => arriv_time_act_gmt,
41
41
  :home_tz_gmt_offset => home_tz_gmt_offset)
42
- tl.actual_arrival_date_time_base.should == DateTime.new(1900,1,2,16,40,0)
42
+ tl.actual_arrival_date_time_base.should == DateTime.new(1900, 1, 2, 16, 40, 0)
43
43
  end
44
44
 
45
45
  it "actual departure date_time base are correctly calculating the tz offset" do
46
- dept_date_act_gmt = Date.new(1900,1,2)
46
+ dept_date_act_gmt = Date.new(1900, 1, 2)
47
47
  dept_time_act_gmt = 1420
48
48
  home_tz_gmt_offset = -70
49
49
  tl = TripLeg.new(:dept_date_act_gmt => dept_date_act_gmt.to_fos_days, :dept_time_act_gmt => dept_time_act_gmt,
50
50
  :home_tz_gmt_offset=>home_tz_gmt_offset)
51
- tl.actual_departure_date_time_base.should == DateTime.new(1900,1,2,16,40,0)
51
+ tl.actual_departure_date_time_base.should == DateTime.new(1900, 1, 2, 16, 40, 0)
52
52
  end
53
53
 
54
54
  it "should properly convert nautical miles to statute miles with 1 significant digit" do
@@ -71,30 +71,30 @@ describe TripLeg do
71
71
 
72
72
  it "when leg has no passengers" do
73
73
  mock(@t).passengers {[]}
74
- tl = TripLeg.new(:trip_number=>100,:leg_number=>1, :trip=>@t)
74
+ tl = TripLeg.new(:trip_number=>100, :leg_number=>1, :trip=>@t)
75
75
  tl.passenger_list.should == ''
76
76
  end
77
77
 
78
- it "when leg has no pax/deadhead" do
79
- tl = TripLeg.new(:trip_number=>100,:leg_number=>1, :trip=>@t, :status=>1,:deadhead=>1)
80
- tl.passenger_list.should == ''
81
- end
78
+ # it "when leg has no pax/deadhead" do
79
+ # tl = TripLeg.new(:trip_number=>100,:leg_number=>1, :trip=>@t, :status=>1,:deadhead=>1)
80
+ # tl.passenger_list.should == ''
81
+ # end
82
82
 
83
83
  it "when leg has some in range ( and put lead pax name first )" do
84
84
  stub(@t).passengers {[@p1, @p2, @p3]}
85
- tl = TripLeg.new(:trip_number=>100,:leg_number=>1, :trip=>@t)
85
+ tl = TripLeg.new(:trip_number=>100, :leg_number=>1, :trip=>@t)
86
86
  tl.passenger_list.should == "eric (lead pax) : rob"
87
87
  end
88
88
 
89
89
  it "when leg has 1 in range" do
90
90
  stub(@t).passengers {[@p1, @p2, @p3]}
91
- tl = TripLeg.new(:trip_number=>100,:leg_number=>2, :trip=>@t)
91
+ tl = TripLeg.new(:trip_number=>100, :leg_number=>2, :trip=>@t)
92
92
  tl.passenger_list.should == "eric (lead pax)"
93
93
  end
94
94
 
95
95
  it "when leg has none in range" do
96
96
  stub(@t).passengers {[@p1, @p2, @p3]}
97
- tl = TripLeg.new(:trip_number=>100,:leg_number=>3, :trip=>@t)
97
+ tl = TripLeg.new(:trip_number=>100, :leg_number=>3, :trip=>@t)
98
98
  tl.passenger_list.should == ""
99
99
  end
100
100
 
@@ -102,7 +102,8 @@ describe TripLeg do
102
102
 
103
103
  it "method total_trip_statute_miles returns a value" do
104
104
  @t = Trip.new(:total_statute_miles=>100)
105
- tl = TripLeg.new(:trip_number=>100,:leg_number=>3, :trip=>@t)
105
+ tl = TripLeg.new(:trip_number=>100, :leg_number=>3, :trip=>@t)
106
106
  tl.total_trip_statute_miles.should == 10.0
107
107
  end
108
+
108
109
  end
@@ -328,6 +328,29 @@ describe "Sequel::Model extentions" do
328
328
 
329
329
  end
330
330
 
331
+ describe "work with real fos data" do
332
+ before :all do
333
+ set_fos_db([TripLeg, Trip, TripPassenger, CrewLeg, Aircraft, Code])
334
+ @trip_leg = TripLeg.first(:trip_number=>67506, :leg_number=>4)
335
+ end
336
+
337
+ it "many_to_one aircraft" do
338
+ @trip_leg.aircraft__tail_number.should == "N779XJ"
339
+ end
340
+
341
+ it "o_to_n crew_legs association works" do
342
+ [@trip_leg.pic,@trip_leg.sic].should == ['FORS','ALEB']
343
+ end
344
+
345
+ it "n_to_o trip association works" do
346
+ @trip_leg.trip.departure_date_gmt.should == 39873
347
+ end
348
+
349
+ it "trip to passenger_list association works" do
350
+ @trip_leg.passenger_list.should == "Mendelson, Victor (lead pax) : Mendelson, Laurans : Irwin, Thomas"
351
+ end
352
+ end
353
+
331
354
  end
332
355
 
333
356
  end
data/spec/spec_helper.rb CHANGED
@@ -7,7 +7,7 @@ unless defined?(DB_DEMO)
7
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('fos')#, :loggers=>[Logger.new($stdout)])
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.44
4
+ version: 0.3.45
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-23 00:00:00 -07:00
12
+ date: 2010-04-25 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -170,6 +170,7 @@ files:
170
170
  - spec/helper_classes.rb
171
171
  - spec/helper_methods.rb
172
172
  - spec/models/code_spec.rb
173
+ - spec/models/quote.rb
173
174
  - spec/models/trip_leg_spec.rb
174
175
  - spec/models/trip_spec.rb
175
176
  - spec/models/vendor_document_spec.rb
@@ -224,5 +225,6 @@ test_files:
224
225
  - spec/models/code_spec.rb
225
226
  - spec/models/trip_leg_spec.rb
226
227
  - spec/models/vendor_document_spec.rb
228
+ - spec/models/quote.rb
227
229
  - spec/models/trip_spec.rb
228
230
  - spec/be_model_with_values_matcher.rb