将 Ruby 库和 gem 与 Shoes 应用程序一起使用 [英] 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 路径变量,如下所示:
$:.unshift "C:/ruby/lib/ruby/1.8"$:.unshift "C:/ruby/lib/ruby/site_ruby/1.8"需要红宝石"宝石'net-ssh'需要'my_lib.rb'
...但没有成功.我得到找不到 RubyGem net-ssh".
有人遇到过同样的问题吗?在 Shoes 应用中使用 Ruby 库和 gem 的最佳方式是什么?
嘿,_为什么发布在他的博客,hackety.org,关于在鞋子中使用宝石.希望对你有帮助!
<上一页>Shoes.setup 做宝石'json> = 1.1.1'宝石'活动记录'结尾需要'json'需要活动记录"鞋子.app 做@msg = para "所有系统运行"动画(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
这篇关于将 Ruby 库和 gem 与 Shoes 应用程序一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!