Testing Rails: problem running a Gruff sample

Discussion in 'Ruby' started by Richard Lionheart, Jan 30, 2006.

  1. Hi All,

    I get errors when I try to run a Gruff sample for my WinXP/SP2 system and
    get an error which I can't fathom.
    The sample is "Code Sample" from http://nubyonrails.topfunky.com/pages/gruff
    (scroll down to find it). I call it GraphicsTest.rb and display it below.

    When I test it from within SciTE, I get:
    >ruby GraphicsTest.rb

    GraphicsTest.rb:6: uninitialized constant Gruff (NameError)
    >Exit code: 1


    Months ago, I had Gem, Ruby, FxRuby, Rails, etc. all beautifully installed
    and working. I believe the GraphicsTest.rb sample ran fine at that time.
    Then sometime later I had a brain cramp and deleted the entire installation.
    Or maybe I was a victim of alien invaders :)

    I have now reinstalled everything using the one-click installer 1.8.2-15
    Stable Release. Shown below is the list of installed components according to
    "gem list --local".

    I ran simple tests on the various components (except Gruff) successfully
    until I tried to test Rails using the above sample. Any suggestions as to
    how I might get this test running properly?

    --
    Regards,
    Richard

    *** LOCAL GEMS ***
    actionmailer (1.1.5)
    actionpack (1.11.2)
    actionwebservice (1.0.0)
    activerecord (1.13.2)
    activesupport (1.2.5)
    fxri (0.3.2)
    fxruby (1.4.4, 1.2.6)
    gruff (0.0.9)
    rails (1.0.0)
    rake (0.7.0)
    sources (0.0.1)

    === GraphicTest.rb ===
    #!/usr/bin/ruby

    require 'rubygems'
    require 'gruff'

    g = Gruff::Line.new
    g.title = "My Graph"

    g.data("Apples", [1, 2, 3, 4, 4, 3])
    g.data("Oranges", [4, 8, 7, 9, 8, 9])
    g.data("Watermelon", [2, 3, 1, 5, 6, 8])
    g.data("Peaches", [9, 9, 10, 8, 7, 9])

    g.labels = {0 => '2003', 2 => '2004', 4 => '2005'}

    g.write('my_fruity_graph.png')
    Richard Lionheart, Jan 30, 2006
    #1
    1. Advertising

  2. Richard Lionheart

    Raj Guest

    Richard Lionheart wrote:
    > Hi All,
    >
    > I get errors when I try to run a Gruff sample for my WinXP/SP2 system
    > and
    > get an error which I can't fathom.
    > The sample is "Code Sample" from
    > http://nubyonrails.topfunky.com/pages/gruff
    > (scroll down to find it). I call it GraphicsTest.rb and display it
    > below.
    >
    > When I test it from within SciTE, I get:
    >>ruby GraphicsTest.rb

    > GraphicsTest.rb:6: uninitialized constant Gruff (NameError)
    >>Exit code: 1

    >


    I ran into the same issue and resolved it as follows:

    You need to have RMagick installed and configured.

    Instructions to install Rmagick on windows are here:
    http://rmagick.rubyforge.org/install-faq.html#win

    However for the Rmagick install to work gem must be at 0.8.11 level.

    In my case gem --version reported 0.8.10

    So, I did the following to get gem updated:

    gem install rubygems-update
    update_rubygems

    That took care of gem --version (reports 0.8.11)

    Then I did the following:

    downloaded RMagick-1.9.2-IM-6.2.4-6-win32.zip from the rubyforge site

    unzipped it, then ran the following commands from the directory where
    the files where unzipped to

    gem -install RMagick-win32-1.9.2-mswin32.gem
    postinstall.rb

    Then ran a simple standalone program (same as the one you tried) that
    used gruff and voila! everything worked.

    Adding it to my test Rails application was a breeze after that.

    Hope that helps.

    Raj

    --
    Posted via http://www.ruby-forum.com/.
    Raj, Feb 1, 2006
    #2
    1. Advertising

  3. Hi Raj.


    > You need to have RMagick installed and configured.


    I didn't get a response in the first day after my post, so I thought the
    Gruff wasn't of much interest to folks on this NG. I emailed Geoffrey
    Grosenbach, the Gruff developer, directly and he was kind enough to tell me
    the same thing, but he concluded "(I need to put together a simple
    RMagick-only script for testing as well.)".

    So your detailed guidance on how to install RMagick was very timely,
    indeed -- and excellent!

    > gem -install RMagick-win32-1.9.2-mswin32.gem


    Just in case you post your instructions to some other poor soul, please note
    that there's a hyphen in front of 'install'.

    My "Code Sample" from http://nubyonrails.topfunky.com/pages/gruff worked
    fine: it created a .png file in the same directory as the .rbw source file.

    But another sample from http://topfunky.net/svn/gruff/test/area_test.rb
    didn't seem to work. I noted it didn't include the "require 'rubygems'"
    that the preceding sample did, but including it didn't seem to make any
    difference. If you have any take on this, I'd appreciate hearing your
    advice.

    > Hope that helps.


    It certainly did. Thank you very much for taking the time to post it.

    Best wishes,
    Richard
    Richard Lionheart, Feb 3, 2006
    #3
  4. Richard Lionheart

    Guest Guest

    Richard Lionheart wrote:
    > Hi Raj.
    > ...
    > ...
    >
    > But another sample from http://topfunky.net/svn/gruff/test/area_test.rb
    > didn't seem to work. I noted it didn't include the "require 'rubygems'"
    > that the preceding sample did, but including it didn't seem to make any
    > difference. If you have any take on this, I'd appreciate hearing your
    > advice.
    >


    Hi Richard,

    I must have skimmed through this part of your post and did not pay
    attention to the above point that I should have responded to. Hope this
    is isnt too late... I was able to run the referenced sample first try
    without any modifications whatsoever. I did create a test/output
    directory before I ran the program. That was about it

    Raj


    --
    Posted via http://www.ruby-forum.com/.
    Guest, Feb 11, 2006
    #4
  5. Hi Raj,

    > I must have skimmed through this part of your post and did not pay
    > attention to the above point that I should have responded to. Hope this
    > is isnt too late... I was able to run the referenced sample first try
    > without any modifications whatsoever. I did create a test/output
    > directory before I ran the program. That was about it


    I abandoned this for a while, so I didn't notice you latest post. I'll
    give it another try in the next week or so.

    Thanks for the follow-up.

    Regards,
    Richard
    Richard Lionheart, Feb 22, 2006
    #5
    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. Chris
    Replies:
    0
    Views:
    84
    Chris
    Apr 4, 2005
  2. Problems with Gruff

    , Nov 20, 2005, in forum: Ruby
    Replies:
    8
    Views:
    98
  3. erhan

    Gruff UTF-8 problem

    erhan, Jul 4, 2006, in forum: Ruby
    Replies:
    0
    Views:
    87
    erhan
    Jul 4, 2006
  4. Luc Juggery

    REXML + Gruff: display label problem

    Luc Juggery, Nov 3, 2006, in forum: Ruby
    Replies:
    0
    Views:
    119
    Luc Juggery
    Nov 3, 2006
  5. Victor Reyes
    Replies:
    1
    Views:
    119
    David Mullet
    Apr 4, 2008
Loading...

Share This Page