Bad File Descriptor in Ruby Daemons

Using Ruby v1.8.7 and Daemons v1.1.8 on Mac OS X Lion, I am attempting to write a consumer process and get it run as a dameon: # config[:name] => 'idx_my_delete_consumer' # config[:daemon] => {:multiple => false, # :backtrace => true, # :dir_mode => :normal, # :log_dir => '/Users/pprakash/consumer.log', # :monitor =>

Ruby守护进程中的错误文件描述符

在Mac OS X Lion上使用Ruby v1.8.7和Daemons v1.1.8,我试图编写一个使用者进程并让它作为dameon运行: # config[:name] => 'idx_my_delete_consumer' # config[:daemon] => {:multiple => false, # :backtrace => true, # :dir_mode => :normal, # :log_dir => '/Users/pprakash/consumer.log', # :monitor => true, # :di

How to output sorted hash in ruby template

I'm building a config file for one of our inline apps. Its essentially a json file. I'm having a lot of trouble getting puppet/ruby 1.8 to output the hash/json the same way each time. I'm currently using <%= require "json"; JSON.pretty_generate data %> But while outputting human readable content, it doesn't guarantee the same order each time. Which means that puppet w

如何在红宝石模板中输出排序后的哈希

我正在为我们的一个内联应用程序构建一个配置文件。 它本质上是一个json文件。 我在使用puppet / ruby​​ 1.8来每次输出hash / json时都遇到了很多麻烦。 我目前正在使用 <%= require "json"; JSON.pretty_generate data %> 但是,在输出人类可读内容的同时,并不保证每次都有相同的顺序。 这意味着木偶会经常发送相同数据的更改通知。 我也试过了 <%= require "json"; JSON.pretty_generate Hash[*data.sort.f

Issue installing the Nokogiri gem in Mac OS X 10.5.8

I'm trying to install the Nokogiri gem under an RVM managed Ruby 1.8.7 installation in OS X Leopard (10.5.8). I'm getting the following error: Building native extensions. This could take a while... ERROR: Error installing nokogiri: ERROR: Failed to build gem native extension. /Users/user/.rvm/rubies/ruby-1.8.7-p352/bin/ruby extconf.rb checking for libxml/parser.h... yes

在Mac OS X 10.5.8中安装Nokogiri gem的问题

我试图在OS X Leopard(10.5.8)中的RVM托管Ruby 1.8.7安装下安装Nokogiri gem。 我收到以下错误: Building native extensions. This could take a while... ERROR: Error installing nokogiri: ERROR: Failed to build gem native extension. /Users/user/.rvm/rubies/ruby-1.8.7-p352/bin/ruby extconf.rb checking for libxml/parser.h... yes checking for libxslt/xslt.h... yes checking for libexslt/e

Omission of curly braces for a hash in an array

I realized that the curly braces for a hash can be omitted if it is the last element in an array. For example, the forms: [1, 2, 3, :a => 'A', :b => 'B'] [1, 2, 3, a: 'A', b: 'B'] seem to be identical to: [1, 2, 3, {:a => 'A', :b => 'B'}] [1, 2, 3, {a: 'A', b: 'B'}] I knew this kind of omission is possible for arguments of a method, but had not noted it is possible for an array.

在数组中省略大括号的大括号

我意识到,如果它是数组中的最后一个元素,那么可以省略哈希的大括号。 例如,表单: [1, 2, 3, :a => 'A', :b => 'B'] [1, 2, 3, a: 'A', b: 'B'] 似乎与以下内容相同: [1, 2, 3, {:a => 'A', :b => 'B'}] [1, 2, 3, {a: 'A', b: 'B'}] 我知道这种遗漏对于方法的参数是可能的,但没有注意到它可能是一个数组。 我对这条规则的理解是正确的吗? 而且,这是在什么地方描述的? 这似乎是1.9的新功能: $ rvm u

Getting started with MacRuby and Xcode 4.2

I recently thought of getting started with MacRuby. I've installed Xcode 4.2 and i've installed MacRuby, but apparently i am missing something. In every tutorial i found so far it says, that i have to choose "MacRuby Application" from the Xcode templates ... but there is no such entry available. I've tried with 0.10 and with a nightly released a few days ago. I've h

开始使用MacRuby和Xcode 4.2

我最近考虑开始使用MacRuby。 我已经安装了Xcode 4.2,我已经安装了MacRuby,但显然我错过了一些东西。 在我发现的每一篇教程中,我都说它必须从Xcode模板中选择“MacRuby Application”,但是没有这样的条目。 我已经尝试过0.10,并且在几天前每晚都会发布。 我已经看过MacRuby在哪里安装它的东西,我发现Xcode 3.0的模板...我必须使用这些模板,我如何将它们导入到Xcode 4.2? 在我开始之前,我还想知道,如果从MacRuby开

How can I detect whether a directory is writeable in Ruby

I am using Ruby and need to detect whether a directory is writeable before trying to create new files. I have tried the following code, which correctly returns true/false depending on whether @path is a directory. However, it still returns true when there is no write permission to the @path folder. if File.directory?(@path) && File.writable?(@path) #is a writeable directory

我如何检测一个目录是否可以在Ruby中写入

我正在使用Ruby,并且需要在尝试创建新文件之前检测目录是否可写入。 我已经尝试了下面的代码,根据@path是否是一个目录,它正确地返回true / false。 但是,如果没有对@path文件夹的写入权限,它仍会返回true。 if File.directory?(@path) && File.writable?(@path) #is a writeable directory true else #is not a writeable directory false end 我查看了File和Dir类的帮助,但无法看到任

What does %w(array) mean?

I'm looking at the documentation for FileUtils. I'm confused by the following line: FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6' What does the %w mean? Can you point me to the documentation? %w(foo bar) is a shortcut for ["foo", "bar"] . Meaning it's a notation to write an array of strings separated by spaces instead of commas and without

%w(数组)是什么意思?

我正在查看FileUtils的文档。 我被以下行弄糊涂了: FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6' %w是什么意思? 你能指点我的文档吗? %w(foo bar)是["foo", "bar"]的快捷方式。 这意味着写一个由空格分隔的字符串数组而不是逗号,并且不用逗号。 你可以在zenspider的quickref中找到写文字的列表。 我认为%w()是一个“字数组” - 元素由空格分隔。 还有其他的%文字: %

Combining RSpec filters?

I've been looking through the docs, but descriptions of how multiple filters work seem to be a bit lacking. Does anyone have a good explanation or source of a good explanation for the behaviour of multiple filters? Does the order they are listed matter? Here's an example of code that might have behaviour other than what one could expect... Rspec.configure do |c| this_version = get_v

结合RSpec过滤器?

我一直在浏览文档,但是关于多个过滤器如何工作的描述似乎有点欠缺。 有没有人有一个很好的解释或多个过滤器的行为很好的解释来源? 他们列出的订单是否重要? 以下是可能具有除人们所期望的行为以外的行为的代码示例... Rspec.configure do |c| this_version = get_version_number.to_sym c.filter_run :focus=> true c.filter_run_excluding :limit_to=>true, this_version => false c.filter_run :new_st

Issue installing Ruby rvm (error while running configure)

ruby-1.9.3-p0 - #configuring *ERROR: Error running ' ./configure --prefix=/Users/davedelich/.rvm/rubies/ruby-1.9.3-p0 --enable-shared --disable-install-doc --with-libyaml-dir=/Users/davedelich/.rvm/usr ', please read /Users/davedelich/.rvm/log/ruby-1.9.3-p0/configure.log ERROR: There has been an error while running configure. Halting the installation.* SupremeOverlord:~ davedelich$ cat /Users/da

安装Ruby rvm时出现问题(运行configure时出错)

ruby-1.9.3-p0 - #configuring *ERROR: Error running ' ./configure --prefix=/Users/davedelich/.rvm/rubies/ruby-1.9.3-p0 --enable-shared --disable-install-doc --with-libyaml-dir=/Users/davedelich/.rvm/usr ', please read /Users/davedelich/.rvm/log/ruby-1.9.3-p0/configure.log ERROR: There has been an error while running configure. Halting the installation.* SupremeOverlord:~ davedelich$ cat /Users/da

How can I print the runtime stack trace of a Ruby 1.9 process?

Is there any way to print the runtime stack trace of a Ruby 1.9.x process? I know that there was a utility called pstack for Ruby 1.8, but the project appears to have been abandoned a couple years ago: https://github.com/ice799/pstack. Does anything like this exist for Ruby 1.9? Thanks a lot! EDIT: I'm interested in using an external tool to generate the stack trace (not running in the s

我如何打印Ruby 1.9进程的运行时堆栈跟踪?

有没有办法打印Ruby 1.9.x进程的运行时堆栈跟踪? 我知道有一个名为pstack的实用程序,用于Ruby 1.8,但该项目几年前似乎已被放弃:https://github.com/ice799/pstack。 Ruby 1.9有类似的东西吗? 非常感谢! 编辑:我有兴趣使用外部工具来生成堆栈跟踪(没有运行在与Ruby进程相同的内存空间)。 正如@mosch所指出的那样, Kernal#caller方法在正在运行的Ruby进程中工作。 您甚至可以构建对您的Ruby代码的支持,以捕获