trix51db 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/trix51db.rb +22 -48
  2. metadata +2 -2
data/lib/trix51db.rb CHANGED
@@ -719,8 +719,8 @@ end
719
719
  hashdata.each_pair do |k,v|
720
720
  next if v.nil?
721
721
  str = ''
722
- str = "#{k} = #{v}" if v.class.name != 'String'
723
- str = "#{k} = \"#{v}\"" if v.class.name == 'String'
722
+ str = %Q|#{k} = #{v}| if v.class.name != 'String'
723
+ str = %Q{#{k} = %Q|#{v}|} if v.class.name == 'String'
724
724
  inits.push( str )
725
725
  end
726
726
  inits.push( expression )
@@ -728,29 +728,6 @@ end
728
728
  return eval( str )
729
729
  end
730
730
 
731
- def hash_compare( h1, h2 ) #:nodoc:
732
-
733
- # Comparitors: like, not_like, not, equals, lt, gt
734
- #
735
-
736
- h1.keys.each { |key|
737
- #pp key
738
- #pp self.structure[key]
739
- if self.structure[key][:datatype] == 'calculated' then
740
- h2[key] = self.eval_in_context( h2, self.structure[key][:calculation] )
741
- end
742
- v1 = h1[key]
743
- if v1.class.name != 'Hash' then
744
- return false if not comparison( h2[key], 'is', h1[key] )
745
- else
746
- v1.each_pair do |operand, target|
747
- return false if not comparison( h2[key], operand, target )
748
- end
749
- end
750
- }
751
- return true
752
- end
753
-
754
731
  # delete records matching the specified hash
755
732
  # ==== Example
756
733
  # num_deleted = animal.delete_hash( {
@@ -1057,34 +1034,31 @@ end
1057
1034
 
1058
1035
  def index_add( urid, record ) #:nodoc:
1059
1036
  record.keys.each { |fieldname|
1060
- if self.indexed?(fieldname) then
1061
- # check index exists
1062
- if self.indices[fieldname].nil? then
1063
- self.index_build( fieldname )
1064
- else
1065
- # partial add
1066
- res = self.indices[fieldname]
1067
- rv = record[fieldname]
1068
- rlist = res[rv] || []
1069
- rlist.push( urid )
1070
- res[rv] = rlist
1071
- end
1072
- end
1037
+ next unless self.indexed?(fieldname)
1038
+ # check index exists
1039
+ if self.indices[fieldname].nil? then
1040
+ self.index_build( fieldname )
1041
+ else
1042
+ # partial add
1043
+ rv = record[fieldname]
1044
+ rlist = self.indices[fieldname][rv] || []
1045
+ rlist.push( urid )
1046
+ self.indices[fieldname][rv] = rlist
1047
+ end
1073
1048
  }
1074
1049
  end
1075
1050
 
1076
1051
  def index_update( oldurid, newurid, record ) #:nodoc:
1077
1052
  record.keys.each { |fieldname|
1078
- if self.indexed?(fieldname) then
1079
- # check index exists
1080
- if self.indices[fieldname].nil? then
1081
- self.index_build( fieldname )
1082
- else
1083
- # partial update
1084
- self.index_remove( oldurid )
1085
- self.index_add( newurid, record )
1086
- end
1087
- end
1053
+ next unless self.indexed?(fieldname)
1054
+ # check index exists
1055
+ if self.indices[fieldname].nil? then
1056
+ self.index_build( fieldname )
1057
+ else
1058
+ # partial update
1059
+ self.index_remove( oldurid )
1060
+ self.index_add( newurid, record )
1061
+ end
1088
1062
  }
1089
1063
  end
1090
1064
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trix51db
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-11 00:00:00.000000000 Z
12
+ date: 2012-06-13 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Database based on GDBM and Marshal with complex queries, indexes, constraints
15
15
  relationships and calculated fields.