arrayfields 3.6.0 → 3.7.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,16 @@
1
+ require 'arrayfields'
2
+ #
3
+ # the struct/fields factory method can be used in much the same way as ruby's
4
+ # own struct generators and is useful when the fields for a set of arrays is
5
+ # known apriori
6
+ #
7
+ c = Array.fields :a, :b, :c # same as Array.struct
8
+ a = c.new [42, nil, nil]
9
+ a[:c] = 42
10
+ p a #=> [42, nil, 42]
11
+ #
12
+ # of course we can append too
13
+ #
14
+ a[:d] = 42.0
15
+ p a[:d] #=> 42.0
16
+ p a #=> [42, nil, 42, 42.0]
@@ -6,87 +6,87 @@ $:.unshift '.'
6
6
  require 'arrayfields'
7
7
 
8
8
  class ArrayFieldsTest < Test::Unit::TestCase
9
- #{{{
9
+ #--{{{
10
10
  def setup
11
- #{{{
11
+ #--{{{
12
12
  @fields = %w(zero one two)
13
13
  @str_fields = %w(zero one two)
14
14
  @sym_fields = [:zero, :one, :two]
15
15
  @a = [0,1,2]
16
- #}}}
16
+ #--}}}
17
17
  end
18
18
  #
19
19
  # setting fields correctly
20
20
  #
21
21
  def test_00
22
- #{{{
22
+ #--{{{
23
23
  assert_nothing_raised do
24
24
  @a.fields = @str_fields
25
25
  end
26
26
  assert_equal @a.fields, @str_fields
27
- #}}}
27
+ #--}}}
28
28
  end
29
29
  def test_01
30
- #{{{
30
+ #--{{{
31
31
  assert_nothing_raised do
32
32
  @a.fields = @sym_fields
33
33
  end
34
34
  assert_equal @a.fields, @sym_fields
35
- #}}}
35
+ #--}}}
36
36
  end
37
37
  def test_02
38
- #{{{
38
+ #--{{{
39
39
  assert_nothing_raised do
40
40
  a = ArrayFields::FieldSet.new @str_fields
41
41
  b = ArrayFields::FieldSet.new @str_fields
42
42
  assert_equal a, b
43
- assert_equal a.id, b.id
43
+ assert_equal a.object_id, b.object_id
44
44
  end
45
- #}}}
45
+ #--}}}
46
46
  end
47
47
  def test_03
48
- #{{{
48
+ #--{{{
49
49
  assert_nothing_raised do
50
50
  a = ArrayFields::FieldSet.new @sym_fields
51
51
  b = ArrayFields::FieldSet.new @sym_fields
52
52
  c = ArrayFields::FieldSet.new @str_fields
53
53
  d = ArrayFields::FieldSet.new @str_fields
54
54
  assert_equal a, b
55
- assert_equal a.id, b.id
55
+ assert_equal a.object_id, b.object_id
56
56
  assert_not_equal a, c
57
- assert_not_equal a.id, c.id
57
+ assert_not_equal a.object_id, c.object_id
58
58
  end
59
- #}}}
59
+ #--}}}
60
60
  end
61
61
  #
62
62
  # setting fields incorrectly
63
63
  #
64
64
  def test_10
65
- #{{{
65
+ #--{{{
66
66
  assert_raises(ArgumentError) do
67
67
  @a.fields = nil
68
68
  end
69
- #}}}
69
+ #--}}}
70
70
  end
71
71
  def test_11
72
- #{{{
72
+ #--{{{
73
73
  assert_raises(ArgumentError) do
74
74
  @a.fields = []
75
75
  end
76
- #}}}
76
+ #--}}}
77
77
  end
78
78
  def test_11
79
- #{{{
79
+ #--{{{
80
80
  assert_raises(ArgumentError) do
81
81
  @a.fields = [Hash.new]
82
82
  end
83
- #}}}
83
+ #--}}}
84
84
  end
85
85
  #
86
86
  # []
87
87
  #
88
88
  def test_20
89
- #{{{
89
+ #--{{{
90
90
  a, b, c = @a[0], @a[1,1].first, @a[2..2].first
91
91
  assert_nothing_raised do
92
92
  @a.fields = @str_fields
@@ -100,10 +100,10 @@ class ArrayFieldsTest < Test::Unit::TestCase
100
100
  assert_nothing_raised do
101
101
  assert_equal c, @a['two']
102
102
  end
103
- #}}}
103
+ #--}}}
104
104
  end
105
105
  def test_21
106
- #{{{
106
+ #--{{{
107
107
  a = @a[0,@a.size]
108
108
  assert_nothing_raised do
109
109
  @a.fields = @str_fields
@@ -111,13 +111,13 @@ class ArrayFieldsTest < Test::Unit::TestCase
111
111
  assert_nothing_raised do
112
112
  assert_equal a, @a['zero', @a.size]
