Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[ANN] openobject-0.0.1

0 views
Skip to first unread message

ara.t.howard

unread,
Sep 9, 2007, 2:04:34 PM9/9/07
to

NAME

openobject

SYNOPSIS

a simple property based container that's much more capable than a
blankslate
but far less polluted than ruby's built-in OpenStruct. openobject
is a tiny
lib that couples the power of the 'attributes' gem alongside a
slightly
enhanced blankslate type object.

INSTALL

gem install openobject

URIS

http://codeforpeople.com/lib/ruby/
http://rubyforge.org/projects/codeforpeople/

SAMPLES

<========< sample/a.rb >========>

~ > cat sample/a.rb

require 'openobject'

oo = openobject

oo.foo = 42
oo.bar 'forty-two'

p oo.foo
p oo.bar

~ > ruby sample/a.rb

42
"forty-two"


<========< sample/b.rb >========>

~ > cat sample/b.rb

require 'openobject'

oo = openobject :foo => 42, :bar => 'forty-two' do
foobar 42.0
end

p oo.to_hash
p oo.attributes

~ > ruby sample/b.rb

{"foobar"=>42.0, "foo"=>42, "bar"=>"forty-two"}
["foo", "bar", "foobar"]


<========< sample/c.rb >========>

~ > cat sample/c.rb

require 'openobject'

oo = openobject :foo => 42

oo.bar = 'forty-two'

oo.extend do
attribute :foobar => 42.0

def barfoo
[ foo, bar, foobar ]
end
end

p oo.foobar
p oo.barfoo

~ > ruby sample/c.rb

42.0
[42, "forty-two", 42.0]


<========< sample/d.rb >========>

~ > cat sample/d.rb

require 'openobject'

config =
openobject do
attribute :header => openobject(:width => 42, :height => 42)
attribute :body => openobject(:width => 4242, :height => 4242)
attribute :footer => openobject(:width => 42.0, :height =>
42.0)
end

p config.header.width
p config.footer.height

~ > ruby sample/d.rb

42
42.0


AUTHOR

ara.t....@gmail.com


enjoy.


a @ http://drawohara.com/
--
we can deny everything, except that we have the possibility of being
better. simply reflect on that.
h.h. the 14th dalai lama


Trans

unread,
Sep 9, 2007, 2:43:00 PM9/9/07
to
On Sep 9, 11:04 am, "ara.t.howard" <ara.t.how...@gmail.com> wrote:
> NAME
>
> openobject
>
> SYNOPSIS
>
> a simple property based container that's much more capable than a
> blankslate
> but far less polluted than ruby's built-in OpenStruct. openobject
> is a tiny
> lib that couples the power of the 'attributes' gem alongside a
> slightly
> enhanced blankslate type object.

Hey dude, the name OpenObject is straight from Facets. And except for
your special attribute DSL, is similar in function.

http://facets.rubyforge.org/rdoc/OpenObjects/index.html

Not a major issue, of course, but certainly can't hurt to avoid name
conflicts. Care to change the name?

T.


ara.t.howard

unread,
Sep 9, 2007, 3:15:33 PM9/9/07
to

On Sep 9, 2007, at 12:43 PM, Trans wrote:

>
> Not a major issue, of course, but certainly can't hurt to avoid name
> conflicts. Care to change the name?
>
> T.

suggestions?

Logan Capaldo

unread,
Sep 9, 2007, 3:38:26 PM9/9/07
to
On 9/9/07, ara.t.howard <ara.t....@gmail.com> wrote:

> suggestions?
Merge the two projects! ;)

ara.t.howard

unread,
Sep 9, 2007, 3:52:21 PM9/9/07
to

On Sep 9, 2007, at 1:38 PM, Logan Capaldo wrote:

> Merge the two projects! ;)

they are actually quite a bit different - otherwise not a bad idea.
in particular mine is geared toward open behaviour (methods) not only
properties. still - might be possible...

Bil Kleb

unread,
Sep 9, 2007, 4:56:50 PM9/9/07
to
ara.t.howard wrote:
>
> suggestions?

Aren't they both namespaced? If so, where's the collison?

Later,
--
Bil Kleb
http://fun3d.larc.nasa.gov

ara.t.howard

unread,
Sep 9, 2007, 5:24:21 PM9/9/07
to

On Sep 9, 2007, at 3:00 PM, Bil Kleb wrote:

> Aren't they both namespaced? If so, where's the collison?

who is this 'namespaced' you speak of?

;-)

Logan Capaldo

unread,
Sep 9, 2007, 5:29:48 PM9/9/07
to
On 9/9/07, Bil Kleb <Bil....@nasa.gov> wrote:
> ara.t.howard wrote:
> >
> > suggestions?
>
> Aren't they both namespaced? If so, where's the collison?
>
I don't think google understands ruby namespaces, when I go searching
for "openobject" ;)

