[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Including core class extensions from gems

Shanti Braford

1/5/2007 11:23:00 AM

Hey all,

This question could just as easily be a good fit for the RoR list, but I
figured it's really more of a Ruby question, pertaining to a
Rails-specific gem in this case.

What I'm trying to do... is leverage Rails' activesupport gem.
Specifically, the new Hash.from_xml method (and all of its related
dependencies).

> gem list | grep activesupport
activesupport (1.3.1, 1.2.5)

Check.

This is where I'm a little befuddled as to how to do this the Ruby
way...

A simple test I've worked up to demonstrate whether or not this is
working (hash_from_xml_test.rb):

require 'rubygems'
require_gem 'activesupport', '>= 1.3.1'
require 'active_support'
require 'active_support/core_ext'

class HashFromXmlTest < Test::Unit::TestCase
def test_hash_from_xml
h = Hash.from_xml('<foo>bar</foo>')
assert h.is_a?(Hash)
end
end


Running this gives a "NoMethodError: undefined method `from_xml' for
Hash:Class".

Any ideas?

Cheers,

- Shanti
http://onwe...

--
Posted via http://www.ruby-....

2 Answers

Eric Hodel

1/5/2007 6:57:00 PM

0

On Jan 5, 2007, at 03:22, Shanti Braford wrote:

> This question could just as easily be a good fit for the RoR list,
> but I
> figured it's really more of a Ruby question, pertaining to a
> Rails-specific gem in this case.
>
> What I'm trying to do... is leverage Rails' activesupport gem.
> Specifically, the new Hash.from_xml method (and all of its related
> dependencies).
>
>> gem list | grep activesupport
> activesupport (1.3.1, 1.2.5)
>
> Check.
>
> This is where I'm a little befuddled as to how to do this the Ruby
> way...
>
> A simple test I've worked up to demonstrate whether or not this is
> working (hash_from_xml_test.rb):
>
> require 'rubygems'
> require_gem 'activesupport', '>= 1.3.1'

You don't need this line at all. Rubygems is smart and knows which
gem to load.

By the way, 'require_gem' is deprecated, use 'gem'

> require 'active_support'
> require 'active_support/core_ext'
>
> class HashFromXmlTest < Test::Unit::TestCase
> def test_hash_from_xml
> h = Hash.from_xml('<foo>bar</foo>')
> assert h.is_a?(Hash)
> end
> end
>
>
> Running this gives a "NoMethodError: undefined method `from_xml' for
> Hash:Class".

You probably have to load some other file. I'm sure grep will find
it. If not, try the Rails list.

--
Eric Hodel - drbrain@segment7.net - http://blog.se...

I LIT YOUR GEM ON FIRE!


RD Sandman

5/15/2013 9:49:00 PM

0

deep wrote in news:s716p8t1dgltchab5bsdnsv8t5ldamma6d@4ax.com:

> On Tue, 14 May 2013 16:02:35 -0700, Winston_Smith
> <invalid@butterfly.net> wrote:
>
>>As I write this, I find it amusing that I'M the conservative and YOU
>>are the liberal. I guess I like individual liberties and you like
>>central government.
>
> That's not what a liberal is, and conservatives are NOT defined by
> individual liberties. Conservatives are only about bigger government
> with them in charge.
>

Both sides want that bigger government....the only difference is what
they want that bigger government doing.

--
Sleep well, tonight.....

RD (The Sandman

You can be young without money, but you
can't be old without it.