Premshree Pillai ([info]premshree) wrote,
@ 2005-07-08 10:18:00
Previous Entry  Add to memories!  Tell a Friend!  Next Entry
Current music:Blue Oyster Cult - (Don't Fear) The Reaper
Entry tags:api, libyws, myweb2, ruby, tech, xml, xsd, yahoo, yws

libyws

Now the we have MyWeb 2.0 (which by the way, is quite cool. I could imagine doing tons of things with it.), it’s time for an update to the Ruby interface to YWSyahoo-ruby 0.2.

Do cool stuff:

require 'yahoo-ruby.rb'
obj = RelatedTags.new('yahoo-ruby', 'ruby', '', '', '', 1)
obj.parse_results.each { |ele|
        ele.each { |k,v|
                print "#{k} => #{v}\n" if v!=nil
        }
}

# Output
Tag => rails
Frequency => 23
Date => 1120011775

The code’s been lying around for some time (observe the date—June 29), but I didn’t release it assuming there’d be an official release or something. Oh well.

I think I’m gonna make major changes to the code. It works well, mind you. However, I’m not satisfied with the design. Ideally I’d like to simply parse the XSD, and spit out a hash. That’d mean each time a new API comes out, I just have to add another schema location to the existing bunch. And I’m not terribly sure I can do that with REXML. Maybe I’m wrong, though, because, honestly, I haven’s dug into it very deep. Oh yeah, I’m gonna move the project to RubyForge.



(Post a new comment)


[info]ga_woo
2005-07-08 11:00 am UTC (link)
Ideally I’d like to simply parse the XSD, and spit out a hash.

It's Ruby, man! You don't have to spit out a hash. You can actually create methods.
A Generic REST web service wrapper is something I've wanted to create for a long time. With Ruby's metaprogramming facilities and ERb, it shouldn't be too difficult. Nobody should ever have to create Ruby wrappers for RESTian services any more. Take that, Java! :D

(Reply to this)(Thread)


[info]premshree
2005-07-08 11:40 am UTC (link)
It's Ruby, man! You don't have to spit out a hash. You can actually create methods.

Yessir, I could create methods dynamically for all key gets. But I don’t see it so necessary... I mean isn't YahooSearchObj[3]['title'] good enough?

(Reply to this)(Parent)(Thread)


[info]ga_woo
2005-07-08 11:58 am UTC (link)
No. Not for me anyway. Mainly a matter of taste. I'm not eloquent enough to say why. Giving a map to the client of your library isn't really very friendly, ya know :)

Anyway, I don't think providing method-like access should even require metaprogramming. ostruct would be a better choice than a map. But I'd actually prefer a "real object" with "real methods" :)

Honestly, you don't get more of a kick using yahoo_search[3].title than using yahoo_search[3]['title'] ? :D

(Reply to this)(Parent)(Thread)


[info]hitchhiker
2005-07-08 01:42 pm UTC (link)
You could always forward missing methods to [] - I do that when using libglade and haven't had it bite me yet

(Reply to this)(Parent)(Thread)


[info]ga_woo
2005-07-08 01:53 pm UTC (link)
You really wouldn't prefer being able to call 'Object#methods' or 'Object#responds_to?' and get something that's useful?

I don't know. Maybe it's just something about having a map as the interface that disturbs the object-oriented bigot in me :)

(Reply to this)(Parent)(Thread)


[info]hitchhiker
2005-07-08 01:56 pm UTC (link)
Hm - at least for glade, that's not been an issue, since the method names correspond to otherwise meaningless identifiers I've assigned to components. Actually, I don't think I've ever had occasion to call #methods from within a ruby script, though I could come up with uses. Good point, though.

(Reply to this)(Parent)


[info]bluesmoon
2005-07-08 11:59 am UTC (link)
why can't you do an official release?

(Reply to this)


[info]hitchhiker
2005-07-08 01:41 pm UTC (link)
whoa - myweb looks amazingly cool. was it ever slashdotted? the 1.0 version slipped entirely under my radar.

(Reply to this)(Thread)


[info]premshree
2005-07-11 06:41 am UTC (link)
Don't remember seeing it on Slashdot. It’s a Yahoo! thingie after all. 1.0 didn’t have It; 2.0’s got It.

(Reply to this)(Parent)

Check out soap4r
(Anonymous)
2005-07-09 01:22 am UTC (link)
It implements a little bit of XSD for the purposes of dealing with WSDL. It may be what you're looking for; or at least a good start.

--
~akk
http://therealadam.com

(Reply to this)

new order phentermine blue and clear supper disk
(Anonymous)
2007-12-11 08:04 am UTC (link)
hay!!
good project :)
senks :)

(Reply to this)

info on tramadol proves href message tramadol
(Anonymous)
2008-02-18 08:13 pm UTC (link)
norvasc tramadol ordering tramadol online
tramadol pet tramadol testing no prescription tramadol buy tramadol 0a time to get tramadol out of system round tramadol tramadol side effects tramadol vs darvon ultram sniffing tramadol cheap easy tramadol

(Reply to this)


Create an Account
Forgot your login?
Login w/ OpenID
English • Español • Deutsch • Русский…