beezwax 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.0
1
+ 0.7.1
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{beezwax}
8
- s.version = "0.7.0"
8
+ s.version = "0.7.1"
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"]
12
- s.date = %q{2010-12-22}
12
+ s.date = %q{2011-03-19}
13
13
  s.description = %q{Access Btrieve database files through a ruby API.}
14
14
  s.email = %q{plardin@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -2,16 +2,16 @@ class BtrieveSearchBuffer
2
2
  include Btrieve
3
3
  COMPARISON = {:equal=>1,:greater_than=>2,:less_than=>3, :not_equal=>4, :greater_than_or_equal=>5, :less_than_or_equal=>6}
4
4
  BOOLEAN = {:and=>1, :or=>2}
5
-
5
+
6
6
  def initialize(table, filter, fields_to_return, records_to_fetch=10, start_point=:next_record, max_reject_count=0)
7
7
  @table=table
8
8
  @filter=filter
9
9
  @records_to_fetch=records_to_fetch
10
10
  @fields_to_return=fields_to_return
11
- @start_point = start_point == :current_record ? 'UC' : 'EG'
11
+ @start_point = start_point == :current_record ? 'UC' : 'EG'
12
12
  @max_reject_count=max_reject_count
13
13
  end
14
-
14
+
15
15
  def get_encoded_buffer
16
16
  filter_buff = []
17
17
  @filter.each_with_index() do |token, i|
@@ -26,13 +26,11 @@ class BtrieveSearchBuffer
26
26
  right_operand=[@table.schema[:columns][token[2]][:offset]].pack('S')
27
27
  else
28
28
  # We're comparing against a constant in the exact same format as the column itself
29
- right_operand=@table.pack_value(column, token[2])
29
+ right_operand=@table.pack_value(column, token[2])
30
30
  right_operand=right_operand.gsub("\x00",' ') if [0,11,12,21].include?(column[:datatype])
31
- end
32
- #filter_buff << "DATATYPE=#{column[:datatype]} SIZE=#{column[:size]} OFFSET=#{column[:offset]} COMPARISON=#{comparison} OPERAND=#{right_operand}"
31
+ end
33
32
  filter_item = [column[:datatype], column[:size], column[:offset], comparison, 0].pack('CSSCC')
34
33
  filter_item << right_operand
35
- #p filter_item
36
34
  filter_buff << filter_item
37
35
  else
38
36
  boolean = BOOLEAN[token]
@@ -40,31 +38,22 @@ class BtrieveSearchBuffer
40
38
  end
41
39
  end
42
40
  num_logical_expressions = filter_buff.size
43
- #p "num_logical_expressions = #{num_logical_expressions}"
44
- #p filter_buff
45
41
  result_descriptor=[@records_to_fetch, @fields_to_return.size].pack('SS')
46
- #p "result_descriptor before = #{result_descriptor}"
47
42
  @fields_to_return.inject(result_descriptor) do |desc, field|
48
43
  column = @table.schema[:columns][field]
49
- #p "#{field} => column[:size], column[:offset] = #{column[:size]}, #{column[:offset]}"
50
44
  desc << [column[:size], column[:offset]].pack('SS')
51
45
  desc
52
46
  end
53
- #p "result_descriptor after = #{result_descriptor}"
54
47
  buffer_size=8+result_descriptor.size+filter_buff.join('').size
55
- #p "buffer_size=#{buffer_size}"
56
48
  search_buffer=[buffer_size, @start_point, @max_reject_count, num_logical_expressions].pack('Sa2SS')
57
- #p "search_buffer.size=#{search_buffer.size}"
58
49
  search_buffer << filter_buff.join('') << result_descriptor
59
- #p "search_buffer.size=#{search_buffer.size}"
60
- #p "buffer_size - search_buffer.size=#{buffer_size - search_buffer.size}"
61
50
  search_buffer
62
51
  end
63
-
52
+
64
53
  private
65
-
54
+
66
55
  def is_symbol?(arg)
67
56
  arg.object_id == arg.to_sym.object_id rescue false
68
57
  end
69
-
70
58
  end
59
+
@@ -6,7 +6,7 @@ class BtrieveRecord
6
6
  attr_reader :data_buffer, :btrieve_table
7
7
  attr_accessor :position
8
8
 
9
- # Initializes a btrieve record.
9
+ # Initializes a btrieve record.
10
10
  def initialize(btrieve_table, data_buffer=nil)
11
11
  @btrieve_table = btrieve_table
12
12
  @data_buffer = data_buffer.nil? ? Btrieve.create_string_buffer(@btrieve_table.schema[:record_size]) : data_buffer
@@ -23,28 +23,28 @@ class BtrieveRecord
23
23
  def update
24
24
  new_state="#{@data_buffer}"
25
25
  @data_buffer[0..3]=@position
26
- btr_op(GET_DIRECT, @btrieve_table.pos_buffer, @data_buffer, NULL_BUFFER, SYSTEM_LOG_KEY)
26
+ btr_op(GET_DIRECT, @btrieve_table.pos_buffer, @data_buffer, NULL_BUFFER, SYSTEM_LOG_KEY)
27
27
  btr_op(UPDATE, @btrieve_table.pos_buffer, new_state, NULL_BUFFER, SYSTEM_LOG_KEY)
28
28
  set_physical_position
29
29
  end
30
-
30
+
31
31
  # Deletes an existing btrieve record through the transactional BTR engine.
32
32
  def delete
33
33
  @data_buffer[0..3]=@position
34
- btr_op(GET_DIRECT, @btrieve_table.pos_buffer, @data_buffer, NULL_BUFFER, SYSTEM_LOG_KEY)
34
+ btr_op(GET_DIRECT, @btrieve_table.pos_buffer, @data_buffer, NULL_BUFFER, SYSTEM_LOG_KEY)
35
35
  btr_op(DELETE, @btrieve_table.pos_buffer, NULL_BUFFER, NULL_BUFFER, NULL_KEY)
36
36
  reset_physical_position
37
37
  end
38
38
 
39
- # Returns hash of column-value pairs for this btrieve record, given an array of named columns.
40
- # If the array is nil, the hash will contain ALL the column-value pairs defined by the schema.
39
+ # Returns hash of column-value pairs for this btrieve record, given an array of named columns.
40
+ # If the array is nil, the hash will contain ALL the column-value pairs defined by the schema.
41
41
  def values(column_names=nil)
42
42
  if(column_names.nil?)
43
43
  column_names=@btrieve_table.schema[:columns].keys.sort.inject([]){|array,column|array<< column;array}
44
- end
44
+ end
45
45
  column_names.inject({}){|vals, key| vals[key]=self[key]; vals}
46
46
  end
47
-
47
+
48
48
  # Sets the column valuesof this record based on the values passed through the 'column_values' map.
49
49
  def values=(column_values)
50
50
  column_values.each{ |key, value| self[key]=value }
@@ -54,16 +54,16 @@ class BtrieveRecord
54
54
  def primary_key()
55
55
  values(@btrieve_table.primary_key)
56
56
  end
57
-
58
- # Returns this record's value of the column passed in.
57
+
58
+ # Returns this record's value of the column passed in.
59
59
  def [](key_name)
60
60
  column = @btrieve_table.schema[:columns][key_name]
61
61
  return nil if(column.nil?)
62
- val = @data_buffer.unpack(column[:unpacker])[0]
62
+ val = @data_buffer.unpack(column[:unpacker])[0]
63
63
  val = val.strip if val.respond_to?('strip')
64
64
  val
65
65
  end
66
-
66
+
67
67
  # Sets this record's value for a particular column.
68
68
  def []=(key_name, value)
69
69
  column = @btrieve_table.schema[:columns][key_name]
@@ -72,32 +72,33 @@ class BtrieveRecord
72
72
  range = (offset..offset+packed_value.size-1)
73
73
  @data_buffer[range] = packed_value
74
74
  end
75
-
75
+
76
76
  # Determines if a record is nil.
77
77
  def nil?()
78
78
  @data_buffer.gsub("\x00", "").size==0
79
79
  end
80
-
80
+
81
81
  # Returns a string representation of this record.
82
82
  def to_s()
83
83
  @btrieve_table.schema[:columns].keys.inject("[position=>'#{position.unpack('i')[0]}'"){|pretty_print, key| pretty_print << ", #{key}=>'#{self[key]}'"; pretty_print } << "]"
84
84
  end
85
85
 
86
- # Returns this record's version as a MD5 Digest value.
86
+ # Returns this record's version as a MD5 Digest value.
87
87
  def version()
88
88
  Digest::MD5.hexdigest(@data_buffer)
89
89
  end
90
-
90
+
91
91
  # TODO - documentation
92
92
  def set_physical_position
93
93
  reset_physical_position
94
94
  btr_op(GET_POSITION, @btrieve_table.pos_buffer, @position, NULL_BUFFER, NULL_KEY)
95
95
  self
96
96
  end
97
-
97
+
98
98
  # TODO - documentation
99
99
  def reset_physical_position
100
100
  @position = Btrieve.create_string_buffer(RECORD_POSITION_SIZE)
101
101
  end
102
102
 
103
103
  end
104
+
@@ -24,13 +24,13 @@ class BtrieveTable
24
24
  close()
25
25
  end
26
26
  end
27
-
27
+
28
28
  # Finds an array of records in this table, using the specified index number and match hash.
29
29
  # If a block is passed in, the entries of this set are passed into this block one by one. Otherwise,
30
- # the set is returned to the caller.
30
+ # the set is returned to the caller.
31
31
  def find(match, index_number, &block)
32
32
  allows_duplicates=schema[:index_flags].map{|f|f&1==1;}[index_number]
33
- set=nil
33
+ set=nil
34
34
  if(allows_duplicates)
35
35
  set=find_in_index(match, index_number)
36
36
  else
@@ -46,8 +46,8 @@ class BtrieveTable
46
46
 
47
47
  # Finds an array of records in this table, using the specified index number, a key and a range of values.
48
48
  # If a block is passed in, the entries of this set are passed into this block one by one. Otherwise,
49
- # the set is returned to the caller.
50
- # WARNING - NO UNIT TEST EXIST YET!
49
+ # the set is returned to the caller.
50
+ # WARNING - NO UNIT TEST EXIST YET!
51
51
  # CONSIDER - Deprecation coming soon... Should use the 'find_extended' method instead.
52
52
  def find_in_range(index_num, key, range, &block)
53
53
  index = @schema[:indices][index_num]
@@ -55,8 +55,8 @@ class BtrieveTable
55
55
  index_values = index.inject([]){|vals,akey|vals << (akey == key ? range.first : nil); vals}
56
56
  key_packer = index.inject("") do |packer, akey|
57
57
  value_packer = BtrieveSchema.lookup(columns[akey][:datatype], columns[akey][:size])[:unpacker]
58
- nil_packer = 'x'*columns[key][:size]
59
- packer << (akey == key ? value_packer : nil_packer)
58
+ nil_packer = 'x'*columns[key][:size]
59
+ packer << (akey == key ? value_packer : nil_packer)
60
60
  packer
61
61
  end
62
62
  key_buffer = index_values.pack(key_packer)
@@ -65,7 +65,7 @@ class BtrieveTable
65
65
  batch do
66
66
  btr_op(GET_GREATER_THAN_OR_EQUAL, @pos_buffer, btr_record.data_buffer, key_buffer, index_num, [OK, EOF])
67
67
  while(range.include?(btr_record[key]))
68
- if(!block.nil?)
68
+ if(!block.nil?)
69
69
  yield btr_record
70
70
  else
71
71
  records << btr_record
@@ -74,12 +74,12 @@ class BtrieveTable
74
74
  btr_op(GET_NEXT, @pos_buffer, btr_record.data_buffer, key_buffer, index_num, [OK, EOF])
75
75
  end
76
76
  end
77
- if(block.nil?)
77
+ if(block.nil?)
78
78
  records
79
79
  end
80
80
  end
81
81
 
82
- # Closes this btrieve table to conclude a sequence of BTR operation(s).
82
+ # Closes this btrieve table to conclude a sequence of BTR operation(s).
83
83
  def close
84
84
  btr_op(CLOSE, @pos_buffer, NULL_BUFFER, NULL_BUFFER, NULL_KEY)
85
85
  @pos_buffer=Btrieve.create_string_buffer(POS_BLOCK_SIZE)
@@ -102,11 +102,11 @@ class BtrieveTable
102
102
  close
103
103
  end
104
104
 
105
- # Returns this table's version as a MD5 Digest value.
105
+ # Returns this table's version as a MD5 Digest value.
106
106
  def version()
107
107
  Digest::MD5.hexdigest(BtrieveSchema.sort(schema[:columns]).inject([]){|array,column|array << BtrieveSchema.readable_type(column);array}.to_s)
108
108
  end
109
-
109
+
110
110
  # Packs a value according to the metadata of a particular column.
111
111
  def pack_value(column, value)
112
112
  packer_string = column[:unpacker]
@@ -117,10 +117,10 @@ class BtrieveTable
117
117
  array = [value]
118
118
  array.pack(packer)
119
119
  end
120
-
120
+
121
121
  # Returns an array of hashes that match the criteria defined by the filter parameter.
122
122
  # An example of the filter parameter is given below -
123
- #
123
+ #
124
124
  # filter = [[:dept_name, :equal, 'Philosophy'], :and, [:name, :not_equal, 'PHI 101'], :and, [:name, :not_equal, :dept_name]]
125
125
  #
126
126
  # The following COMPARISON operators are supported in the logical comparison clauses -
@@ -143,7 +143,7 @@ class BtrieveTable
143
143
  start_point = :next_record
144
144
  searcher = BtrieveSearchBuffer.new(self, filter, fields_to_return, records_to_fetch, max_reject_count, max_reject_count)
145
145
  search_buffer = searcher.get_encoded_buffer
146
- buff_diff = records_buffer - search_buffer.size
146
+ buff_diff = records_buffer - search_buffer.size
147
147
  search_buffer << Btrieve.create_string_buffer(buff_diff) if(buff_diff > 0)
148
148
  tmp_buff = Btrieve.create_string_buffer(record_size)
149
149
  key_buff = Btrieve.create_string_buffer(record_size)
@@ -157,7 +157,7 @@ class BtrieveTable
157
157
  record_position = search_buffer.unpack("@#{2+record_byte_pointer}i")[0]
158
158
  record=search_buffer.unpack("@#{6+record_byte_pointer}a#{record_length}")[0]
159
159
  record_byte_pointer += 6+record_length
160
- unpacker = fields_to_return.inject(["", 0]) do |arr, c|
160
+ unpacker = fields_to_return.inject(["", 0]) do |arr, c|
161
161
  column = @schema[:columns][c]
162
162
  str = BtrieveSchema.unpacker(arr[1], column[:datatype], column[:size])
163
163
  arr[0] << str
@@ -167,16 +167,16 @@ class BtrieveTable
167
167
  fields = record.unpack(unpacker[0])
168
168
  records << {:position=>record_position, :values=>Hash[*fields_to_return.zip(fields).flatten]}
169
169
  end
170
- records
170
+ records
171
171
  end
172
-
172
+
173
173
  private
174
174
 
175
175
  def step_next
176
176
  btr_record = BtrieveRecord.new(self)
177
177
  result = btr_op(STEP_NEXT, @pos_buffer, btr_record.data_buffer, NULL_BUFFER, NULL_KEY, [OK, EOF])
178
178
  return false if(result == EOF)
179
- btr_record
179
+ btr_record.set_physical_position
180
180
  end
181
181
 
182
182
  def find_matching_index(match)
@@ -186,18 +186,18 @@ class BtrieveTable
186
186
  raise Exception.new("No matching index for #{keys}")
187
187
  end
188
188
 
189
- INTEGER_TYPES=['TINYINT','SMALLINT','INTEGER','BIT','UTINYINT','USMALLINT','UINTEGER','UBIGINT']
189
+ INTEGER_TYPES=['TINYINT','SMALLINT','INTEGER','BIT','UTINYINT','USMALLINT','UINTEGER','UBIGINT']
190
190
  FLOAT_TYPES=['REAL','DOUBLE']
191
191
  def finder(match, index_number = nil, &block)
192
192
  index_number ||= find_matching_index(match)
193
193
  index = @schema[:indices][index_number]
194
194
  columns = @schema[:columns]
195
- key_components = index.inject([]) do |vals, key|
196
- datatype = BtrieveSchema.lookup(columns[key][:datatype], columns[key][:size])[:name]
195
+ key_components = index.inject([]) do |vals, key|
196
+ datatype = BtrieveSchema.lookup(columns[key][:datatype], columns[key][:size])[:name]
197
197
  value = match[key]
198
198
  value = value.to_f if FLOAT_TYPES.include?(datatype)
199
199
  value = value.to_i if INTEGER_TYPES.include?(datatype)
200
- value = value.ljust(columns[key][:size], ' ') if datatype=='CHAR'
200
+ value = value.ljust(columns[key][:size], ' ') if datatype=='CHAR'
201
201
  vals << value
202
202
  vals
203
203
  end
@@ -229,12 +229,12 @@ class BtrieveTable
229
229
  finder(match, index_number) do |org_key_buffer, index|
230
230
  absolute_match = match.keys.inject({}){|vals, key| vals[key] = match[key] if(match[key] != nil); vals}
231
231
  absolute_match_keys = absolute_match.keys
232
- result = []
232
+ result = []
233
233
  batch do
234
234
  key_buffer="#{org_key_buffer}"
235
235
  ops_result = btr_op(GET_EQUAL_KEY, @pos_buffer, NULL_BUFFER, key_buffer, index, [OK, EOF, KEY_NOT_FOUND])
236
236
  ops=GET_EQUAL
237
- while(ops_result == OK)
237
+ while(ops_result == OK)
238
238
  btr_record = BtrieveRecord.new(self)
239
239
  ops_result = btr_op(ops, @pos_buffer, btr_record.data_buffer, key_buffer, index, [OK, EOF])
240
240
  break if(key_buffer!=org_key_buffer)
@@ -244,13 +244,13 @@ class BtrieveTable
244
244
  end
245
245
  result
246
246
  end
247
- end
248
-
247
+ end
248
+
249
249
  def session
250
250
  s=BtrieveSession.get_session
251
251
  raise "Cannot manipulate a BtrieveTable when no BtrieveSession exists." if s.nil?
252
252
  s
253
253
  end
254
-
254
+
255
255
  end
256
256
 
@@ -5,27 +5,27 @@ class TestBeezwax < Test::Unit::TestCase
5
5
  setup do
6
6
  BtrieveSession.create_session(PSQL_DB)
7
7
  end
8
-
8
+
9
9
  teardown do
10
10
  BtrieveSession.destroy_session
11
11
  end
12
-
12
+
13
13
  should "not allow the creation of another session" do
14
14
  assert_raise(RuntimeError){BtrieveSession.create_session(PSQL_DB)}
15
15
  end
16
-
16
+
17
17
  should "return a handle to the session singleton" do
18
18
  session=nil
19
19
  assert_nothing_raised{session=BtrieveSession.get_session}
20
- assert_not_nil session
20
+ assert_not_nil session
21
21
  end
22
-
22
+
23
23
  should "permit the instanciation of a DB table" do
24
24
  table=nil
25
25
  assert_nothing_raised{table=BtrieveTable.new(:course)}
26
26
  assert_not_nil table
27
27
  end
28
-
28
+
29
29
  should "permit the instanciation of multiple instances for the same DB table" do
30
30
  table0 = table1 = nil
31
31
  assert_nothing_raised do
@@ -35,18 +35,18 @@ class TestBeezwax < Test::Unit::TestCase
35
35
  assert_not_nil table0
36
36
  assert_not_nil table1
37
37
  end
38
-
38
+
39
39
  should "allow an empty transaction to go through" do
40
40
  assert_nothing_raised{BtrieveSession.transaction{}}
41
41
  end
42
-
42
+
43
43
  should "allow an empty transaction to go through, with explicit boundaries" do
44
44
  assert_nothing_raised do
45
45
  BtrieveSession.begin_transaction
46
46
  BtrieveSession.end_transaction
47
47
  end
48
48
  end
49
-
49
+
50
50
  should "allow a transaction to be aborted" do
51
51
  assert_nothing_raised do
52
52
  BtrieveSession.begin_transaction
@@ -54,44 +54,55 @@ class TestBeezwax < Test::Unit::TestCase
54
54
  end
55
55
  assert_raise(RuntimeError){BtrieveSession.end_transaction}
56
56
  end
57
-
57
+
58
58
  context "and an instance of BtrieveTable is created, it" do
59
59
  setup do
60
60
  @table=BtrieveTable.new(:course)
61
61
  @table.primary_key = [:name]
62
62
  end
63
-
63
+
64
64
  teardown do
65
65
  @table=nil
66
66
  end
67
-
67
+
68
68
  should "be possible to open it for operations, then close it" do
69
69
  assert_nothing_raised{ @table.open }
70
70
  assert_nothing_raised{ @table.close }
71
71
  end
72
-
72
+
73
73
  should "be possible to have the file automatically closed when a block is passed when opening a table" do
74
74
  assert_nothing_raised{ @table.open{} }
75
75
  assert_raise(RuntimeError){ @table.close }
76
76
  end
77
-
77
+
78
78
  should "return a version number for that table" do
79
79
  table_version=nil
80
80
  assert_nothing_raised{ table_version=@table.version }
81
81
  assert_not_nil table_version
82
82
  assert_equal 32, table_version.size
83
- end
84
-
83
+ end
84
+
85
85
  should "allow looping over each of its records to count them" do
86
86
  counter = 0
87
87
  assert_nothing_raised{@table.each_record{|record|counter+=1}}
88
88
  assert_equal 145, counter
89
89
  end
90
-
90
+
91
+ should "allow looping over each of its records to updated them" do
92
+ BtrieveSession.begin_transaction
93
+ i=0
94
+ @table.each_record do |record|
95
+ record[:description]="#{record[:description]} #{i}"
96
+ i += 1
97
+ record.update
98
+ end
99
+ BtrieveSession.abort_transaction
100
+ end
101
+
91
102
  should "be possible to search the table for a given index" do
92
103
  assert_nothing_raised {@table.find({:name=>'blah'}, 0)}
93
104
  end
94
-
105
+
95
106
  should "be possible to find a particular record in a unique index" do
96
107
  name = 'PHI 101'
97
108
  record = nil
@@ -99,10 +110,10 @@ class TestBeezwax < Test::Unit::TestCase
99
110
  assert_nothing_raised{record=@table.find({:name=>name}, 0).first}
100
111
  assert_not_nil record
101
112
  assert_nothing_raised{record_name=record[:name]}
102
- assert_not_nil record_name
113
+ assert_not_nil record_name
103
114
  assert_equal record_name, name
104
115
  end
105
-
116
+
106
117
  should "be possible to search for a unique key that doesn't exist and not cause an exception" do
107
118
  name = 'FRA 333'
108
119
  records=@table.find({:name=>name}, 0)
@@ -118,31 +129,31 @@ class TestBeezwax < Test::Unit::TestCase
118
129
  assert_equal 9, records.size
119
130
  assert records.inject(true){|test, record| test |= record[:dept_name]==dept_name; test}
120
131
  end
121
-
132
+
122
133
  should "support finding records and looping over them if a block is passed in" do
123
134
  dept_name = 'Mathematics'
124
- counter = 0
135
+ counter = 0
125
136
  assert_nothing_raised{@table.find({:dept_name=>dept_name}, 1){counter += 1}}
126
137
  assert_equal 9, counter
127
138
  end
128
-
139
+
129
140
  should "be possible to search for a key that doesn't exit and not cause an exception" do
130
141
  dept_name = 'Francais'
131
142
  records=@table.find({:dept_name=>dept_name}, 1)
132
143
  assert_not_nil records
133
144
  assert records.empty?, "records is NOT empty"
134
145
  end
135
-
146
+
136
147
  context "and an instance of BtrieveRecord is fetched, it" do
137
148
  setup do
138
149
  @name = 'PHI 101'
139
150
  @record=@table.find({:name=>@name}, 0).first
140
151
  end
141
-
152
+
142
153
  teardown do
143
154
  @record=nil
144
155
  end
145
-
156
+
146
157
  should "be possible to get the record's primary key" do
147
158
  expected_value = {:name=>@name}
148
159
  pk = nil
@@ -150,7 +161,7 @@ class TestBeezwax < Test::Unit::TestCase
150
161
  assert_not_nil pk
151
162
  assert_equal expected_value, pk
152
163
  end
153
-
164
+
154
165
  should "be possible retrieve all its columns" do
155
166
  expected_values={:name=>@name, :description=>'Introduction to Ethics', :credit_hours=>3, :dept_name=>'Philosophy'}
156
167
  values = nil
@@ -158,7 +169,7 @@ class TestBeezwax < Test::Unit::TestCase
158
169
  assert_not_nil values
159
170
  assert_equal expected_values, values
160
171
  end
161
-
172
+
162
173
  should "be possible retrieve a subset of its columns" do
163
174
  expected_values={:description=>'Introduction to Ethics', :credit_hours=>3}
164
175
  values = nil
@@ -167,13 +178,13 @@ class TestBeezwax < Test::Unit::TestCase
167
178
  assert_equal expected_values, values
168
179
  end
169
180
  end
170
-
181
+
171
182
  context "for a BtrieveRecord to be created, it" do
172
183
  setup do
173
184
  @values={:name=>'FRA 303', :description=>'Francais Avance', :credit_hours=>3, :dept_name=>"Latin".force_encoding("ASCII-8BIT")}
174
185
  @rb_values={:name=>'FRE 303', :description=>'Frenceis Evence', :credit_hours=>3, :dept_name=>'Latin'}
175
186
  end
176
-
187
+
177
188
  teardown do
178
189
  # meh
179
190
  end
@@ -234,7 +245,7 @@ class TestBeezwax < Test::Unit::TestCase
234
245
  assert str.size > 0
235
246
  end
236
247
  end
237
- end
248
+ end
238
249
  assert_nothing_raised{ new_record = @table.find({:name=>'FRA 303'}, 0).first }
239
250
  assert_not_nil new_record
240
251
  assert_nothing_raised { new_values = new_record.values }
@@ -250,20 +261,20 @@ class TestBeezwax < Test::Unit::TestCase
250
261
  assert_nil new_record
251
262
  end
252
263
  end
253
- end
264
+ end
254
265
  end
255
-
266
+
256
267
  context "A destroyed BtrieveSession" do
257
268
  setup do
258
269
  BtrieveSession.create_session(PSQL_DB)
259
270
  @table = BtrieveTable.new(:course)
260
271
  BtrieveSession.destroy_session
261
272
  end
262
-
273
+
263
274
  should "not allow the instanciation of a DB table" do
264
275
  assert_raise(RuntimeError){BtrieveTable.new(:course)}
265
276
  end
266
-
277
+
267
278
  should "not allow exsting tables to search against the DB" do
268
279
  records=nil
269
280
  assert_raise(RuntimeError){records=@table.find({:dept_name=>'Mathematics'}, 1)}
@@ -271,3 +282,4 @@ class TestBeezwax < Test::Unit::TestCase
271
282
  end
272
283
  end
273
284
  end
285
+
@@ -18,3 +18,4 @@ class Test::Unit::TestCase
18
18
  end
19
19
  end
20
20
  end
21
+
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 7
8
- - 0
9
- version: 0.7.0
8
+ - 1
9
+ version: 0.7.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - Patrick Lardin
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-12-22 00:00:00 -08:00
17
+ date: 2011-03-19 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency