草庐IT

git - `--name` 选项没有 \'t work with ` git submodule add` 命令

全部标签

ruby-on-rails - Rcov:为什么这段代码没有被考虑覆盖?

这是我的Controller:classMyController@list}format.json{render:json=>@list}endendendend...它所基于的助手:moduleMyHelperdefget_list_from_params(param=:id,&on_success)raw_id=params[param]beginid=Integer(raw_id)rescuerender:template=>"invalid_id",:locals=>{:id=>raw_id}elseyieldMyList.new(id)endendend...和我的功能测试(

ruby-on-rails - rails 3 缓存 : expire action for named route

我的Controller有这个:caches_action:render_ticker_for_channel,:expires_in=>30.seconds在我的路由文件中我有这个:match'/render_c_t/:channel_id'=>'render#render_ticker_for_channel',:as=>:render_channel_ticker在日志文件中我看到了这个:Writefragmentviews/mcr3.dev/render_c_t/63(11.6ms)我如何手动使它过期?我需要从与渲染Controller不同的Controller使它过期,但即使

ruby - 当 shelled-out 命令返回非零退出代码时,如何让 Ruby 脚本失败?

在Ruby脚本中,有variousways调用系统命令/命令行反引号:`commandarg1arg2`分隔形式,例如%x(commandarg1arg2)(可用其他分隔符)Kernel#system方法:system('commandarg1arg2')Kernel#exec方法:exec('commandarg1arg2')如果我希望Ruby脚本在调用的命令失败时失败(有异常)(具有非零退出代码),我可以检查特殊变量中的退出代码$?对于前两个变体:`commandarg1arg2`failunless$?==0或%x,commandarg1arg2,failunless$?==0如

ruby - 是否有任何命令可以使用 vim 转到 Ruby block 的末尾(或开始)

有没有办法使用vim结束Rubyblock?例如moduleSomeModule#defsome_methodendend我想用一个命令从光标所在的位置移动到block的末尾,这可能吗?我读过thisdocumentation,但它似乎不适用于.rb文件,我在某些地方读到它只适用于C(虽然还没有尝试过)。提前致谢。 最佳答案 rubyforge好像有官方包对此有一些支持:TheRubyftpluginnowincludesRubyspecificimplementationsforthe[[,]],[],][,[m,]m,[M,an

ruby-on-rails - rails 上的 ruby 。 bundler 。 cucumber 。 rake 中止!命令失败,状态为 (1)

我在Rails3中使用Bundler和Cucumber时遇到问题。当我运行$rakecucumber时,我得到以下输出:bundleexec/usr/local/bin/ruby-I"/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-0.8.5/lib:lib""/usr/local/lib/ruby/gems/1.9.1/gems/cucumber-0.8.5/bin/cucumber"--profiledefault(in/home//practice/rails/blog)Usingthedefaultprofile...UUUU1scen

ruby - 有没有更简洁的方法来检查 PGResult 是否为空?

我正在使用pggem从Ruby与PostgreSQL对话。有没有检查是否没有结果比使用res.ntuples==0更好的方法?conn=PGconn.connectconfigcmd="select*fromlabelsinnerjoinlabels_mailusing(label_id)"+"wherelabels_mail.mail_id=$1andlabels.name=$2"res=conn.exec(cmd,[mail_id,mailbox])ifres.ntuples==0# 最佳答案 元组,打字错误?使用zero?比=

ruby-on-rails - Rails 3 Cli 执行命令真的很慢吗?

有人知道为什么我的rails3.0.7cli这么慢吗?当我运行railss或railsg时,他大约需要5秒才能真正执行命令...有什么建议吗?谢谢 最佳答案 更新:我正在将我的建议从rrails切换到rails-sh,因为前者支持REPL,而rrails不是用例。此外,当与ruby​​环境结合使用时,修补似乎确实可以提高性能变量,现在反射(reflect)在答案中。一个可能的原因可能是这个performancebuginruby每当在ruby​​代码中使用“require”时,它就会调用一些代码(更多详细信息here)。在使用Rai

ruby - 如何使用 pager 制作 ruby​​ 命令行应用程序?

我正在使用Ruby制作一个命令行工具。它将在屏幕上打印大量文本。目前,我正在使用shell管道(may_app|more)来执行此操作。但我认为最好有一个默认的寻呼机。就像你在执行gitlog时看到的一样。可以使用git--nopagerlog禁用寻呼机。我已经完成了大量的谷歌工作并找到了一颗gem:hirb,但似乎有点矫枉过正。经过多次尝试,我目前正在使用shellwrapper来这样做:#!/bin/bash#xray.rbisthecorescript#doingthemainlogicandwill#outputmanyrowsoftexton#screenXRAY=$HOME

ruby - 如何将 Thor::Group 注册为带参数的子命令

这道题开始于here.但随着我对雷神的了解越来越多,情况发生了很大变化。我正在尝试创建一个带参数的Thor::Group子命令。奇怪的是,如果没有参数,它就可以工作。我可以使用Thor::Group作为子命令吗?这在我输入时有效:foocounterfoo/bin/foomoduleFooclassCLI但是当我输入时这不起作用:foocounter5moduleFooclassCLI','Countupfromtheinput.')endclassCounter:numeric,:desc=>"Thenumbertostartcounting"desc"Prints2numbersb

ruby - 我如何从 Rational(或任何没有构造函数的类)继承?

例如,我可以很容易地继承自String,如下所示:classMyString'thingsandstuff'但是我如何继承没有构造函数的Rational呢?例如:defMyRatNoMethodError:undefinedmethod`new'forMyRat:ClassMyRat(10).inc#=>NoMethodError:undefinedmethod`MyRat'formain:ObjectMyRat.send(:initialize,10).inc#=>TypeError:alreadyinitializedclass#???#Noneofitworks!我找不到初始化新