【问题标题】:Run a ruby / gem repo on mac在 Mac 上运行 ruby​​ / gem 存储库
【发布时间】:2020-01-16 21:38:49
【问题描述】:

我是 node.js 开发者,我想运行这个应用程序https://github.com/seven1m/bible_parser

已安装 ruby​​ 和 gem,但下一步是什么?

【问题讨论】:

  • Gem 是一个库,因此您需要使用它在 Ruby 中实际编写一些代码。存储库中有一个示例。这应该转到某个文件,比如bible.rb,然后使用ruby bible.rb 运行。

标签: node.js ruby rubygems


【解决方案1】:

与 gem 交互的最快方法可能是使用 IRB(这是标准的 Ruby REPL,类似于在终端中使用 Node 命令打开 Node REPL)。

在您的终端中(我假设您正在使用类似 Unix 的操作系统),运行以下命令:

$ irb - 如果你正确安装了 Ruby,这应该会打开一个 IRB 会话

进入 IRB 后,您可以运行 Ruby 命令并立即评估和执行它们。从这里您可以运行 gem 的 README 中的用法示例:

require 'bible_parser'

bible = BibleParser.new(File.open('web.usfx.xml'))
verse = bible.books.first.chapters.first.verses.first
# => <Genesis 1:1>
verse.text
# => "In the beginning, God created the heavens and the earth.\n"

当然,这假设您有一个有效的 XML 文档可用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多