fossil 0.4.19 → 0.4.20

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.19
1
+ 0.4.20
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.4.19"
8
+ s.version = "0.4.20"
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-09-22}
12
+ s.date = %q{2010-09-23}
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 = [
@@ -11,5 +11,10 @@ module Sequel
11
11
  def set_db(db)
12
12
  Sequel::Model.find_children.each { |klass| klass.to_s.constantize.db=db }
13
13
  end
14
+
15
+ # take a fos_id like: "SEMJ.0.15.40210.1342" and convert to ["SEMJ", 0, 15, 40210, 1342]
16
+ def fos_id_to_lookup_key(fos_id)
17
+ fos_id.split('.').collect{|v| v.match(/\d+/) ? v.to_i : v}
18
+ end
14
19
  end
15
20
  end
@@ -13,6 +13,16 @@ class Sequel::Model
13
13
  end
14
14
  end
15
15
 
16
+ # Using this order for keys because it makes it easier to query fos records.
17
+ # If you had a key like "MERE.0.8.40443.1259" for a trip leg and you did this:
18
+ # TripLeg['MERE',0,8,40443,1259], you would get a trip leg
19
+ # You still have to massage this key alittle to make the query:
20
+ # see Sequel.fos_id_to_lookup_key in core_patch.rb
21
+ PK_KEYS = [:"kid - user",:"kid - mult",:"kid - comm",:"kid - date",:"kid - time"]
22
+ def fos_id
23
+ PK_KEYS.collect{|key| value=send(key); value.strip! if value.is_a?(String); value}.join('.')
24
+ end
25
+
16
26
  # Passing in an array of attribute / method names, fills a hash with values from
17
27
  # the model. Can pass in attributes with __ like :passenger__name and the 'name'
18
28
  # value will be delegated to 'passenger' with the delegator being created on the fly.
@@ -23,5 +23,9 @@ describe Sequel do
23
23
  Trip.db.should == db
24
24
  end
25
25
 
26
+ it "converts fos_id to key that can be used to query model" do
27
+ Sequel.fos_id_to_lookup_key("MERE.0.8.40443.1259").should == ['MERE',0,8,40443,1259]
28
+ end
29
+
26
30
  end
27
31
 
@@ -6,7 +6,12 @@ describe "Sequel::Model extentions" do
6
6
  it "find_children method finds find Sequel::Models" do
7
7
  Sequel::Model.find_children # should not blow up
8
8
  end
9
-
9
+
10
+ it "makes fos_id" do
11
+ tl = TripLeg.new(:kid_user => 'ME ',:kid_mult => 1,:kid_comm => 2,:kid_date => 3,:kid_time => 4)
12
+ tl.fos_id.should == "ME.1.2.3.4"
13
+ end
14
+
10
15
  describe "fill_hash method" do
11
16
 
12
17
  it "works with attributes as array" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 4
8
- - 19
9
- version: 0.4.19
8
+ - 20
9
+ version: 0.4.20
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-09-22 00:00:00 -07:00
17
+ date: 2010-09-23 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency