问题标签 [ruby-2.0]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
4 回答
21175 浏览

ruby - 如何在 Ruby 2.0 中使用调试器?

我知道调试器 gem 不是也永远不会与 ruby​​ 2.0 兼容,因为“正式支持 ruby​​ 2.X ”。

在 Ruby 2.0 的更新日志中是:

调试支持

DTrace 支持,可在

生产 TracePoint,这是一个改进的跟踪 API

是否有开箱即用的东西可以用 Ruby 2.0 进行调试?有人可以向我解释一下吗?

0 投票
1 回答
2827 浏览

ruby - Ruby 2.0 中的改进完全没用吗?

Ruby 2.0 中引入了所谓的改进。我和他们一起玩,现在我完全被哄骗了:

— 声明的主要优点refine是它们不是全局范围的。呸。

是孤立的,不是更糟。

— 改进不支持类方法。呸。当然,它们是通过 hack(记住,一切都是对象):

后者甚至不会导致性能损失,因为没有人会Fixnum.substr故意调用。

— 细化是通过 执行的evalrefine不是关键字。呸。(嗯,“呸!”再次。)

所以,我的问题是:我是否错过了什么或者每个人都认为新引入的功能没有优势?

0 投票
1 回答
634 浏览

ruby - rb-appscript 停止使用 Ruby 2.0.0 - 修补想法使其再次工作?

我知道官方不再支持 rb-appscript。

然而,我尝试并发现重写现有库以使用替代方法(例如 osascript)是一项不平凡的工作,并且在我看来,猴子修补 rb-appscript 再次工作似乎是一种更好的方法,如果可能的话。

这就是发生的事情。

Ruby 2.0.0 的哪些变化导致了这种情况?

0 投票
2 回答
403 浏览

ruby - Why does `send` fail with Ruby 2.0 refinement?

Why does this not work?

Can someone explain why send doesn't work here? And is there a way to dynamically call methods defined in a refinement? I can't seem to find a good, full explanation of how refinements work in Ruby 2.0.

0 投票
2 回答
1071 浏览

ruby - 在 OS X Snow Leopard 上使用 RVM 安装 Ruby 2.0 时出错

我正在尝试在运行 Snow Leopard 的 Macbook 上使用 RVM 安装 Ruby 2.0。RVM 版本 - 1.18.18 XCode 版本 - 4.0.2 GCC 版本 - 4.2.1

当我运行时rvm install 2.0.0,它失败了

make.log 因“总线错误”而失败。在此处完成日志https://gist.github.com/anonymous/1cacd89ee0d4fb2be3e2

我怀疑它与我的 gcc 有关,但无法弄清楚到底是什么。我尝试将 readline 设置为 brew 安装位置,将 gcc 设置为 Clang,但仍然遇到此错误。任何帮助表示赞赏。

0 投票
1 回答
2256 浏览

ruby - 错误:在 ruby​​ 2.0.0 中安装 vagrant gem

当我尝试在ruby​​ 2.0.0-p0中安装vagrant gem时,出现以下错误:

我想,它在构建 gem 并得到上述错误时使用来自 /home/user_name/.rvm/gems/ruby-2.0.0-p0/gems/ 的json-1.5.5 。

我尝试重新安装最新的json-1.7.7 gem,但仍然无法安装。

0 投票
1 回答
9121 浏览

ruby - 如何使用 JRuby 1.7 运行 Ruby 2.0?

让 JRuby 在 2.0 模式下运行的最佳方法是什么?

0 投票
9 回答
93295 浏览

ruby - Ruby 2 中的命名参数

我不完全理解 Ruby 2.0 中的命名参数是如何工作的。

它被视为哈希。这很有趣,因为要在 Ruby 2.0 中使用命名参数,我必须为它们设置默认值:

这与 Ruby 之前使用默认参数值的行为非常相似:

我知道为什么会发生这种情况以及它几乎是如何工作的。

但我只是好奇,如果我使用命名参数,我必须使用参数的默认值吗?

而且,谁能告诉我这两者之间有什么区别?

0 投票
1 回答
361 浏览

ruby - Segfault Error in Sinatra After Upgrading to Ruby 2.0 Beta

I'm reporting this because I haven't found any other reports of code that worked previously, but now generates random Ruby segmentation fault errors after upgrading to the just-released Ruby 2.0.0-p0.

I have a Sinatra application that generates a string that an .erb template embeds in a data- tag in the DOM. As I stated, this worked just fine until I upgraded to Ruby 2.0. With 2.0.0-p0, It gives segmentation fault errors, usually after about 5 to 20 runs of the program. When I revert to Ruby 1.9, it works perfectly again and I can run the program hundreds of times without problems.

Here's an example of the results I get from these errors. This is the first few lines of the 'control frame information' section of the error listing:

The line numbers indicated as the location where the error occured are always in the following code, somewhere inside the definition for the hash values{} after the encode method has been called by the line str << encode(hex) in the terrain_string method:

Maybe after other people have tried the brand new Ruby 2.0 release, others will report similar errors. In the meantime, is there anything else I should be looking at that might help pinpoint the problem with the 2.0.0-p0 release?

0 投票
0 回答
268 浏览

ruby - 用于调试 Ruby 2.0.0 的 Vim 插件?

我已经看到了一些在 Vim 中运行 Ruby 调试器的选项,包括 StackOverflow 上的一些很好的答案。但是,其中大多数似乎都针对 Ruby 1.8 或 1.9.2,并且不清楚如何让调试器在 Vim 中与 Ruby 2.0.0 一起运行。

最新的似乎是https://github.com/astashov/vim-ruby-debugger。感谢这里的一些答案,我已经能够让 Rails 服务器在这个插件下运行。但是,设置断点似乎没有任何效果:代码只是完成而没有中断。

我正在使用自制软件中的 MacVim,它回答启用 Ruby。

我是否缺少其他一些插件或宝石?

需要哪些 Vim 插件和 Ruby gem 才能在 Vim 中获得良好的调试体验(尤其是在 Mac OS X Lion 上)?