在Shoes应用中使用Ruby库和宝石 [英] Using Ruby libraries and gems with a Shoes app
问题描述
我正在写一个小鞋子应用程序,需要一个我用我的常规Ruby安装编写的库。我的库使用'net-ssh'gem和一堆其他Ruby库。
当我使用普通的ruby直接运行我的库时(它有自己的命令行接口)如下所示:
ruby my_lib.rb
...一切正常。但是,当我尝试在我的Shoes应用程序中需要它时,我得到'没有这样的文件来加载--net / ssh'错误(因为my_lib使用了net-ssh)。
我试着在这个应用中使用$:include path变量:
$ :. unshiftC:/ ruby / lib / ruby / 1.8
$ :. unshiftC:/ruby/lib/ruby/site_ruby/1.8
require'rubygems'
gem'net-ssh'
需要'my_lib.rb'
...但没有成功。我得到'找不到RubyGem net-ssh'。
任何人都有同样的问题?什么是在Shoes应用程序中使用Ruby库和宝石的最佳方式?
//hackety.org/2008/05/08/clearingUpTheWholeShoesAndRubyGemsDeal.htmlrel =noreferrer> _为什么在他的博客上发布 hackety.org,关于在Shoes中使用宝石。我希望它有帮助!
Shoes.setup do
gem'json> = 1.1.1'
gem' activerecord'
end
require'json'
require'activerecord'
Shoes.app do
@msg = paraALL SYSTEMS GO
animate(20){@ msg.toggle}
结束
I am writing a little Shoes app that requires a library I wrote with my regular Ruby installation. My library uses the 'net-ssh' gem and a bunch of other Ruby libraries.
When I run my library directly with regular ruby (it has its own command-line interface) like this:
ruby my_lib.rb
...all is fine. But when I try to require it within my Shoes app I get an 'no such file to load - net/ssh' error (because my_lib uses net-ssh).
I tried messing around with the $: include path variable in the Shoes app like this:
$:.unshift "C:/ruby/lib/ruby/1.8"
$:.unshift "C:/ruby/lib/ruby/site_ruby/1.8"
require 'rubygems'
gem 'net-ssh'
require 'my_lib.rb'
...but had no success. I get 'Could not find RubyGem net-ssh'.
Anyone has had the same problem? What's the best way to use your Ruby libraries and gems in a Shoes app?
Hey, _why posted on his blog, hackety.org, about using gems within Shoes. I hope it helps!
Shoes.setup do gem 'json >= 1.1.1' gem 'activerecord' end require 'json' require 'activerecord' Shoes.app do @msg = para "ALL SYSTEMS GO" animate(20) { @msg.toggle } end
这篇关于在Shoes应用中使用Ruby库和宝石的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!