113
113
  end
114
- #}}}
114
+ #--}}}
115
115
  end
116
116
  #
117
117
  # []=
118
118
  #
119
119
  def test_30
120
- #{{{
120
+ #--{{{
121
121
  assert_nothing_raised do
122
122
  @a.fields = @str_fields
123
123
  end
@@ -127,10 +127,10 @@ class ArrayFieldsTest < Test::Unit::TestCase
127
127
  assert_equal value, @a['zero']
128
128
  assert_equal @a[0], @a['zero']
129
129
  end
130
- #}}}
130
+ #--}}}
131
131
  end
132
132
  def test_31
133
- #{{{
133
+ #--{{{
134
134
  assert_nothing_raised do
135
135
  @a.fields = @str_fields
136
136
  end
@@ -140,10 +140,10 @@ class ArrayFieldsTest < Test::Unit::TestCase
140
140
  assert_equal value, @a['zero']
141
141
  assert_equal @a[0,1], @a['zero',1]
142
142
  end
143
- #}}}
143
+ #--}}}
144
144
  end
145
145
  def test_32
146
- #{{{
146
+ #--{{{
147
147
  assert_nothing_raised do
148
148
  @a.fields = @str_fields
149
149
  end
@@ -153,10 +153,10 @@ class ArrayFieldsTest < Test::Unit::TestCase
153
153
  assert_equal value, @a['zero']
154
154
  assert_equal @a[0,1], @a['zero',1]
155
155
  end
156
- #}}}
156
+ #--}}}
157
157
  end
158
158
  def test_33
159
- #{{{
159
+ #--{{{
160
160
  assert_nothing_raised do
161
161
  @a.fields = @str_fields
162
162
  end
@@ -164,10 +164,10 @@ class ArrayFieldsTest < Test::Unit::TestCase
164
164
  @a['zero', @a.size] = nil
165
165
  assert_equal @a, []
166
166
  end
167
- #}}}
167
+ #--}}}
168
168
  end
169
169
  def test_34
170
- #{{{
170
+ #--{{{
171
171
  assert_nothing_raised do
172
172
  @a.fields = @str_fields
173
173
  end
@@ -176,10 +176,10 @@ class ArrayFieldsTest < Test::Unit::TestCase
176
176
  assert_equal 3, @a['three']
177
177
  assert_equal 3, @a[3]
178
178
  end
179
- #}}}
179
+ #--}}}
180
180
  end
181
181
  def test_35
182
- #{{{
182
+ #--{{{
183
183
  assert_nothing_raised do
184
184
  @a.fields = @str_fields
185
185
  @a['three'] = 3
@@ -190,22 +190,22 @@ class ArrayFieldsTest < Test::Unit::TestCase
190
190
  @a.each_with_field{|e,f| actual << [e,f]}
191
191
  end
192
192
  assert_equal exp, actual
193
- #}}}
193
+ #--}}}
194
194
  end
195
195
  def test_36
196
- #{{{
196
+ #--{{{
197
197
  assert_nothing_raised do
198
198
  @a.fields = @str_fields
199
199
  @a['three'] = 3
200
200
  end
201
201
  assert_equal %w(zero one two three), @a.fields
202
- #}}}
202
+ #--}}}
203
203
  end
204
204
  #
205
205
  # at
206
206
  #
207
207
  def test_40
208
- #{{{
208
+ #--{{{
209
209
  assert_nothing_raised do
210
210
  @a.fields = @str_fields
211
211
  end
@@ -216,13 +216,13 @@ class ArrayFieldsTest < Test::Unit::TestCase
216
216
  end
217
217
  assert_equal ret, i
218
218
  end
219
- #}}}
219
+ #--}}}
220
220
  end
221
221
  #
222
222
  # delete_at
223
223
  #
224
224
  def test_50
225
- #{{{
225
+ #--{{{
226
226
  assert_nothing_raised do
227
227
  @a.fields = @str_fields
228
228
  end
@@ -234,13 +234,13 @@ class ArrayFieldsTest < Test::Unit::TestCase
234
234
  value = @a.delete_at 'three'
235
235
  assert_equal nil, value
236
236
  end
237
- #}}}
237
+ #--}}}
238
238
  end
239
239
  #
240
240
  # fill
241
241
  #
242
242
  def test_60
243
- #{{{
243
+ #--{{{
244
244
  assert_nothing_raised do
245
245
  @a.fields = @str_fields
246
246
  end
@@ -248,10 +248,10 @@ class ArrayFieldsTest < Test::Unit::TestCase
248
248
  @a.fill 42, 'zero', 1
249
249
  assert_equal 42, @a[0]
250
250
  end
251
- #}}}
251
+ #--}}}
252
252
  end
253
253
  def test_61
254
- #{{{
254
+ #--{{{
255
255
  assert_nothing_raised do
