fossil 0.5.36 → 0.5.37
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/fossil.gemspec +1 -1
- data/lib/models/city_cost.rb +5 -5
- data/lib/models/trip_leg.rb +4 -1
- data/lib/sequel/model_patch.rb +2 -0
- data/spec/models/city_pair_spec.rb +4 -27
- data/spec/silly_spec.rb +14 -4
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.37
|
data/fossil.gemspec
CHANGED
data/lib/models/city_cost.rb
CHANGED
@@ -13,11 +13,11 @@ class CityCost < Sequel::Model(:'city cost')
|
|
13
13
|
self.kid_comm = rand(255)
|
14
14
|
self.kid_mult = rand(255)
|
15
15
|
self.kid_user = rand(36**4).to_s(36)
|
16
|
-
self.owner_kid_date =
|
17
|
-
self.owner_kid_time =
|
18
|
-
self.owner_kid_mult =
|
19
|
-
self.owner_kid_comm =
|
20
|
-
self.owner_kid_user =
|
16
|
+
self.owner_kid_date = city_pair.kid_date
|
17
|
+
self.owner_kid_time = city_pair.kid_time
|
18
|
+
self.owner_kid_mult = city_pair.kid_mult
|
19
|
+
self.owner_kid_comm = city_pair.kid_comm
|
20
|
+
self.owner_kid_user = city_pair.kid_user
|
21
21
|
end
|
22
22
|
|
23
23
|
n_to_o :city_pair, :class=>:CityPair, :prefix=>'owner'
|
data/lib/models/trip_leg.rb
CHANGED
@@ -75,7 +75,6 @@ class TripLeg < Sequel::Model(:'trip legs')
|
|
75
75
|
o_to_n :crew_legs, :class=>:CrewLeg, :prefix=>'trip leg'
|
76
76
|
o_to_n :audit_trails, :class=>:AuditTrail, :prefix=>'owner'
|
77
77
|
o_to_n :flight_log_expenses, :class=>:FlightLogExpense, :prefix=>'trip leg'
|
78
|
-
o_to_n :fuel_expenses, :class=>:FlightLogExpense, :prefix=>'trip leg', :extra_conditions => {:type => 1}
|
79
78
|
|
80
79
|
# Code associations
|
81
80
|
code_association :approval_value, :'approval code', :trip_approval
|
@@ -901,6 +900,10 @@ class TripLeg < Sequel::Model(:'trip legs')
|
|
901
900
|
end
|
902
901
|
|
903
902
|
# Fuel Expense Stuff
|
903
|
+
def fuel_expenses
|
904
|
+
flight_log_expenses.select{ |expense| expense.type == 1 }
|
905
|
+
end
|
906
|
+
|
904
907
|
def departure_fuel_expenses
|
905
908
|
fuel_expenses.select { |expense| expense.arrival_airport == 0 }
|
906
909
|
end
|
data/lib/sequel/model_patch.rb
CHANGED
@@ -55,6 +55,8 @@ class Sequel::Model
|
|
55
55
|
if method.to_s.split(/__/).size > 1
|
56
56
|
generate_delegator(method)
|
57
57
|
send(method.to_s.gsub('__', '_').to_sym)
|
58
|
+
elsif self.class.instance_variable_get("@aliases").values.include? method
|
59
|
+
send(:[],method)
|
58
60
|
else
|
59
61
|
super(method, * args, & block)
|
60
62
|
end
|
@@ -10,40 +10,17 @@ RSpec::Matchers.define :have_valid_kid_keys do |expected|
|
|
10
10
|
end
|
11
11
|
end
|
12
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
13
|
describe CityPair do
|
24
14
|
|
25
15
|
it "sets kid values for new city_pair" do
|
26
16
|
city_pair = CityPair.new
|
27
|
-
|
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
|
17
|
+
city_pair.should have_valid_kid_keys
|
36
18
|
end
|
37
19
|
|
38
20
|
it "sets kid vlues for CityCost" do
|
39
|
-
|
40
|
-
|
41
|
-
|
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}/
|
21
|
+
city_pair = CityPair.new
|
22
|
+
city_cost = CityCost.new(:city_pair=>city_pair)
|
23
|
+
city_cost.should have_valid_kid_keys
|
47
24
|
end
|
48
25
|
|
49
26
|
end
|
data/spec/silly_spec.rb
CHANGED
@@ -2,12 +2,22 @@ require_relative '../lib/fossil'
|
|
2
2
|
require 'logger'
|
3
3
|
require 'pp'
|
4
4
|
|
5
|
+
class Sequel::Model::Associations::OneToManyAssociationReflection
|
6
|
+
# one_to_many associations can only have associated objects if none of
|
7
|
+
# the :keys options have a nil value.
|
8
|
+
def can_have_associated_objects?(obj)
|
9
|
+
!self[:primary_keys].any?{|k| obj.send(k).nil?}
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
5
13
|
#DB = Sequel.fos('fosprod', :loggers=>[Logger.new($stdout)])
|
6
14
|
DB = Sequel.fos('fos', :loggers=>[Logger.new($stdout)])
|
7
15
|
#DB = Sequel.fos('demo_company_fos_db')#, :loggers=>[Logger.new($stdout)])
|
8
16
|
#DB = Sequel.fos('flyos')#, :loggers=>[Logger.new($stdout)])
|
9
|
-
|
10
|
-
|
17
|
+
[CityPair,CityCost].each {|model| model.db = DB}
|
18
|
+
p CityPair.first.city_costs
|
19
|
+
#p CityPair.first.send('kid - user')
|
20
|
+
#[TripLeg,FlightLogExpense].each {|model| model.db = DB}
|
11
21
|
#[Vendor].each {|model| model.db = DB}
|
12
22
|
#p Aircraft.first.type_id
|
13
23
|
#p [AirportFuel.min(:kid_date),AirportFuel.max(:kid_date)]
|
@@ -78,8 +88,8 @@ DB = Sequel.fos('fos', :loggers=>[Logger.new($stdout)])
|
|
78
88
|
#DB.execute('Update "trip legs" set "lunch comment" = \'hi\' where "trip number" = 83100 and "leg number" = 3')
|
79
89
|
#DB.execute('Update "trip legs" set "pax count" = 4 where "trip number" = 62 and "leg number" = 1 ')
|
80
90
|
#tl = TripLeg.filter(:trip_number=>69012,:leg_number=>1).eager_graph(:fuel_expenses).all.first
|
81
|
-
tl = TripLeg.first
|
82
|
-
p tl.fuel_expenses
|
91
|
+
#tl = TripLeg.first
|
92
|
+
#p tl.fuel_expenses
|
83
93
|
#p tl.actual_arrival_date_time_gmt
|
84
94
|
#date = TripLeg.filter(:arr_date_act_gmt=>0).filter{:verify_date >0}.order(:kid_date).last.kid_date # :arrival_date_gmt
|
85
95
|
#p Date.from_fos_days(date).to_s
|