问题标签 [psychparser]

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 投票
1 回答
818 浏览

jruby - JRuby 1.7.1 和 PsychParser 解析 UTF-8 YAML 文件时出错 (Rails 3.2.8)

在我们的 JRuby/Rails 项目中,我们使用i18ngem,并且支持日语和英语。我们的config/locales.ja.yml文件是 UTF-8 格式,没有任何 BOM。

在 上运行Rails 3.2.9JRuby 1.7.1,我们现在看到以下错误:

YAML 解析ja.yml文件的这个错误现在在我们的 Windows XP 和 Linux 开发环境中都发生了,并且只有当我们为 JVM 显式设置以下系统参数时才会消失

谁能告诉我为什么会这样JRuby 1.7.1
我没有在1.6.8or中看到这个1.7.0

0 投票
3 回答
5238 浏览

ruby-on-rails - database.yml 的 Ruby 和 Rails yaml 解析器错误

环境 Rails 3.2.14 Ruby 1.9.3p448 Ubuntu 12.04 bundler 版本 1.3.5

ruby 1.9.3 加载 YAML 的方式存在一些问题。如果我干掉 databse.yml 文件中的代码,rails 控制台、服务器、生成等命令将失败。如果我删除这些默认值,那么一切正常。

我尝试过 psych 解析器和 syck 解析器。它只是 syck 解析器中的错误跟踪不同,但问题仍然存在。

下面只是一个例子。实际配置不同。当 database.yml 是这样的时候会导致错误:

当 database.yml 文件是这样的时候工作得很好:

以下是错误跟踪:

下面是完整的 database.yml 文件。如果我取消注释注释部分,则会出现此错误。与 ruby​​ 1.8.7 和 rails 2.3.x 一样,一切正常。

0 投票
0 回答
27 浏览

ruby-on-rails - 安装 Ruby 时遇到问题

这是我第二次尝试在我的系统上安装 Ruby。这次我关注了http://railsapps.github.io/installrubyonrails-mac.html。我已按照这些步骤操作,并一直被以下错误挂断。此时,我已经回溯并删除了 RVM 和 Homebrew,但现在我看到了这个错误。我搜索了堆栈溢出,谷歌等。有类似的问题,但它们都与系统文件无关。我可以从哪里开始有什么想法吗?

编辑:.gemrc 文件

0 投票
1 回答
2128 浏览

ruby-on-rails - 使用 ActiveRecord::Base.connection.execute 时的批处理

我正忙于编写一个迁移,这将使我们能够将我们的 yamler 从 Syck 迁移到 Psych,并最终将我们的项目升级到 ruby​​ 2。不过,这种迁移将非常耗费资源,因此我将需要使用分块。

我编写了以下方法来确认我计划使用的迁移结果产生了预期的结果,并且可以在不停机的情况下完成。为了避免活动记录自动执行序列化,我需要使用ActiveRecord::Base.connection.execute

我描述转换的方法如下

使用时如何使用批处理 ActiveRecord::Base.connection.execute

为了完整起见,我的更新功能如下

我从http://fossies.org/linux/openproject/db/migrate/migration_utils/legacy_yamler.rb得到的

0 投票
1 回答
81 浏览

ruby - SystemStackError trying to call `.to_yaml` in a cequel object

I started to work in a legacy project and if I try to find a cequel record and then convert it to yaml:

#xA;

I'm getting a stack level too deep error. Checking deeper, there's a @record_collection instance variable defined in the cequel record, which it brings a copy of the same object and inside of this, another copy of the same and so on...:

#xA;

The problem is, the ruby yaml parser, at some point, tries to parse all the instance variables of an object, which eventually derives in the mentioned SystemStackError.
Worth to mention this is only happening in this specific model, I mean, as far as I've seen, the @record_collection variable comes nil for another cequel models present in this project.
Not sure at all how this works, if this is a cequel bug or something not properly configured in the model, but... maybe has to do with cequel lazy loading?, anyway I'm running out of ideas here :(

0 投票
3 回答
4274 浏览

ruby - YAML:解析包含方括号作为其第一个字符的字符串时出错

我正在用 Ruby 解析 YAML 文件,其中一些输入导致 Psych 语法错误:

导致:

我从一个我无法控制的外部 API 收到了这个 YAML。我可以看到编辑输入以强制解析为字符串,使用my_key: '[string] string',如“我需要 YAML 中的字符串的引号吗? ”中所述,可以解决问题,但我无法控制如何接收输入。

有没有办法强制将输入解析为某些键的字符串,例如 my_key?是否有成功解析此 YAML 的解决方法?