256
256
  @a.fields = @str_fields
257
257
  end
@@ -259,10 +259,10 @@ class ArrayFieldsTest < Test::Unit::TestCase
259
259
  @a.fill 42
260
260
  assert_equal 42, @a[-1]
261
261
  end
262
- #}}}
262
+ #--}}}
263
263
  end
264
264
  def test_62
265
- #{{{
265
+ #--{{{
266
266
  assert_nothing_raised do
267
267
  @a.fields = @str_fields
268
268
  end
@@ -270,13 +270,13 @@ class ArrayFieldsTest < Test::Unit::TestCase
270
270
  @a.fill 42, 0...@a.size
271
271
  assert_equal(Array.new(@a.size, 42), @a)
272
272
  end
273
- #}}}
273
+ #--}}}
274
274
  end
275
275
  #
276
276
  # slice
277
277
  #
278
278
  def test_70
279
- #{{{
279
+ #--{{{
280
280
  a, b, c = @a[0], @a[1,1].first, @a[2..2].first
281
281
  assert_nothing_raised do
282
282
  @a.fields = @str_fields
@@ -290,13 +290,13 @@ class ArrayFieldsTest < Test::Unit::TestCase
290
290
  assert_nothing_raised do
291
291
  assert_equal c, @a.slice('two')
292
292
  end
293
- #}}}
293
+ #--}}}
294
294
  end
295
295
  #
296
296
  # slice!
297
297
  #
298
298
  def test_80
299
- #{{{
299
+ #--{{{
300
300
  assert_nothing_raised do
301
301
  @a.fields = @str_fields
302
302
  end
@@ -304,10 +304,10 @@ class ArrayFieldsTest < Test::Unit::TestCase
304
304
  @a.slice! 'zero', @a.size
305
305
  assert_equal @a, []
306
306
  end
307
- #}}}
307
+ #--}}}
308
308
  end
309
309
  def test_81
310
- #{{{
310
+ #--{{{
311
311
  assert_nothing_raised do
312
312
  @a.fields = @str_fields
313
313
  end
@@ -315,9 +315,9 @@ class ArrayFieldsTest < Test::Unit::TestCase
315
315
  @a.slice! 0, @a.size
316
316
  assert_equal @a, []
317
317
  end
318
- #}}}
318
+ #--}}}
319
319
  end
320
320
  if false
321
321
  end
322
- #}}}
322
+ #--}}}
323
323
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
2
+ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: arrayfields
5
5
  version: !ruby/object:Gem::Version
6
- version: 3.6.0
7
- date: 2006-08-23 00:00:00.000000 -06:00
6
+ version: 3.7.0
7
+ date: 2007-04-03 00:00:00 -06:00
8
8
  summary: arrayfields
9
9
  require_paths:
10
- - lib
10
+ - lib
11
11
  email: ara.t.howard@noaa.gov
12
12
  homepage: http://codeforpeople.com/lib/ruby/arrayfields/
13
13
  rubyforge_project:
@@ -18,34 +18,42 @@ bindir: bin
18
18
  has_rdoc: false
19
19
  required_ruby_version: !ruby/object:Gem::Version::Requirement
20
20
  requirements:
21
- -
22
- - ">"
23
- - !ruby/object:Gem::Version
24
- version: 0.0.0
21
+ - - ">"
22
+ - !ruby/object:Gem::Version
23
+ version: 0.0.0
25
24
  version:
26
25
  platform: ruby
27
26
  signing_key:
28
27
  cert_chain:
28
+ post_install_message:
29
29
  authors:
30
- - Ara T. Howard
30
+ - Ara T. Howard
31
31
  files:
32
- - install.rb
33
- - README
34
- - VERSION
35
- - gemspec.rb
36
- - lib
37
- - test
38
- - sample
39
- - lib/arrayfields.rb
40
- - lib/arrayfields-3.6.0.rb
41
- - test/arrayfields.rb
42
- - test/memtest.rb
43
- - sample/a.rb
32
+ - install.rb
33
+ - gen_readme.rb
34
+ - gemspec.rb
35
+ - README.tmpl
36
+ - lib
37
+ - lib/arrayfields.rb
38
+ - lib/arrayfields-3.7.0.rb
39
+ - test
40
+ - test/arrayfields.rb
41
+ - test/memtest.rb
42
+ - sample
43
+ - sample/a.rb
44
+ - sample/b.rb
45
+ - README
44
46
  test_files:
45
- - test/arrayfields.rb
47
+ - test/arrayfields.rb
46
48
  rdoc_options: []
49
+
47
50
  extra_rdoc_files: []
51
+
48
52
  executables: []
53
+
49
54
  extensions: []
55
+
50
56
  requirements: []
51
- dependencies: []
57
+
58
+ dependencies: []
59
+
data/VERSION DELETED
@@ -1 +0,0 @@
1
- 3.6.0