fossil 0.5.34 → 0.5.35
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/fossil.gemspec +8 -2
- data/lib/dbr_models/aircraft.rb +3 -0
- data/lib/dbr_models/airport.rb +3 -0
- data/lib/dbr_models/airport_fbo.rb +3 -0
- data/lib/fos_schema/fos_table_gen.rb +7 -5
- data/lib/models/aircraft.rb +1 -0
- data/lib/models/city_cost.rb +46 -0
- data/lib/models/city_pair.rb +53 -36
- data/lib/models/trip_leg.rb +0 -2
- data/lib/models/vendor_document.rb +2 -3
- data/spec/models/city_pair_spec.rb +50 -0
- data/spec/silly_spec.rb +16 -9
- data/spec/spec_helper.rb +1 -0
- metadata +9 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.35
|
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.5.
|
8
|
+
s.version = "0.5.35"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Daniel Sudol", "Patrick Lardin"]
|
12
|
-
s.date = %q{2011-03-
|
12
|
+
s.date = %q{2011-03-15}
|
13
13
|
s.description = %q{Access FOS/betrieve db with this Sequel based orm wrapper}
|
14
14
|
s.email = %q{dansudol@yahoo.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -20,6 +20,9 @@ Gem::Specification.new do |s|
|
|
20
20
|
"Rakefile",
|
21
21
|
"VERSION",
|
22
22
|
"fossil.gemspec",
|
23
|
+
"lib/dbr_models/aircraft.rb",
|
24
|
+
"lib/dbr_models/airport.rb",
|
25
|
+
"lib/dbr_models/airport_fbo.rb",
|
23
26
|
"lib/dbr_models/flight_log_expense.rb",
|
24
27
|
"lib/dbr_models/group_cost.rb",
|
25
28
|
"lib/dbr_models/personnel.rb",
|
@@ -55,6 +58,7 @@ Gem::Specification.new do |s|
|
|
55
58
|
"lib/models/cargo.rb",
|
56
59
|
"lib/models/check_group.rb",
|
57
60
|
"lib/models/checklist.rb",
|
61
|
+
"lib/models/city_cost.rb",
|
58
62
|
"lib/models/city_pair.rb",
|
59
63
|
"lib/models/code.rb",
|
60
64
|
"lib/models/comment.rb",
|
@@ -146,6 +150,7 @@ Gem::Specification.new do |s|
|
|
146
150
|
"spec/helper_classes.rb",
|
147
151
|
"spec/helper_methods.rb",
|
148
152
|
"spec/models/airport_fbo_spec.rb",
|
153
|
+
"spec/models/city_pair_spec.rb",
|
149
154
|
"spec/models/code_spec.rb",
|
150
155
|
"spec/models/flight_log_expense_spec.rb",
|
151
156
|
"spec/models/quote_spec.rb",
|
@@ -191,6 +196,7 @@ Gem::Specification.new do |s|
|
|
191
196
|
"spec/models/vendor_document_spec.rb",
|
192
197
|
"spec/models/trip_spec.rb",
|
193
198
|
"spec/models/airport_fbo_spec.rb",
|
199
|
+
"spec/models/city_pair_spec.rb",
|
194
200
|
"spec/be_model_with_values_matcher.rb"
|
195
201
|
]
|
196
202
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'sequel'
|
3
3
|
require 'logger'
|
4
|
-
|
4
|
+
require_relative '../sequel/pervasive_adapter'
|
5
5
|
|
6
6
|
Sequel::Model.plugin(:schema)
|
7
7
|
$db = Sequel.connect('odbc:/FOS')#, :loggers => [ Logger.new( $stdout ) ] )
|
@@ -57,7 +57,7 @@ COLUMN_DEFINITIONS
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def write_class_file
|
60
|
-
file_name = File.join("..","
|
60
|
+
file_name = File.join("..","models","#{@file_name}.rb")
|
61
61
|
puts "filename=#{file_name}"
|
62
62
|
file_str = File.exists?(file_name) ? File.read(file_name) : new_class_text
|
63
63
|
sequel_part = build_sequel_section
|
@@ -118,7 +118,9 @@ end
|
|
118
118
|
|
119
119
|
files = XFILE.filter(~:'xf$flags' => 16).and(:'xf$loc'.like('%.btr')).or(:'xf$loc'.like('%.BTR'))
|
120
120
|
files.each do |file|
|
121
|
-
|
122
|
-
|
123
|
-
|
121
|
+
if file[:'xf$name'] == "CITY COST"
|
122
|
+
p file[:'xf$name']
|
123
|
+
fos_class_gen = FOSClassGenerator.new(file)
|
124
|
+
fos_class_gen.write_class_file
|
125
|
+
end
|
124
126
|
end
|
data/lib/models/aircraft.rb
CHANGED
@@ -5,6 +5,7 @@ class Aircraft < Sequel::Model(:'aircraft')
|
|
5
5
|
# One to many to one associations with atomic primary keys
|
6
6
|
one_to_many :trips, :class=>:Trip, :key=>:'aircraft id', :primary_key=>:'aircraft id'
|
7
7
|
one_to_many :trip_legs, :class=>:TripLeg, :key=>:'aircraft id', :primary_key=>:'aircraft id'
|
8
|
+
many_to_one :aircraft_type, :class=>:AircraftType, :key=>:'type id', :primary_key=>:'type id'
|
8
9
|
n_to_o :owner, :class=>:Passenger, :prefix=>'owner'
|
9
10
|
|
10
11
|
code_association :company_value, :'company code', :company
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class CityCost < Sequel::Model(:'city cost')
|
2
|
+
set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
|
3
|
+
|
4
|
+
unrestrict_primary_key
|
5
|
+
|
6
|
+
def after_initialize
|
7
|
+
set_kids if new?
|
8
|
+
end
|
9
|
+
|
10
|
+
def set_kids
|
11
|
+
self.kid_date = rand(65535)
|
12
|
+
self.kid_time = rand(65535)
|
13
|
+
self.kid_comm = rand(255)
|
14
|
+
self.kid_mult = rand(255)
|
15
|
+
self.kid_user = rand(36**4).to_s(36)
|
16
|
+
self.owner_kid_date = citypair.kid_date
|
17
|
+
self.owner_kid_time = citypair.kid_time
|
18
|
+
self.owner_kid_mult = citypair.kid_mult
|
19
|
+
self.owner_kid_comm = citypair.kid_comm
|
20
|
+
self.owner_kid_user = citypair.kid_user
|
21
|
+
end
|
22
|
+
|
23
|
+
n_to_o :city_pair, :class=>:CityPair, :prefix=>'owner'
|
24
|
+
|
25
|
+
#### BEGIN GENERATED SECTION ####
|
26
|
+
|
27
|
+
column_alias :dh_fare, :'dh fare'
|
28
|
+
column_alias :effective_date, :'effective date'
|
29
|
+
column_alias :end_date, :'end date'
|
30
|
+
column_alias :fare, :'fare'
|
31
|
+
column_alias :internal0, :'internal0'
|
32
|
+
column_alias :kid_comm, :'kid - comm'
|
33
|
+
column_alias :kid_date, :'kid - date'
|
34
|
+
column_alias :kid_mult, :'kid - mult'
|
35
|
+
column_alias :kid_time, :'kid - time'
|
36
|
+
column_alias :kid_user, :'kid - user'
|
37
|
+
column_alias :owner_kid_comm, :'owner kid - comm'
|
38
|
+
column_alias :owner_kid_date, :'owner kid - date'
|
39
|
+
column_alias :owner_kid_mult, :'owner kid - mult'
|
40
|
+
column_alias :owner_kid_time, :'owner kid - time'
|
41
|
+
column_alias :owner_kid_user, :'owner kid - user'
|
42
|
+
column_alias :key0, :'key0'
|
43
|
+
column_alias :key1, :'key1'
|
44
|
+
#### END GENERATED SECTION ####
|
45
|
+
|
46
|
+
end
|
data/lib/models/city_pair.rb
CHANGED
@@ -1,43 +1,60 @@
|
|
1
1
|
class CityPair < Sequel::Model(:'city pair')
|
2
|
+
set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
|
3
|
+
|
4
|
+
unrestrict_primary_key
|
5
|
+
|
6
|
+
def after_initialize
|
7
|
+
set_kids if new?
|
8
|
+
end
|
9
|
+
|
10
|
+
def set_kids
|
11
|
+
self.kid_date = rand(65535)
|
12
|
+
self.kid_time = rand(65535)
|
13
|
+
self.kid_comm = rand(255)
|
14
|
+
self.kid_mult = rand(255)
|
15
|
+
self.kid_user = rand(36**4).to_s(36)
|
16
|
+
end
|
17
|
+
|
18
|
+
o_to_n :city_costs, :class=>:CityCost, :prefix=>'owner'
|
2
19
|
|
3
20
|
#### BEGIN GENERATED SECTION ####
|
4
|
-
set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
|
5
21
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
22
|
+
column_alias :additional_distance, :'additional distance'
|
23
|
+
column_alias :additional_time, :'additional time'
|
24
|
+
column_alias :aircraft_type_id, :'aircraft type id'
|
25
|
+
column_alias :allocation_1, :'allocation 1'
|
26
|
+
column_alias :allocation_2, :'allocation 2'
|
27
|
+
column_alias :cklist_kid_comm, :'cklist kid - comm'
|
28
|
+
column_alias :cklist_kid_date, :'cklist kid - date'
|
29
|
+
column_alias :cklist_kid_mult, :'cklist kid - mult'
|
30
|
+
column_alias :cklist_kid_time, :'cklist kid - time'
|
31
|
+
column_alias :cklist_kid_user, :'cklist kid - user'
|
32
|
+
column_alias :dh_fare, :'dh fare'
|
33
|
+
column_alias :distance, :'distance'
|
34
|
+
column_alias :expiration_date, :'expiration date'
|
35
|
+
column_alias :fare, :'fare'
|
36
|
+
column_alias :flight_time, :'flight time'
|
37
|
+
column_alias :from_ap_id, :'from ap id'
|
38
|
+
column_alias :from_ap_prefix, :'from ap prefix'
|
39
|
+
column_alias :from_area_id, :'from area id'
|
40
|
+
column_alias :internal01, :'internal01'
|
41
|
+
column_alias :internal02, :'internal02'
|
42
|
+
column_alias :kid_comm, :'kid - comm'
|
43
|
+
column_alias :kid_date, :'kid - date'
|
44
|
+
column_alias :kid_mult, :'kid - mult'
|
45
|
+
column_alias :kid_time, :'kid - time'
|
46
|
+
column_alias :kid_user, :'kid - user'
|
47
|
+
column_alias :outside_eec_percent, :'outside eec percent'
|
48
|
+
column_alias :to_ap_id, :'to ap id'
|
49
|
+
column_alias :to_ap_prefix, :'to ap prefix'
|
50
|
+
column_alias :to_area_id, :'to area id'
|
51
|
+
column_alias :internal0, :'internal0'
|
52
|
+
column_alias :key0, :'key0'
|
53
|
+
column_alias :key1, :'key1'
|
54
|
+
column_alias :key2, :'key2'
|
55
|
+
column_alias :key3, :'key3'
|
56
|
+
column_alias :key4, :'key4'
|
57
|
+
column_alias :key5, :'key5'
|
41
58
|
#### END GENERATED SECTION ####
|
42
59
|
|
43
60
|
end
|
data/lib/models/trip_leg.rb
CHANGED
@@ -8,8 +8,6 @@ class TripLeg < Sequel::Model(:'trip legs')
|
|
8
8
|
many_to_one :locked_by, :class=>:User, :key=>:'locked by - user id', :primary_key=>:'users initials'
|
9
9
|
many_to_one :leg_rate_aircraft, :class=>:Aircraft, :key=>:'leg rate ac id', :primary_key=>:'aircraft id'
|
10
10
|
many_to_one :authorizer_name, :class=>:Personnel, :key=>:authorization, :primary_key=>:employee_id
|
11
|
-
many_to_one :departure_fuel_vendor, :class=>:Vendor, :key=>:dep_fuel_vendor, :primary_key=>:vendor_id
|
12
|
-
many_to_one :arrival_fuel_vendor, :class=>:Vendor, :key=>:arr_fuel_vendor, :primary_key=>:vendor_id
|
13
11
|
|
14
12
|
# Many to one associations with composite primary keys
|
15
13
|
n_to_o :trip, :class=>:Trip, :prefix=>'trips'
|
@@ -1,6 +1,8 @@
|
|
1
1
|
class VendorDocument < Sequel::Model(:'vendor documents')
|
2
2
|
set_primary_key [:'kid - user', :'kid - mult', :'kid - comm', :'kid - date', :'kid - time']
|
3
3
|
|
4
|
+
unrestrict_primary_key
|
5
|
+
|
4
6
|
# helper accessors for creating vendor document
|
5
7
|
# filename_prefix helps set up the path to the document
|
6
8
|
attr_accessor :doc_type_value, :file_name_prefix, :doc_type, :file_name
|
@@ -9,9 +11,6 @@ class VendorDocument < Sequel::Model(:'vendor documents')
|
|
9
11
|
column_alias :trip_number, :number, :type => :integer
|
10
12
|
column_alias :description, :name
|
11
13
|
|
12
|
-
# Developpers must have the ability to set the PK programmatically
|
13
|
-
unrestrict_primary_key
|
14
|
-
|
15
14
|
# Code associations
|
16
15
|
code_association :type, :document_type, :aircraft_document
|
17
16
|
|
@@ -0,0 +1,50 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
RSpec::Matchers.define :have_valid_kid_keys do |expected|
|
4
|
+
match do |actual|
|
5
|
+
actual.kid_date.to_s.should =~ /\d{1,5}/
|
6
|
+
actual.kid_time.to_s.should =~ /\d{1,5}/
|
7
|
+
actual.kid_user.should =~ /\w{4}/
|
8
|
+
actual.kid_mult.to_s.should =~ /\d{1,3}/
|
9
|
+
actual.kid_comm.to_s.should =~ /\d{1,3}/
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
class Sequel::Model::Associations::OneToManyAssociationReflection
|
15
|
+
# one_to_many associations can only have associated objects if none of
|
16
|
+
# the :keys options have a nil value.
|
17
|
+
def can_have_associated_objects?(obj)
|
18
|
+
!self[:primary_keys].any?{|k| obj.send(k).nil?}
|
19
|
+
# !self[:primary_keys].any?{|k| obj.send(:[],k).nil?}
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
describe CityPair do
|
24
|
+
|
25
|
+
it "sets kid values for new city_pair" do
|
26
|
+
city_pair = CityPair.new
|
27
|
+
begin
|
28
|
+
city_pair.should have_valid_kid_keys
|
29
|
+
# p CityPair.aliases
|
30
|
+
p city_pair.city_costs
|
31
|
+
# p city_pair.kid_user
|
32
|
+
# p city_pair.send(:[],:'kid - user')
|
33
|
+
rescue => e
|
34
|
+
pp [e,e.backtrace]
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
it "sets kid vlues for CityCost" do
|
39
|
+
# city_pair = CityPair.new
|
40
|
+
# city_cost = CityCost.new(:city_pair=>city_pair)
|
41
|
+
# city_cost.should have_valid_kid_keys
|
42
|
+
# city_pair.kid_date.to_s.should =~ /\d{4,5}/
|
43
|
+
# city_pair.kid_time.to_s.should =~ /\d{4,5}/
|
44
|
+
# city_pair.kid_user.should =~ /\w{4}/
|
45
|
+
# city_pair.kid_mult.to_s.should =~ /\d{1,3}/
|
46
|
+
# city_pair.kid_comm.to_s.should =~ /\d{1,3}/
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
data/spec/silly_spec.rb
CHANGED
@@ -3,31 +3,38 @@ require 'logger'
|
|
3
3
|
require 'pp'
|
4
4
|
|
5
5
|
#DB = Sequel.fos('fosprod', :loggers=>[Logger.new($stdout)])
|
6
|
+
DB = Sequel.fos('fos', :loggers=>[Logger.new($stdout)])
|
7
|
+
#DB = Sequel.fos('demo_company_fos_db')#, :loggers=>[Logger.new($stdout)])
|
6
8
|
#DB = Sequel.fos('flyos')#, :loggers=>[Logger.new($stdout)])
|
7
|
-
#[
|
8
|
-
|
9
|
-
|
9
|
+
#[CityPair,CityCost].each {|model| model.db = DB}
|
10
|
+
[Vendor].each {|model| model.db = DB}
|
11
|
+
#p Aircraft.first.type_id
|
10
12
|
#p [AirportFuel.min(:kid_date),AirportFuel.max(:kid_date)]
|
11
13
|
#p [TripLeg.min(:dept_date_gmt),TripLeg.max(:dept_date_gmt)]
|
12
14
|
#p [Date.from_fos_days(TripLeg.min(:dept_date_gmt)).to_s,Date.from_fos_days(TripLeg.max(:dept_date_gmt)).to_s]
|
13
|
-
|
14
|
-
#p TripLeg.filter(
|
15
|
+
p Vendor.count
|
16
|
+
#p TripLeg.filter{kid_date > 40500}.limit(10).all.collect &:dep_fuel_vendor
|
15
17
|
#p Passenger.filter(:kid_date=>38439, :kid_time=>1428, :kid_comm=>1, :kid_mult=>0).first
|
16
18
|
#p Aircraft.filter(:kid_date=>39722).first.owner_name
|
17
19
|
#p Aircraft.select(:kid_date,:owner_kid_date,:owner_kid_time).all.collect{|c| [c.kid_date,c.owner_kid_date,c.owner_kid_time] }
|
18
|
-
#p Aircraft.select(:kid_date,:owner_name,:owner_kid_user,:owner_kid_comm,:owner_kid_mult,:owner_kid_date,:owner_kid_time).
|
20
|
+
#p Aircraft.select(:kid_date,:tail_number,:owner_name,:owner_kid_user,:owner_kid_comm,:owner_kid_mult,:owner_kid_date,:owner_kid_time).all.collect{|c| [c.kid_date,c.tail_number,c.owner_name,c.owner_kid_user,c.owner_kid_comm,c.owner_kid_mult,c.owner_kid_date,c.owner_kid_time] }
|
19
21
|
#p Aircraft.select(:owner_name).all.collect(&:owner_name).uniq.sort
|
20
|
-
|
22
|
+
#p Passenger.filter(:name.like('%CTA%')).first
|
23
|
+
#p TripLeg.all.collect(&:aircraft__tail_number).uniq
|
24
|
+
#
|
21
25
|
#Aircraft.first.owner
|
22
26
|
#p TripLeg.filter{flight_time_actual > 0 }.first.aft_time_view
|
23
27
|
|
24
28
|
#p TripLeg.select(:cancel_code).distinct(:cancel_code)
|
25
29
|
#p TripLeg.filter{ cancel_code >1 }.count
|
26
30
|
|
27
|
-
#p TripLeg.first(:trip_number=>
|
28
|
-
#
|
31
|
+
#p TripLeg.first(:trip_number=>85868,:leg_number=>4).fill_hash(
|
32
|
+
#p TripLeg.first(:trip_number=>87204,:leg_number=>2).fill_hash(
|
33
|
+
# [:kid_date,:planned_departure_date_time_gmt,:status,:deadhead,:leg_type_code,:trip__trip_type_code]
|
29
34
|
#)
|
30
35
|
|
36
|
+
#pp TripLeg.first(:trip_number=>87204,:leg_number=>2).trip.values
|
37
|
+
|
31
38
|
#p QuoteLeg.filter{kid_date > (Date.today-30)}.filter{block_time_actual > 0}.first.confirmation_number
|
32
39
|
#p t.actual_departure_date_time_gmt.to_time
|
33
40
|
#p t.actual_departure_date_time_gmt.to_time.utc
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 5
|
8
|
-
-
|
9
|
-
version: 0.5.
|
8
|
+
- 35
|
9
|
+
version: 0.5.35
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Daniel Sudol
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03-
|
18
|
+
date: 2011-03-15 00:00:00 -07:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -72,6 +72,9 @@ files:
|
|
72
72
|
- Rakefile
|
73
73
|
- VERSION
|
74
74
|
- fossil.gemspec
|
75
|
+
- lib/dbr_models/aircraft.rb
|
76
|
+
- lib/dbr_models/airport.rb
|
77
|
+
- lib/dbr_models/airport_fbo.rb
|
75
78
|
- lib/dbr_models/flight_log_expense.rb
|
76
79
|
- lib/dbr_models/group_cost.rb
|
77
80
|
- lib/dbr_models/personnel.rb
|
@@ -107,6 +110,7 @@ files:
|
|
107
110
|
- lib/models/cargo.rb
|
108
111
|
- lib/models/check_group.rb
|
109
112
|
- lib/models/checklist.rb
|
113
|
+
- lib/models/city_cost.rb
|
110
114
|
- lib/models/city_pair.rb
|
111
115
|
- lib/models/code.rb
|
112
116
|
- lib/models/comment.rb
|
@@ -198,6 +202,7 @@ files:
|
|
198
202
|
- spec/helper_classes.rb
|
199
203
|
- spec/helper_methods.rb
|
200
204
|
- spec/models/airport_fbo_spec.rb
|
205
|
+
- spec/models/city_pair_spec.rb
|
201
206
|
- spec/models/code_spec.rb
|
202
207
|
- spec/models/flight_log_expense_spec.rb
|
203
208
|
- spec/models/quote_spec.rb
|
@@ -270,4 +275,5 @@ test_files:
|
|
270
275
|
- spec/models/vendor_document_spec.rb
|
271
276
|
- spec/models/trip_spec.rb
|
272
277
|
- spec/models/airport_fbo_spec.rb
|
278
|
+
- spec/models/city_pair_spec.rb
|
273
279
|
- spec/be_model_with_values_matcher.rb
|