ruby-1.9.2

How to set default Ruby version with RVM?

寵の児 提交于 2019-11-26 19:23:32
问题 Ubuntu 11. I do the following: $ rvm --default use 1.9.2 and I get: Using /home/md/.rvm/gems/ruby-1.9.2-p180 so that is good. but when I now open a new terminal window I still get: $ ruby -v ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-linux] 回答1: If you put the RVM source line in your bashrc (in order to ensure that non-interactive shells have access to RVM), you will need to source .bashrc from your .bash_profile with the following as the last lines in your .bash_profile if [ -f "$HOME/

Thread Safety: Class Variables in Ruby

青春壹個敷衍的年華 提交于 2019-11-26 19:17:44
问题 Performing writes/reads on class variables in Ruby is not thread safe. Performing writes/reads on instance variables appears to be thread safe. That said, is it thread safe to perform write/reads on instance variables of a class or metaclass object? What are the differences between these three (contrived) examples in terms of thread safety? EXAMPLE 1: MUTUAL EXCLUSION class BestUser # (singleton class) @@instance_lock = Mutex.new # Memoize instance def self.instance @@instance_lock

Get list of a class' instance methods

女生的网名这么多〃 提交于 2019-11-26 11:56:27
问题 I have a class: class TestClass def method1 end def method2 end def method3 end end How can I get a list of my methods in this class ( method1 , method2 , method3 )? 回答1: You actually want TestClass.instance_methods , unless you're interested in what TestClass itself can do. class TestClass def method1 end def method2 end def method3 end end TestClass.methods.grep(/method1/) # => [] TestClass.instance_methods.grep(/method1/) # => ["method1"] TestClass.methods.grep(/new/) # => ["new"] Or you

Invalid gemspec because of the date format in specification

萝らか妹 提交于 2019-11-26 07:54:49
问题 When I include a gem that I made, thanks to Bundler (version 1.0.12), in a Gemfile and then I try to bundle or to rake just like that: $ rake I\'ve got this error message: Invalid gemspec in [/Users/zagzag/.rvm/gems/ruby-1.9.2-p180@foobar/specifications/myplugin-1.0.0.gemspec]: invalid date format in specification: \"2011-04-21 00:00:00.000000000Z\" I\'m on the last Mac OS X (10.6.4), with: $ ruby -v ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.4.0] and: $ gem -v Invalid