在Windows XP中安装Ruby Curb gem [英] Install Ruby Curb gem in windows XP

查看:265
本文介绍了在Windows XP中安装Ruby Curb gem的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用ruby 1.8做文件上传,似乎没有好的开箱即用的解决方案。他们似乎都需要一些项目的第三方补丁或分支工作。我将使用机械化,但我实际上需要与一个xml api和机械化接口似乎是专门为直接处理网页。我试过RestClient,但它没有开箱即用的多部分表单的功能,你必须使用一个工程项目的叉子让它工作。类似的情况似乎存在Net:HTTP
我认为curb将是去的方式,因为我可能想要使用multicurl反正我计划做的一些其他事情。但是,在我的Windows机器上,我似乎不能安装curb宝石。 gem install curb给出一个错误,我需要指定curl库的位置。我试过传递选项到extconf但没有运气到目前为止。
下面是没有任何选项的gem install curb的输出。

I'm trying to do file uploads with ruby 1.8 and it seems like there are no good out-of-the-box solutions. They all seem to need some 3rd party patch or fork of a project to work. I would use mechanize but I actually need to interface with an xml api and mechanize seems to be made specifically for dealing directly with webpages. I've tried RestClient but it doesn't have that functionality for multipart forms out of the box, you have to use a fork of the project to get it to work. Similar situations seem to exist for Net:HTTP I'm thinking curb would be the way to go since I may want to use multicurl anyways for some other things I plan to do. However, on my windows machine I can't seem to install the curb gem. gem install curb gives an error saying I need to specify where the curl library lives.. I've tried passing options to extconf but no luck so far. Here is the output of gem install curb without any options

C:\ruby\lib\ruby\gems\1.8\gems\curb-0.5.4.0>gem install curb
Building native extensions.  This could take a while...
ERROR:  Error installing curb:
        ERROR: Failed to build gem native extension.

C:/ruby/bin/ruby.exe extconf.rb
checking for curl-config... no
checking for main() in curl.lib... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
        --with-opt-dir
        --without-opt-dir
        --with-opt-include
        --without-opt-include=${opt-dir}/include
        --with-opt-lib
        --without-opt-lib=${opt-dir}/lib
        --with-make-prog
        --srcdir=.
        --curdir
        --ruby=C:/ruby/bin/ruby
        --with-curl-dir
        --without-curl-dir
        --with-curl-include
        --without-curl-include=${curl-dir}/include
        --with-curl-lib
        --without-curl-lib=${curl-dir}/lib
        --with-curllib
        --without-curllib
extconf.rb:12:   Can't find libcurl or curl/curl.h (RuntimeError)

  Try passing --with-curl-dir or --with-curl-lib and --with-curl-include
  options to extconf.


Gem files will remain installed in C:/ruby/lib/ruby/gems/1.8/gems/curb-0.5.4.0 for inspection.
Results logged to C:/ruby/lib/ruby/gems/1.8/gems/curb-0.5.4.0/ext/gem_make.out

任何想法如何让这个工作?

Any ideas how I can get this to work?

推荐答案

已经,我没有找到一个解决方案,只是使用在github gems提供的rest-client。
gem install rest-client
将完成工作。
从那里你可以做一个多部分的帖子,可以包含1个或多个文件..它有所有的灵活性,可能需要一个休息客户端。
请参阅此处的文档: http://rdoc.info/projects/archiloque/rest -client
关于如何使用它的例子。

As I commented already, I did find a solution which was simply using the rest-client provided in the github gems.. gem install rest-client will get the job done. From there you can do a multipart post which can contain 1 or more files.. It has all the flexibility one could need in a rest-client. See the documentation here: http://rdoc.info/projects/archiloque/rest-client for examples on how to use it.

我发现它做的不正确的唯一的事情是解析cookie。我公司使用的cookie可以在值中具有相等的符号,并且不会正确解析它们。我已经放在一些黑客来解决这个问题,但最终,回来咬我。所以只是在另一天,我开始分析机械化/ WEBrick的代码,并能够利用来自Mechanize的CookieJar从休息管理Cookie希望我可以让rest-client的作者将这个功能构建到rest-client中,这样其他人就不会有我遇到的相同问题了。

The only thing I found that it didn't do correctly was parsing cookies. The cookies my company uses can have equal signs in the values and it doesn't parse them correctly. I had put in some hacks to get around the issue but eventually that came back to bite me.. So just the other day I started analyzing the code from Mechanize/WEBrick and was able to utilize the CookieJar from Mechanize to manage cookies from the rest-client.. Hopefully I can get the author of the rest-client to build this functionality into the rest-client so others won't have the same problems I had..

这篇关于在Windows XP中安装Ruby Curb gem的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