[ANN] Initial release of Elemental

Discussion in 'Ruby' started by mwlang88, Feb 3, 2009.

  1. mwlang88

    mwlang88 Guest

    Posted By: Michael Lang
    Date: 2009-02-02 18:42
    Summary: [ANN] Initial release of Elemental
    Project: Elemental Enumerated Types

    I am happy to announce the initial release of Elemental 0.1.1.

    Elemental provides enumerated collection of elements that allow you to
    associate ruby symbols to arbitrary "display" values, thus allowing
    your code to think symbolically and unambiguously while giving you the
    means to easily display what end-users need to see. Additionally,
    symbols are associated with ordinal values, allowing easy storage/
    retrieval to persistent stores (databases, files, marshalling, etc) by
    saving the Element#value as appropriate (String by default, Fixnum if
    you "persist_ordinally").

    The primary aim of Elemental is to collect and abstract literals away
    from your code logic. There's an old programmer's wisdom that you
    should not encode your logic using literal values, especially those
    the end-user is exposed to.

    Complete details provided in README.txt

    http://github.com/mwlang/elemental/tree/master
    http://rubyforge.org/projects/elemental/

    Regards,

    Michael
    --
    http://ramblings.gibberishcode.net
     
    mwlang88, Feb 3, 2009
    #1
    1. Advertising

  2. mwlang88

    Ryan Davis Guest

    From your github readme:

    > if my_user.status == UserStatus::active.value
    > my_user.favorite_color = Color::blue


    versus:

    > if my_user.status == UserStatus::ACTIVE
    > my_user.favorite_color = Color::BLUE


    ?

    in other words, why would I want to add 250 lines of dependency code
    where 0 seems to suffice?
     
    Ryan Davis, Feb 3, 2009
    #2
    1. Advertising

  3. mwlang88

    mwlang88 Guest

    Re: Initial release of Elemental

    On Feb 2, 9:15 pm, Ryan Davis <> wrote:
    >  From your github readme:
    >
    > >   if my_user.status == UserStatus::active.value
    > >   my_user.favorite_color = Color::blue

    >
    > versus:
    >
    > >   if my_user.status == UserStatus::ACTIVE
    > >   my_user.favorite_color = Color::BLUE

    >
    > ?
    >
    > in other words, why would I want to add 250 lines of dependency code  
    > where 0 seems to suffice?


    As always, depends on where you want to go with it. For me, I wanted
    to catch typos immediately much like a compiled language might. I
    also wanted to associate a display value with a symbol. And I also
    wanted to have that be enumerable so I can populate a dropdown list or
    emit radio button groups and checkboxes.

    Not every case calls for Elemental, but I find that it heightens my
    code's clarity and maintainability and felt it worthy to release to
    public domain.

    Michael
     
    mwlang88, Feb 3, 2009
    #3
  4. On Mon, Feb 2, 2009 at 9:15 PM, Ryan Davis <> wrote:
    > From your github readme:
    >
    >> if my_user.status == UserStatus::active.value
    >> my_user.favorite_color = Color::blue

    >
    > versus:
    >
    >> if my_user.status == UserStatus::ACTIVE
    >> my_user.favorite_color = Color::BLUE

    >
    > ?
    >
    > in other words, why would I want to add 250 lines of dependency code where 0
    > seems to suffice?


    Don't be so harsh Ryan. You'd need at least two lines of code there :)

    -greg

    --
    Technical Blaag at: http://blog.majesticseacreature.com
    Non-tech stuff at: http://metametta.blogspot.com
    "Ruby Best Practices" Book now in O'Reilly Roughcuts:
    http://rubybestpractices.com
     
    Gregory Brown, Feb 3, 2009
    #4
  5. mwlang88

    Ryan Davis Guest

    Re: Initial release of Elemental

    On Feb 2, 2009, at 18:34 , mwlang88 wrote:

    >> in other words, why would I want to add 250 lines of dependency code
    >> where 0 seems to suffice?

    >
    > As always, depends on where you want to go with it. For me, I wanted
    > to catch typos immediately much like a compiled language might.


    immediately? how? you can't (afaik) do better than a runtime error of
    some kind. No different than a const_missing/NameError that you're
    going to get with a typo'd constant name.

    > I also wanted to associate a display value with a symbol.


    #to_s ? #to_html ? #to_whatever ? Maybe I'm not getting your point on
    this one.

    > And I also wanted to have that be enumerable so I can populate a
    > dropdown list or emit radio button groups and checkboxes.


    Arrays are already enumerable.

    # actual code from png.rb:
    Background = Color.from 0x00000000, "Transparent"
    Black = Color.from 0x000000FF, "Black"
    Blue = Color.from 0x0000FFFF, "Blue"
    Brown = Color.from 0x996633FF, "Brown"
    Bubblegum = Color.from 0xFF66FFFF, "Bubblegum"
    Cyan = Color.from 0x00FFFFFF, "Cyan"
    Gray = Color.from 0x7F7F7FFF, "Gray"
    Green = Color.from 0x00FF00FF, "Green"
    Magenta = Color.from 0xFF00FFFF, "Magenta"
    Orange = Color.from 0xFF7F00FF, "Orange"
    Purple = Color.from 0x7F007FFF, "Purple"
    Red = Color.from 0xFF0000FF, "Red"
    White = Color.from 0xFFFFFFFF, "White"
    Yellow = Color.from 0xFFFF00FF, "Yellow"

    so it would be trivial to do:

    Colors = [...all of the above...]

    ...
    options_from_collection_for_select(Color::Colors, :to_hex, :name)

    > Not every case calls for Elemental, but I find that it heightens my
    > code's clarity and maintainability and felt it worthy to release to
    > public domain.



    Granted, the doco you have up on github is a tad on the light side,
    but I just don't see it. Ruby seems to provide pretty good mechanisms
    for everything you're trying to solve.
     
    Ryan Davis, Feb 3, 2009
    #5
  6. mwlang88

    mwlang88 Guest

    Re: Initial release of Elemental

    On Feb 3, 4:45 am, Ryan Davis <> wrote:
    > On Feb 2, 2009, at 18:34 , mwlang88 wrote:
    >
    > >> in other words, why would I want to add 250 lines of dependency code
    > >> where 0 seems to suffice?

    >
    > > As always, depends on where you want to go with it.  For me, I wanted
    > > to catch typos immediately much like a compiled language might.

    >
    > immediately? how? you can't (afaik) do better than a runtime error of  
    > some kind. No different than a const_missing/NameError that you're  
    > going to get with a typo'd constant name.
    >
    > > I also wanted to associate a display value with a symbol.

    >
    > #to_s ? #to_html ? #to_whatever ? Maybe I'm not getting your point on  
    > this one.
    >
    > > And I also wanted to have that be enumerable so I can populate a  
    > > dropdown list or emit radio button groups and checkboxes.

    >
    > Arrays are already enumerable.
    >
    >      # actual code from png.rb:
    >      Background = Color.from 0x00000000, "Transparent"
    >      Black      = Color.from 0x000000FF, "Black"
    >      Blue       = Color.from 0x0000FFFF, "Blue"
    >      Brown      = Color.from 0x996633FF, "Brown"
    >      Bubblegum  = Color.from 0xFF66FFFF, "Bubblegum"
    >      Cyan       = Color.from 0x00FFFFFF, "Cyan"
    >      Gray       = Color.from 0x7F7F7FFF, "Gray"
    >      Green      = Color.from 0x00FF00FF, "Green"
    >      Magenta    = Color.from 0xFF00FFFF, "Magenta"
    >      Orange     = Color.from 0xFF7F00FF, "Orange"
    >      Purple     = Color.from 0x7F007FFF, "Purple"
    >      Red        = Color.from 0xFF0000FF, "Red"
    >      White      = Color.from 0xFFFFFFFF, "White"
    >      Yellow     = Color.from 0xFFFF00FF, "Yellow"
    >
    > so it would be trivial to do:
    >
    >    Colors = [...all of the above...]
    >
    > ..
    > options_from_collection_for_select(Color::Colors, :to_hex, :name)
    >
    > > Not every case calls for Elemental, but I find that it heightens my
    > > code's clarity and maintainability and felt it worthy to release to
    > > public domain.

    >
    > Granted, the doco you have up on github is a tad on the light side,  
    > but I just don't see it. Ruby seems to provide pretty good mechanisms  
    > for everything you're trying to solve.


    This is some interesting stuff and you have just shown me a technique/
    use of arrays I haven't encountered yet. Looks like I'm going to have
    to take myself back to school here.

    Michael
     
    mwlang88, Feb 4, 2009
    #6
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. O'Neal Computer Programmer

    python scripting game The Temple Of Elemental Evil update

    O'Neal Computer Programmer, Jul 7, 2003, in forum: Python
    Replies:
    1
    Views:
    419
    Bengt Richter
    Jul 7, 2003
  2. O'Neal Computer Programmer

    Temple of Elemental Evil and Python

    O'Neal Computer Programmer, Oct 30, 2003, in forum: Python
    Replies:
    0
    Views:
    588
    O'Neal Computer Programmer
    Oct 30, 2003
  3. Follower
    Replies:
    0
    Views:
    325
    Follower
    May 7, 2004
  4. Kirill Simonov

    [ANN] LibYAML-0.0.1: The initial release

    Kirill Simonov, Aug 1, 2006, in forum: Python
    Replies:
    0
    Views:
    348
    Kirill Simonov
    Aug 1, 2006
  5. Andrey Khavryuchenko
    Replies:
    0
    Views:
    629
    Andrey Khavryuchenko
    Jan 15, 2007
Loading...

Share This Page