Peña, Botp

unread,
Sep 10, 2007, 5:25:39 AM9/10/07
to
From: ara.t.howard [mailto:ara.t....@gmail.com]
# config = openobject do
# attribute :header => openobject(:width => 42, :height => 42)
# attribute :body => openobject(:width => 4242, :height => 4242)
# attribute :footer => openobject(:width => 42.0, :height => 42.0)
# end
# p config.header.width
# p config.footer.height
# ~ > ruby sample/d.rb
# 42
# 42.0

LOL. cool :) downloading now...
thanks for openobject.. nice name too.
kind regards -botp

Logan Capaldo

unread,
Sep 11, 2007, 8:31:48 PM9/11/07
to
On 9/11/07, Steven Lumos <ste...@lumos.us> wrote:

> For that matter, there are at least two others?
>
> % gem search openobject
>
> *** LOCAL GEMS ***
>
> *** REMOTE GEMS ***
> Need to update 27 gems from http://gems.rubyforge.org
> ...........................
> complete
>
> calibre-openobject (1.0.0)
> OpenObject is an improved variation of OpenStruct
>
> openobject (1.3.0)
> OpenObject is an improved variation of OpenStruct
>
In retrospect I'm surprised there aren't more.
> Steve
>
>
>

Marc Heiler

unread,
Sep 11, 2007, 8:41:24 PM9/11/07
to
>> Care to change the name?

Brainstorming! Sorry, I have to add #comments :)


How about this:

FreeStruct # hehe
BetterStruct # yay! good indication!


protoobject # original yeah? :D
proteusobject # for a change, why only proto, why not proteus...

libreobject # i dont like that one, but who cares!
objectfate # this object starts blank, but it will grow slowly to
accept its fate in the world!


PS: I think a small problem with facets is that it looks big and
intimidating (to me, I have installed facets but didnt really
dig into it). Such smaller projects as this one are nice to have!
--
Posted via http://www.ruby-forum.com/.

Trans

unread,
Sep 12, 2007, 12:51:28 PM9/12/07
to

On Sep 11, 5:15 pm, Steven Lumos <ste...@lumos.us> wrote:

> For that matter, there are at least two others?
>
> % gem search openobject
>
> *** LOCAL GEMS ***
>
> *** REMOTE GEMS ***

> Need to update 27 gems fromhttp://gems.rubyforge.org


> ...........................
> complete
>
> calibre-openobject (1.0.0)
> OpenObject is an improved variation of OpenStruct
>
> openobject (1.3.0)
> OpenObject is an improved variation of OpenStruct

calibre-openobject is an older version of openobject. All the calibre-
* gems will be deleted soon actually, as that library was was merged
into Facets a while ago. The openobject gem is a stand-alone release
of the Facets library. I've long debated if I should release parts of
Facets in small individual packages. I've tested the waters in that
regard with a few libraries like this one. If there's enough demand, I
may continue to do so, but in the mean time my focus has been on
tightening up the the single package.

T.


Trans

unread,
Sep 12, 2007, 1:11:57 PM9/12/07
to

On Sep 9, 12:52 pm, "ara.t.howard" <ara.t.how...@gmail.com> wrote:
> On Sep 9, 2007, at 1:38 PM, Logan Capaldo wrote:
>
> > Merge the two projects! ;)
>
> they are actually quite a bit different - otherwise not a bad idea.
> in particular mine is geared toward open behaviour (methods) not only
> properties. still - might be possible...

I don't see a great deal of difference between Ara's openobject and
just using his attribute library with OpenStruct (perhaps with an
extra extension or two). OTOH, Facets' OpenObject class is designed to
be better than OpenStruct in some ways. It's faster, more open, and
doesn't have issues with #dup and so forth b/c of the use of singleton
methods.

On the surface however, the main item of difference is really the
#attribute method. Certainly Facets could incorporate that
functionality, but it sort of goes against the grain of it's
annotations system, which allows any piece of information to be
attached to attributes, not just default values. For example, Ara's
lib does:

attribute :x => 10

Where Facets' would do:

attr_accessor :x, :default => 10

At the moment Facets' annotations library doesn't do anything with the
annotations. So this is just a syntax distinction, not a functional
one. But I've always planned to expand the annotations system to
handle this, and a few other features like casting. It is for this
reason alone that I have never incorporated Ara's, otherwise excellent
attribute language.

Eventually I will get the annotations system handling it. The trick
has been finding a good way to generalize the procedure so others can
easily add there own "functional significance" to annotations. The key
to this may lie in around advice, actually. We shall see.

T.


0 new messages