我正在 ubuntu vagrant box 中设置 JRuby 1.7 以与 Torquebox 一起使用。我正在使用Torquebox-remote-deployer gem 将存档文件和应用程序内容部署到虚拟机。现在,当 gem 尝试执行时bundle exec rake db:migrate,我收到以下错误:
bundler: not executable: rake
Run Code Online (Sandbox Code Playgroud)
现在,当我检查供应商/bundle/jruby/1.9/bin 目录时,rake 和所有其他所需的可执行文件都在那里。我还尝试通过本地 jruby 安装运行捆绑命令以确保正确调用它,但我得到了相同的结果
/opt/jruby/bin/jruby -S bundle exec rake db:migrate
Run Code Online (Sandbox Code Playgroud)
有什么建议么?如果您需要更多信息,请询问。
我首先使用 sudo apt-get install jruby 命令安装了 jruby,它成功了,但当我想要更高版本时,它确实给了我 1.5.6 版本。所以我卸载了它并使用 rvm install jruby 命令,我能够安装 jruby 版本 1.7.19,但是在安装它之后,我的 ruby 应用程序开始产生错误,抱怨缺少像 mysql2 gem 这样的 gem 丢失,运行 bundle install。我运行 bundle install 但我所做的似乎没有任何帮助,我无处可去。当我要求 ruby 版本时,我收到的是 jruby 版本,它的 lyk jruby 覆盖了 ruby,,,, 所以我决定卸载 jruby,重新安装 ruby,现在 ruby 的功能和以前一样。任何人都可以帮助我使用 ubuntu 命令来帮助我安装 jruby 和 ruby,这样两者都可以正常工作而没有任何错误???我请求认真的帮助
我在 jruby irb 上玩,遇到了这种现象,其中参数方法[[:rest]]在字符串方法上调用时返回。这不仅是字符串的情况,而且我将举一个关于字符串的例子。
irb(main):042:0> String.new.methods-Object.methods
[:valid_encoding?, :casecmp, :to_java_bytes, :squeeze!,
:is_utf8?, :slice, :hex, :[]=, :initialize_copy, :empty?,
:oct, :rindex, :unseeded_hash, :%, :rjust, :chop, :index,
:gsub!, :chomp!, :*, :+, :concat, :capitalize, :singularize,
:titlecase, :each_line, :size, :deconstantize, :downcase!,
:capitalize!, :to_sym, :humanize, :setbyte, :force_encoding,
:sub, :reverse!, :swapcase, :scan, :gsub, :sum, :partition,
:to_str, :codepoints, :swapcase!, :byteslice, :end_with?,
:upto, :tr!, :[], :intern, :parameterize, :tableize, :chomp,
:pluralize, :reverse, :mb_chars, :succ, :underscore, :titleize,
:start_with?, :ljust, :tr, :chars, :chop!, :encode, :<<,
:lstrip!, :dasherize, :prepend, :replace, :strip, :split, …Run Code Online (Sandbox Code Playgroud) Actioncable - 概述。
\n我正在使用 jruby 9.2.16(因此 ruby 2.5.7)和 Rails 6.1.6.1。
\n我不确定 Actioncable 是否仅在开发中或仅在没有 ssl (wss) 的情况下可以与简单客户端一起使用:
\nvar ws = new WebSocket(\'ws://0.0.0.0:3000/channels\');\nws.onmessage = function(e){ console.log(e.data); }\nRun Code Online (Sandbox Code Playgroud)\n但至少我没有让它在生产中使用 wss 运行“从通道流式传输”,因为它在本地工作(在终端中启动“redis-cli”,然后“监视”)。
\n所以我尝试实现可操作的客户端脚本,因此浪费了 8 天的时间。
\n首先,我对没有任何完整的描述感到困惑。许多人发布特定的解决方案,但这就像赌博:也许你很幸运。
\n其次,文件的命名方式似乎很通用,即使它们仅与可操作相关(文件夹“javascript”或“application.js”)\n不将它们称为“actioncable_files”会产生误导。 ' 和 \'actioncable_app.js\' 和 voil\xc3\xa0 由于多个同名文件而出现问题。
\n下一个问题是,只需更改很多内容,因为文件的有序结构被忽略。Javascript 不再位于 asset 中,但为什么?\n它们可能位于 asset/javascripts/actioncable/ 中?\n因此,manifest.js 必须更改,甚至必须在 application.rb 中添加属性(attr_accessor :importmap)。您在论坛几天后发现的东西。
\n但更令人困惑的是: importmap 是一个 gem,它需要一些目录,并且必须以某种方式安装(rake app:update:bin、rails importmap:install),有人写道,gems 的顺序是相关的,但你不能只卸载Actioncable gem,因为 Rails 依赖于它。可以使用优先级排列来组织依赖关系。
\nimportmaps 在 Firefox 中不起作用,因此您还需要垫片
\n在HBase的壳现在基于jirb,使用JRuby实现交互式Ruby外壳IRB的.除了通过这个shell之外,有没有任何好的技巧可以通过编程方式在JRuby中与HBase进行交互?
在对Hadoop的维基例子似乎只是直接调用Java API的; 还有什么我可以做的吗?
为什么这两个陈述不相同?
defined? foo ? foo << "bar" : foo = ["bar"]if (defined? foo) then foo << "bar" else foo = ["bar"] end第一个声明:
irb(main):001:0> defined? foo ? foo << "bar" : foo = ["bar"]
=> nil
irb(main):002:0> foo
=> nil
irb(main):003:0> defined? foo ? foo << "bar" : foo = ["bar"]
=> "expression"
irb(main):004:0> foo
=> ["bar"]
Run Code Online (Sandbox Code Playgroud)
第二个声明:
irb(main):001:0> if (defined? foo) then foo << "bar" else foo = ["bar"] end
=> ["bar"]
irb(main):002:0> foo
=> ["bar"]
irb(main):003:0> if …Run Code Online (Sandbox Code Playgroud) 我有以下正则表达式用于数据验证:
lexer = /(?:
(.{18}|(?:.*)(?=\s\S{2,})|(?:[^\s+]\s){1,})\s*
(.{18}|(?:.*)(?=\s\S{2,})|(?:[^\s+]\s){1,})\s*
(?:\s+([A-Za-z][A-Za-z0-9]{2}(?=\s))|(\s+))\s*
(Z(?:RO[A-DHJ]|EQ[A-C]|HIB|PRO|PRP|RMA)|H(?:IB[2E]|ALB)|F(?:ER[2T]|LUP2|ST4Q))\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\s+\d{10}|\s+)\s*
(\d{6})\s*
(.*)(?=((?:\d{2}\/){2}\d{4}))\s*
((?:\d{2}\/){2}\d{4})\s*
(\S+)
)/x
Run Code Online (Sandbox Code Playgroud)
问题是我必须遍历10000行(平均值)的文件,使用正则表达式执行验证,从而导致解析缓慢的应用程序.
filename = File.new(@file, "r")
filename.each_line.with_index do |line, index|
next if index < INFO_AT + 1
lexer = /(?:
(.{18}|(?:.*)(?=\s\S{2,})|(?:[^\s+]\s){1,})\s*
(.{18}|(?:.*)(?=\s\S{2,})|(?:[^\s+]\s){1,})\s*
(?:\s+([A-Za-z][A-Za-z0-9]{2}(?=\s))|(\s+))\s*
(Z(?:RO[A-DHJ]|EQ[A-C]|HIB|PRO|PRP|RMA)|H(?:IB[2E]|ALB)|F(?:ER[2T]|LUP2|ST4Q))\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\S+)\s*
(\s+\d{10}|\s+)\s*
(\d{6})\s*
(.*)(?=((?:\d{2}\/){2}\d{4}))\s*
((?:\d{2}\/){2}\d{4})\s*
(\S+)
)/x
m = lexer.match(line)
begin
if (m) then …Run Code Online (Sandbox Code Playgroud) 当我尝试在JRuby 1.6.5上安装Rails 3.2 rc 1时,我收到此gemspec错误:
Invalid gemspec in[/Users/robin/.rvm/gems/jruby-1.6.5/specifications/railties-3.2.0.rc1.gemspec]:
Illformed requirement ["#<YAML::Yecht::DefaultKey:0x469c3554> 3.2.0.rc1"]
Run Code Online (Sandbox Code Playgroud)
所有的核心轨道宝石似乎都有这个问题,任何想法?
我是Ruby的新手,我在Ruby中使用HashWithIndifferentAccess作为哈希特性.所以我的代码就像:
def someFunction
array_list = []
some_array.each do | x |
new_hash = HashWithIndifferentAccess.new
// add entries to new_hash
array_list.push(new_hash)
end
array_list
end
Run Code Online (Sandbox Code Playgroud)
问题是:对于每次迭代我都在初始化新哈希,但如果我这样做,则array_list中的条目变为空:
def someFunction
array_list = []
new_hash = HashWithIndifferentAccess.new
some_array.each do | x |
// add entries to new_hash
array_list.push(new_hash)
new_hash.clear
end
array_list
end
Run Code Online (Sandbox Code Playgroud)
我不想为每次迭代初始化新的哈希,这个问题的解决方案是什么?
运行脚本时,我不断收到此错误。我对Ruby很陌生,所以请原谅。
我正在使用内置了JRuby支持的Nuix编写脚本。
这是我的代码;
require 'benchmark'
require 'socket'
require 'rubygems'
require 'java'
java_import org.joda.time.format.DateTimeFormat
module JSwing
include_package javax.swing
end
def dropdown()
ar = Array.new
$current_case.getRootItems().each do set
ar set.guid()
end
names2 = JSwingJOptionPane.showInputDialog(nil, Please enter the name of the item set to export to Relativity.,
Choose item set, -1,
nil, ar.to_java(Object), ar[0])
if (names2.nil)
JSwingJOptionPane.showMessageDialog(nil, No Export Set Selected)
abort()
end
return names2
end
def writeLine (filepath, line)
File.open(filepath, 'a') { f1 f1.puts line }
end
def writeLines(filepath, lines)
#lines.each do …Run Code Online (Sandbox Code Playgroud) jruby ×10
ruby ×6
jrubyonrails ×2
actioncable ×1
bundler ×1
hash ×1
hbase ×1
import-maps ×1
irb ×1
java ×1
parameters ×1
parsing ×1
regex ×1
token ×1
torquebox ×1