ruby-1.9.3

Load only what classes are being used in Ruby?

≡放荡痞女 提交于 2019-12-11 03:23:14
问题 If I load x.rb , then all the classes in that file are loaded. Is it possible to check and see what classes are being used and load those only? Assuming x.rb contains both Hello and Goodbye classes, and my program only uses the Hello Class, is it possible to load only the Hello Class? Happy with a script that checks the document, and outputs an .rb that has only the Hello Class and the code that uses it... Would be an interesting github project if doesn't exist, but I think it's out of my

How to traverse this hash within one line?

☆樱花仙子☆ 提交于 2019-12-10 19:01:31
问题 Each key in a hash has a value that's also a hash. { 100 => { 1 => 'ruby', 2 => 'enumerables' }, 50 => { 3 => 'can', 4 => 'cause' }, 15 => { 5 => 'occassional', 6 => 'insanity' } } For each hash object, I want to discard the top-level key, and replace it with the key and value of the nested hash objects. { 1 => 'ruby', 2 => 'enumerables', 3 => 'can', 4 => 'cause', 5 => 'occasional', 6 => 'insanity' } I have it working, but my method uses a merge! , and requires creating another hash to store

Ruby 1.9.3 multicore?

北慕城南 提交于 2019-12-10 16:14:08
问题 Yestereday I read a little about threading in ruby (like this article), and what I generally understood was, that (except a few implementations like JRuby), there is the so-called Global Interpreter Lock, and because of that, one cannot run ruby code on multiple CPUs at a time. I did a little test (I have AMD Turion II Dual-Core Mobile M500 processors, and running ubuntu 11.04, +rvm), to see this in action, with this code: threads = [] CPU = 2 CPU.times do threads << Thread.new { x=0 time

Cross-thread violation on rb_gc()

ぃ、小莉子 提交于 2019-12-10 14:16:55
问题 The codebase I'm working on was recently upgraded from Ruby 1.9.2 to Ruby 1.9.3 and from Rails 3.1 to Rails 3.2.2. Since I'm using RVM I simply did rvm install 1.9.3 which I would have expected to be all that was necessary. When I run rails s I get the error [BUG] cross-thread violation on rb_gc() I've found a number of links relating to this problem. There is one on StackOverflow, but it doesn't really give an answer. The most promising answer is on the RVM site: In every case of this I have

How install ruby 2.1.0 on OS_X 10.9 using rvm? ( No binary rubies available for: osx/10.9/x86_64/ruby )

怎甘沉沦 提交于 2019-12-10 10:13:26
问题 I'm trying to install ruby 1.9.3-p545 or ruby-2.1.0 or ruby-2.1.1, but it fails... My environment: OS_X 10.9 x86_64 rvm 1.25.20 Error from terminal: bmalets$ rvm install 1.9.3-p545 Searching for binary rubies, this might take some time. No binary rubies available for: osx/10.9/x86_64/ruby-1.9.3-p545. Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies. Checking requirements for osx_port. Installing macports........................................

Ruby on Linux PTY goes away without EOF, raises Errno::EIO

烈酒焚心 提交于 2019-12-08 23:40:44
问题 I'm writing some code which takes a file, passes that file to one of several binaries for processing, and monitors the conversion process for errors. I've written and tested the following routine on OSX but linux fails for reasons about which I'm not clear. #run the command, capture the output so it doesn't display PTY.spawn(command) {|r,w,pid| until r.eof? do ##mark puts r.readline end } The command that runs varies quite a lot and the code at the ##mark has been simplified into a local echo

How parallel are parallel tests in Ruby 1.9.3?

北慕城南 提交于 2019-12-08 19:44:22
问题 In Ruby 1.9.3, you're allowed to run multiple test cases at once. I'm not sure whether this is a feature of the language, the minitest library, or a feature of YARV, so apologies for any bad terminology. But have they eliminated the GVL for this, or does this merely mean that if one thread's doing IO, another thread can utilize the CPU? 回答1: The implementation doesn't use threads, but separate processes communicating through pipes. See e.g. this presentation. So the GVL/GIL doesn't come into

What does Module.private_constant do? Is there a way to list only private constants?

家住魔仙堡 提交于 2019-12-08 16:49:30
问题 Starting in Ruby 1.9.3, we can create private constants: module M class C; end private_constant :C end Is there a good documentation about what this does? Is there a way to get the names of only private constants similar to calling constants 回答1: As of Ruby 2.1, while Module#constants includes only public constants, if you set inherit=false , you will get private constants as well. So if you find a constant in constants(false) but not in constants (and you don't care about inherited constants

ERROR — : reaped #<Process::Status: pid 4335 exit 1> worker=0

血红的双手。 提交于 2019-12-08 04:50:19
问题 I am trying since 2 days to deploy on my vps (Ubuntu 12.04 Server (64 bits)) using : ruby (1.9.3-rc1), rails, capistrano, nginx and unicorn. I also follow railscast tutorial from Ryan Bates showing how to deploy on VPS from scratch. Actualy the cap deploy:cold command seems to work fine (as all the others) but when i try to go on my url i fall on "We're sorry but something went wront" => The default error page from Rails. In my production logs i get : Migrating to CreateQuestionAnswers

Confusion with Ruby File class related PATH methods [closed]

余生长醉 提交于 2019-12-08 01:54:28
问题 As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 6 years ago . I am getting confused with the utility of the File Class methods as below: 1. File::absolute_path 2. File::realdirpath 3. File: