English 中文(简体)
将curl命令添加到sinatra和rails?
原标题:adding curl command to sinatra and rails?
  • 时间:2011-02-10 20:21:35
  •  标签:
  • ruby
  • curl

(GAVE UP ON INSTALLING CURB. POSTED NEW QUESTION PER SUGGESTION OF ONE OF THE RESPONDENTS) I thought curl was built-in but got an undefined method error in a sinatra app. is there a gem i need to add?

轨道3也有同样的问题?


应用程序是,我只需点击一个外部url(http://kickstartme.someplace.com?action=ACTIONNAME&;token=XYZXYZXYZ)来启动远程进程。

外部url以以下格式返回描述成功/失败的XML:

<session>
  <success>true</success>
  <token>xyzxyzxyz</token>
  <id>abcabcabc</id>
</session>

所以,实际上,我所需要的只是让我的rails和sinatra应用程序访问该url,解析返回的任何内容,并粗暴地处理远程服务器无法回复的问题。

最佳回答
require  open-uri 
require  nokogiri 
response = open("http://kickstartme.someplace.com?action=ACTIONNAME&token=XYZXYZXYZ").read
doc = Nokogiri::XML(response)
问题回答

使用curb,一个到libcurl的Ruby绑定。您将获得所有curl功能,而无需使用系统

curl -b "auth=abcdef; ASP.NET_SessionId=lotsatext;" example.com

变成

curl = Curl::Easy.new( http://example.com/ )
curl.cookies =  auth=abcdef; ASP.NET_SessionId=big-wall-of-text; 
curl.perform

更多路缘石示例





相关问题
Ruby parser in Java

The project I m doing is written in Java and parsers source code files. (Java src up to now). Now I d like to enable parsing Ruby code as well. Therefore I am looking for a parser in Java that parses ...

rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

multiple ruby extension modules under one directory

Can sources for discrete ruby extension modules live in the same directory, controlled by the same extconf.rb script? Background: I ve a project with two extension modules, foo.so and bar.so which ...

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

热门标签