[ANN] arrayfields-3.4.0

A

Ara.T.Howard

URLS:

- http://raa.ruby-lang.org/project/arrayfields/
- http://www.codeforpeople.com/lib/ruby/arrayfields/
- http://rubyforge.org/projects/arrayfields/

SYNOPSIS:

allow keyword access to arrays:

require 'arrayfields'

fields = 'name', 'age'
row = [ 'bob', 30 ]

row.fields = fields

row[ 'name' ] #=> 'bob'
row.indices 'name', 'age' #=> [ 'bob', 30 ]

assigning to un-named fields appends:

stack = []
stack.fields = %w(zero one)
stack['zero'] = 'zero'
stack['one'] = 'one'
stack #=> [ 'zero', 'one' ]

useful for database work:

relation = pgconn.query sql
relation.size #=> 65536

# yikes! do we really want to re-construct a hash for for each tuple when
# we already have Arrays?

fields = %w(ssn name position)
table.each{|tuple| tuple.fields = fields}

tuples[34578]['ssn'] #=> 574865032

LIST OF OVERRIDDEN METHODS:

- Array#[]
- Array#[]=
- Array#at
- Array#delete_at
- Array#fill
- Array#values_at
- Array#indices
- Array#indexes
- Array#slice
- Array#slice!

LIST OF NEW Array METHODS:

- Array#fields=
- Array#each_with_field

DOCS/USAGE/SAMPLE:

- lib/arrayfields.rb
- test/arrayfields.rb

AUTHOR:

(e-mail address removed)

HISTORY:

3.4.0:
- added FieldedArray[] ctor
- added methods to make Arrays with fields set behave more closely to Hashes
- each_pair
- each_key
- each_value
- fetch
- has_key?
- member?
- key?
- has_value?
- value?
- keys?
- store
- values

3.3.0:
- added gemspec file - thnx Assaph Mehr
- added FieldedArray proxy class which minimizes modifications to class
Array and allow ArrayFields to work (potientially) other arraylike object.
thnks Sean O'Dell
- added ArrayFields#to_hash method - this seems like an obvious one to add!
- remedied bug where using append feature of assigning with unknow field
appedended but did not append to acutal fields
- added samples
- created rubyforge accnt @ http://rubyforge.org/projects/arrayfields/

3.2.0:
- precedence fix in many methods - thnx. nobu
- test for #slice! were not being run - corrected
- added test for appeding via "a['new_field'] = 42"

3.1.0:
- added FieldSet class to reduce ram - thnx. Kirk Haines for profiliing
memory and prompting this change

- interface changed every so slightly so

a.fields = 'a', 'b', 'c'

is not allowed. use

a.fields = %w(a b c)

or

a.fields = ['a', 'b', 'c']


3.0.0:
- added unit tests


enjoy

-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| A flower falls, even though we love it;
| and a weed grows, even though we do not love it.
| --Dogen
===============================================================================
 
M

Mauricio Fernández


I have just uploaded arrayfields 3.4.0-1 to the preliminary Ruby Production
Archive (RPA) repository (http://rubyforge.org/frs/?group_id=265 --
more info at http://rpa-base.rubyforge.org).

batsman@tux-chan:/tmp/ruby$ rpa install arrayfields
Installing ports
Getting port arrayfields from http://rpa-base.rubyforge.org/ports/arrayfields_3.4.0-1.rps.
100% [========================================] 10240 bytes
Building arrayfields (3.4.0-1).
Generating RI data files.
Generating RDoc HTML documentation.
Calculating MD5 digests.
Building package in arrayfields_3.4.0-1_i686-pc-linux-gnu.rpa.
Installing arrayfields
Reusing cached package /home/batsman/usr/lib/ruby/rpa0.0/packages/arrayfields_3.4.0-1_i686-pc-linux-gnu.rpa.
Starting lightweight (metadata only) transaction for arrayfields
Checking for file conflicts in arrayfields.
Starting transaction for arrayfields
Preparing to replace arrayfields 3.3.0-1 with /home/batsman/usr/lib/ruby/rpa0.0/packages/arrayfields_3.4.0-1_i686-pc-linux-gnu.rpa
Package /home/batsman/usr/lib/ruby/rpa0.0/packages/arrayfields_3.4.0-1_i686-pc-linux-gnu.rpa unpacked.
Finished transaction for arrayfields
Starting lightweight (metadata only) transaction for arrayfields
Finished lightweight (metadata only) transaction for arrayfields
Finished lightweight (metadata only) transaction for arrayfields
Committed changes
 
A

Ara.T.Howard


I have just uploaded arrayfields 3.4.0-1 to the preliminary Ruby Production
Archive (RPA) repository (http://rubyforge.org/frs/?group_id=265 --
more info at http://rpa-base.rubyforge.org).

batsman@tux-chan:/tmp/ruby$ rpa install arrayfields
Installing ports
Getting port arrayfields from http://rpa-base.rubyforge.org/ports/arrayfields_3.4.0-1.rps.
100% [========================================] 10240 bytes
Building arrayfields (3.4.0-1).
Generating RI data files.
Generating RDoc HTML documentation.
Calculating MD5 digests.
Building package in arrayfields_3.4.0-1_i686-pc-linux-gnu.rpa.
Installing arrayfields
Reusing cached package /home/batsman/usr/lib/ruby/rpa0.0/packages/arrayfields_3.4.0-1_i686-pc-linux-gnu.rpa.
Starting lightweight (metadata only) transaction for arrayfields
Checking for file conflicts in arrayfields.
Starting transaction for arrayfields
Preparing to replace arrayfields 3.3.0-1 with /home/batsman/usr/lib/ruby/rpa0.0/packages/arrayfields_3.4.0-1_i686-pc-linux-gnu.rpa
Package /home/batsman/usr/lib/ruby/rpa0.0/packages/arrayfields_3.4.0-1_i686-pc-linux-gnu.rpa unpacked.
Finished transaction for arrayfields
Starting lightweight (metadata only) transaction for arrayfields
Finished lightweight (metadata only) transaction for arrayfields
Finished lightweight (metadata only) transaction for arrayfields
Committed changes


thanks very much, and keep up the good work!

cheers.

-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| A flower falls, even though we love it;
| and a weed grows, even though we do not love it.
| --Dogen
===============================================================================
 
J

Joao Pedrosa

Hi,

I'm using Arrayfields since two weeks ago, and it's already one of my
preferred Ruby libraries. Now that I'm using it a lot, I can't even
imagine doing what I do (databases, pdf reporting) without it.

The importance of referencing the columns by their 'names' instead of
their index is so great, so great... and everything works so well.

Thank you so much Ara.

Cheers,
Joao
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,240
Members
46,828
Latest member
LauraCastr

Latest Threads

Top