罗德岛的 HTTparty
我正在使用 Rhodes 开发 Android 应用程序。 我已经在罗德安装了 HTTpary gem。现在,当我在应用程序顶部编写语句“require 'httparty'”时,它会给我错误,例如“没有要加载的文件”。 我应该怎么做才能解决这个问题?
I am using Rhodes to develop android application.
I have installed HTTpary gem in Rhodes. Now when I am writing the statement "require 'httparty' " at top of the application it gives me error like "No such file to load".
What should I do to solve this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
从文档中,向下滚动到以“将 Ruby 扩展库添加到您的罗德应用”。它详细介绍了将外部库包含到应用程序中的 3 种方法,总结如下。
基本 Rhodes 框架仅包含被认为足够通用的内容 - 因此可以保留构建的应用程序包大小低的。任何不在基础框架中的东西都可以通过上述方法包含在应用程序中。
From the documentation, scroll down to the section beginning "Adding Ruby Extension Libraries to Your Rhodes Application". It details 3 ways you can include external libraries into your application, summarized below.
The base Rhodes framework only contains things deemed generic enough to be included - so the built application package size can be kept low. Anything not in the base framework can be included in the application through the aforementioned methods.
这只是一个猜测,因为有罗德环境;但如果这是一个普通的 ruby 脚本,您首先需要
require 'rubygems'
(假设您使用 rubygems...)。This is just a guess since w/ Rhodes environment; but if this were a normal ruby script you would need to have
require 'rubygems'
first (assuming your used rubygems...).摩托罗拉的文档非常糟糕;如果可以的话请允许我帮忙。首先,检查 Ruby 代码中的常量
$LOAD_PATHS
以查看 Rhodes 搜索的完整路径列表。此路径中的任何.rb
文件都会自动可供require
使用。然后你必须决定是将该库添加到整个 Rhodes 框架还是仅添加到你的应用程序中;就我个人而言,我一次选择一个应用程序,因为这样可以减少不兼容的可能性,并且您的应用程序仍然会提供
rhodes-*version/lib/framework
中的所有库(如果您想添加)一个库到您的应用程序,文档建议将其放入目录
app/lib
中,但请记住,仅搜索这个确切的路径,因此如果您没有.rb
与你的 require 语句同名的文件直接在此路径下,它不会被自动检测到。 我提到这一点是因为常见的结构是单个文件,库名称直接放置在lib
中,以及同名文件夹中的实际库内容。示例:
mime-types
库由:lib/mime-types.rb
和lib/mime/
组成,它们的命名不同当包含在 Ruby 中时,可能会导致这种混乱。The Motorola documentation is horrendous; allow me to help if I can. Firstly, examine the constant
$LOAD_PATHS
from your Ruby code to see the entire list of paths that Rhodes searches. Any.rb
file in this path is automatically made available torequire
.Then you have to decide whether to add this library to the entire Rhodes framework or just your app; personally I opt for one app at a time, because that way it reduces the chances of incompatibilities, and your apps are still provided all the libraries in
rhodes-*version/lib/framework
If you want to add a library to your app, the docs suggest plopping it into the directory
app/lib
, but keep in mind that only this exact path is searched, so if you don't have a.rb
file of the same name as your require statement directly under this path, it won't be detected automatically. I mention this because the common structure is a single file with the library name placed directly inlib
, and the actual library contents inside a folder of the same name.Example: the
mime-types
library is made up of:lib/mime-types.rb
andlib/mime/
, which are named differently and can lead to exactly this kind of confusion when including in Ruby.