fossil 0.5.14 → 0.5.15
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 +2 -2
- data/lib/fossil_dbr.rb +1 -1
- data/spec/helper_methods.rb +2 -2
- data/spec/models/trip_leg_spec.rb +1 -1
- data/spec/sequel/core_patch_spec.rb +37 -36
- data/spec/silly_spec.rb +62 -2
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.5.
|
1
|
+
0.5.15
|
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.15"
|
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-
|
12
|
+
s.date = %q{2010-12-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.extra_rdoc_files = [
|
data/lib/fossil_dbr.rb
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
# require the dbr models files that rewrite the model associations
|
2
|
-
Dir.glob(File.join(File.dirname(__FILE__),'dbr_models' , '*.rb')).each{|f| require_relative f}
|
2
|
+
Dir.glob(File.join(File.dirname(__FILE__),'dbr_models' , '*.rb')).each{|f| p f; require_relative f}
|
data/spec/helper_methods.rb
CHANGED
@@ -29,14 +29,14 @@ module HelperMethods
|
|
29
29
|
# controller helpers
|
30
30
|
def should_render_json_for(obj,path)
|
31
31
|
mock(obj).to_fos_json(is_a(Hash)) {"json"}
|
32
|
-
call_controller path
|
32
|
+
call_controller path, :json
|
33
33
|
response.body.should == "json"
|
34
34
|
end
|
35
35
|
|
36
36
|
def should_render_xml_for(obj,path)
|
37
37
|
request.env["HTTP_ACCEPT"] = "application/xml"
|
38
38
|
mock(obj).to_fos_xml(is_a(Hash)) {"xml"}
|
39
|
-
call_controller path
|
39
|
+
call_controller path, :xml
|
40
40
|
response.body.should == "xml"
|
41
41
|
end
|
42
42
|
|
@@ -2,53 +2,54 @@ require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
2
|
|
3
3
|
describe Sequel do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
describe "has method 'fos' that" do
|
6
|
+
before :each do
|
7
|
+
@db = Sequel.fos('fos')
|
8
|
+
end
|
9
|
+
|
10
|
+
it "instantiates a fos/pervasive db from an odbc name" do
|
11
|
+
@db.should_not be nil
|
12
|
+
end
|
13
|
+
|
14
|
+
it "actually works to see a fos table" do
|
15
|
+
TripLeg.db=@db
|
16
|
+
TripLeg.first.should_not be nil
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# describe "has method 'fos_dbr' that" do
|
21
|
+
# before :each do
|
22
|
+
# hash = {:host=>"localhost", :user=>'root', :password=>'', :database=>'test'}
|
23
|
+
# @db = Sequel.fos_dbr(hash)
|
8
24
|
# end
|
9
25
|
#
|
10
|
-
# it "instantiates
|
26
|
+
# it "instantiates dbr/mysql db from hash of params name" do
|
11
27
|
# @db.should_not be nil
|
12
28
|
# end
|
13
29
|
#
|
14
|
-
# it "actually works to see
|
15
|
-
# TripLeg.db=@db
|
30
|
+
# it "actually works to see dbr tables" do
|
31
|
+
# [TripLeg,Trip,Aircraft,Code,CrewLeg].each{|model| model.db=@db}
|
16
32
|
# TripLeg.first.should_not be nil
|
33
|
+
# TripLeg.first.trip.should_not be nil
|
34
|
+
## p TripLeg.select(:trip_number).eager_graph(:trip).sql
|
35
|
+
## p TripLeg.filter(:id=>"WERJ-1-17-40385-1243").first
|
36
|
+
## p TripLeg.filter(:'trip legs__trip_number'=>68070,:leg_number=>5).eager_graph(:crew_legs => [:crew_name, :position_code]).sql
|
37
|
+
## t = TripLeg.filter(:'trip legs__trip_number'=>68070,:leg_number=>5).eager_graph(:crew_legs => [:crew_name, :position_code]).all.first
|
38
|
+
## p [t.status,t.division,t.regulation,t.closed,t.ete,t.department,t.deadhead,t.company]
|
39
|
+
## p TripLeg.filter(:id=>"WERJ-1-17-40385-1243").eager_graph(:aircraft).all.first
|
40
|
+
## TripLeg.filter(:'trip legs__kid_date'=>40475..40475, :cancel_code=>0,:leg_type_code=>7).eager_graph(:crew_legs=>:position_code).all.size.should == 3
|
17
41
|
# end
|
18
42
|
# end
|
19
43
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
end
|
25
|
-
|
26
|
-
# it "instantiates dbr/mysql db from hash of params name" do
|
27
|
-
# @db.should_not be nil
|
28
|
-
# end
|
29
|
-
|
30
|
-
it "actually works to see dbr tables" do
|
31
|
-
[TripLeg,Aircraft,Code,CrewLeg].each{|model| model.db=@db}
|
32
|
-
# TripLeg.first.should_not be nil
|
33
|
-
# TripLeg.first.aircraft.should_not be nil
|
34
|
-
# p TripLeg.filter(:id=>"WERJ-1-17-40385-1243").first
|
35
|
-
p TripLeg.filter(:'trip legs__trip_number'=>68070,:leg_number=>5).eager_graph(:crew_legs => [:crew_name, :position_code]).sql
|
36
|
-
t = TripLeg.filter(:'trip legs__trip_number'=>68070,:leg_number=>5).eager_graph(:crew_legs => [:crew_name, :position_code]).all.first
|
37
|
-
p [t.status,t.division,t.regulation,t.closed,t.ete,t.department,t.deadhead,t.company]
|
38
|
-
# p TripLeg.filter(:id=>"WERJ-1-17-40385-1243").eager_graph(:aircraft).all.first
|
39
|
-
# TripLeg.filter(:'trip legs__kid_date'=>40475..40475, :cancel_code=>0,:leg_type_code=>7).eager_graph(:crew_legs=>:position_code).all.size.should == 3
|
40
|
-
end
|
44
|
+
it "set_db method finds sets db on all Sequel models" do
|
45
|
+
db = Sequel.fos('fos')
|
46
|
+
Sequel.set_db db
|
47
|
+
Trip.db.should == db
|
41
48
|
end
|
42
49
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
# Trip.db.should == db
|
47
|
-
# end
|
48
|
-
#
|
49
|
-
# it "converts fos_id to key that can be used to query model" do
|
50
|
-
# Sequel.fos_id_to_lookup_key("MERE-0-8-40443-1259").should == ['MERE',0,8,40443,1259]
|
51
|
-
# end
|
50
|
+
it "converts fos_id to key that can be used to query model" do
|
51
|
+
Sequel.fos_id_to_lookup_key("MERE-0-8-40443-1259").should == ['MERE',0,8,40443,1259]
|
52
|
+
end
|
52
53
|
|
53
54
|
end
|
54
55
|
|
data/spec/silly_spec.rb
CHANGED
@@ -1,9 +1,69 @@
|
|
1
1
|
require 'fossil'
|
2
2
|
require 'logger'
|
3
|
+
require 'pp'
|
4
|
+
|
5
|
+
module Sequel
|
6
|
+
class Model
|
7
|
+
module InstanceMethods
|
8
|
+
def this
|
9
|
+
if primary_key.is_a?(Array) and primary_key.include?(:'kid - user')
|
10
|
+
@this ||= model.dataset.filter(pk_hash.soft_delete(:'kid - user')).filter(:kid_user.like("%#{kid_user}%")).limit(1).naked
|
11
|
+
else
|
12
|
+
@this ||= model.dataset.filter(pk_hash).limit(1).naked
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
# 800 557-9965
|
19
|
+
# 0279507735
|
20
|
+
|
21
|
+
DB = Sequel.fos('flyos', :loggers=>[Logger.new($stdout)])
|
22
|
+
|
23
|
+
[Airport,TripLeg,AirportFbo].each{|m| m.db=DB}
|
24
|
+
#[Trip,CrewLeg,TripLeg,Passenger,Aircraft,Airport,AirportFbo,CrewLeg,Code,Personnel,Comment].each{|m| m.db=DB}
|
25
|
+
#p TripLeg.all.collect{ |t| [t.pic,t.sic,t.departure_fbo__name,t.arrival_fbo__name]}
|
26
|
+
#t = Trip.filter(:trips__trip_number=>8).eager_graph(:trip_legs).all.first
|
27
|
+
#p t
|
28
|
+
#p AirportFbo[Sequel.fos_id_to_lookup_key("D-0-2-75-21071")]
|
29
|
+
#p [:kid_user,:kid_mult,:kid_comm,:kid_date,:kid_time].zip(Sequel.fos_id_to_lookup_key("D-0-2-75-21071"))
|
30
|
+
def pk_list(prefix)
|
31
|
+
['kid - user','kid - mult','kid - comm','kid - date','kid - time'].collect{|v| "#{prefix} #{v}" }
|
32
|
+
#[:kid_user,:kid_mult,:kid_comm,:kid_date,:kid_time].collect{|v| "#{prefix} #{v.to_s}" }
|
33
|
+
end
|
34
|
+
|
35
|
+
#p AirportFbo.filter(:icao=>'KSFO').count
|
36
|
+
tl = TripLeg.filter(:trip_number=>8,:leg_number=>1).first#eager_graph(:arrival_fbo).all.first
|
37
|
+
#tl2 = TripLeg.filter(tl.pk_hash.soft_delete(:'kid - user')).filter(:kid_user.like("%#{tl.kid_user}%")).first
|
38
|
+
p tl.pk_hash
|
39
|
+
#tl.update(:fs_hotel=>"dan lodge")
|
40
|
+
#ku = tl.pk_hash.soft_delete(:'kid - user')
|
41
|
+
#p ku
|
42
|
+
#p tl.pk_hash.delete(:'kid - user')
|
43
|
+
#fbo = Airport.filter(:icao=>tl.arrival_icao).eager_graph(:airport_fbos).all.first
|
44
|
+
#tl.update(pk_list('fbo').zip(fbo.pk))
|
45
|
+
|
46
|
+
#p fbo.pk
|
47
|
+
#p fbo.primary_key
|
48
|
+
#tl.fbo_kid_user="D"
|
49
|
+
#p tl.fill_hash(pk_list('fbo'))
|
50
|
+
#pk_list('fbo').each_with_index do |k,i|
|
51
|
+
# tl.send(k= fbo.pk[i]
|
52
|
+
#end
|
53
|
+
#p tl.fill_hash(pk_list('fbo'))
|
54
|
+
# tl.arrival_icao
|
55
|
+
#p fbo.pk
|
56
|
+
|
57
|
+
#p fbos.collect{|f| [f.fos_id, f.name]}
|
58
|
+
|
59
|
+
#p tl.arrival_fbo
|
60
|
+
#p t.trip_legs.collect{|tl| [tl.fbo_kid_date,tl.fbo_kid_time,tl.fbo_kid_user,tl.fbo_kid_mult,tl.fbo_kid_comm]}
|
61
|
+
#p Trip.filter(:trip_number=>8).first.trip_legs.size
|
62
|
+
#p Personnel.filter(:crew_type=>1).all.collect &:employee_name
|
3
63
|
|
4
|
-
DB = Sequel.fos('fosprod', :loggers=>[Logger.new($stdout)])
|
5
|
-
[Passenger,CrewDuty].each{|m| m.db=DB}
|
6
64
|
#[Trip,CrewTrip,TripLeg,TripPassenger,Passenger,CrewLeg].each{|m| m.db=DB}
|
65
|
+
#pp TripLeg.filter(:depart_date_key=>Date.today - 1).all.collect{|t| t.fill_hash [:pax_count,:pax_estimated,:passengers_actual] }
|
66
|
+
|
7
67
|
#[Trip,TripLeg,Airport,AirportFbo,Aircraft,CrewLeg,Code,TripPassenger,Passenger,Personnel,Quote,Comment].each{|m| m.db=DB}
|
8
68
|
#start_date = Date.parse('June 15 2010').to_fos_days
|
9
69
|
#end_date = Date.parse('July 1 2010').to_fos_days
|
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
|
+
- 15
|
9
|
+
version: 0.5.15
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Patrick Lardin, Daniel Sudol
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-
|
17
|
+
date: 2010-12-03 00:00:00 -08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|