0

我使用 OCRA 在 Windows 中创建了一个 ruby​​ 可执行文件。我已经使用它几年了,效果很好,没有抱怨。

但是今天,当我在代码中创建和分发包含包含模块的 exe 时,它​​在包含模块行中失败了。

有没有更好的方法来编写代码或编译 exe?

在下面的代码中,错误发生在包含 Mongo的位置。如果我删除包含模块,则代码不起作用

require 'all the libs including mongo'

###############################################################
#### to insert the program parameters and the data to mongodb
###############################################################
def writedatatomongodb(toinsert, sname, dname, collname, lfile)
#Sampele params to insert  {:command=>"get data", :servername=>"servname", :remotecommand=>"/user/home/somefile", :outputfile=>"filename123_YYYYMMDD.txt"}

include Mongo
@client = MongoClient.new(sname, 27017)
p "Copying parametrs to Mongodb"
#@client = MongoClient.new('myservername', 27017)
@db     = @client[dname] 
@coll   = @db[collname]

File.open(lfile, 'a'){ |f| f.puts "Copying params to Mongodb" }
id = @coll.insert(toinsert)
p "Copied parametrs to Mongodb"
rescue Exception => e 
File.open(lfile, 'a'){ |f| f.puts "Error occured: #{e}" }
end
4

0 回答 0