ruby-1.9

Invalid gemspec because of the date format in specification

▼魔方 西西 提交于 2019-11-26 21:17:16
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 gemspec in [/Users/zagzag/.rvm/gems/ruby-1.9.2-p180@foobar/specifications/myplugin-1.0.0.gemspec]: invalid date

How do I reference a function in Ruby?

烂漫一生 提交于 2019-11-26 19:43:29
问题 In python, it's fairly straightforward to reference a function: >>> def foo(): ... print "foo called" ... return 1 ... >>> x = foo >>> foo() foo called 1 >>> x() foo called 1 >>> x <function foo at 0x1004ba5f0> >>> foo <function foo at 0x1004ba5f0> However, it seems to be different in Ruby since a naked foo actually calls foo: ruby-1.9.2-p0 > def foo ruby-1.9.2-p0 ?> print "foo called" ruby-1.9.2-p0 ?> 1 ruby-1.9.2-p0 ?> end => nil ruby-1.9.2-p0 > x = foo foo called => 1 ruby-1.9.2-p0 > foo

Ruby: require vs require_relative - best practice to workaround running in both Ruby <1.9.2 and >=1.9.2

只谈情不闲聊 提交于 2019-11-26 19:17:47
What is the best practice if I want to require a relative file in Ruby and I want it to work in both 1.8.x and >=1.9.2? I see a few options: just do $LOAD_PATH << '.' and forget everything do $LOAD_PATH << File.dirname(__FILE__) require './path/to/file' check if RUBY_VERSION < 1.9.2, then define require_relative as require , use require_relative everywhere where it's needed afterwards check if require_relative already exists, if it does, try to proceed as in previous case use weird constructions such as require File.join(File.dirname(__FILE__), 'path/to/file') - alas they don't seem to work in

How do I make Ruby 1.9 the default Ruby on Ubuntu?

倾然丶 夕夏残阳落幕 提交于 2019-11-26 18:59:01
问题 Is there any way, on Ubuntu 9.04, to install Ruby 1.8 as ruby1.8 (or get rid of it altogether) and have Ruby 1.9 be the default ruby ? 回答1: I'm not really sure, but maybe this can help: update-alternatives --config ruby ... and here's the non-interactive, scriptable, way: update-alternatives --set ruby /usr/bin/ruby1.9.1 You may find out about available alternatives and respective /usr/bin/... paths by doing: update-alternatives --query ruby 回答2: Martin - Take a look at the following link:

invalid multibyte char (US-ASCII) with Rails and Ruby 1.9

三世轮回 提交于 2019-11-26 18:03:58
I'm using Ruby 1.9.1 with Rails 2.3.4 My application is to handle text input If I try something like (the inside quotation marks look different) text = "”“" I get the following error: #<SyntaxError: /Users/tammam56/rubydev/favquote/lib/daemons/twitter_quotes_fetch.rb:54: invalid multibyte char (US-ASCII) /Users/tammam56/rubydev/favquote/lib/daemons/twitter_quotes_fetch.rb:54: invalid multibyte char (US-ASCII) /Users/tammam56/rubydev/favquote/lib/daemons/twitter_quotes_fetch.rb:54: syntax error, unexpected $end, expecting keyword_end I need to user those quotation marks as users might input

What are the benefits of the new hash syntax in Ruby 1.9?

萝らか妹 提交于 2019-11-26 17:23:06
问题 Apart from making it sightly more concise for defining hashes with symbols as keys, are there any other benefits of writing a hash as: {key1: "value1", key2: "value2"} instead of {:key1 => "value1", :key2 => "value2"} ? Also, what is the convention when you have a mix of strings and symbols as hash keys? Do you write it as {"key1" => "value1", key2: "value2"} or keep the style consistant as {"key1" => "value1", :key => "value2"} 回答1: It just looks nicer--it's syntactic sugar; it ends up being

Is Hash Rocket deprecated?

半腔热情 提交于 2019-11-26 15:07:43
The well-cited RIP Hash rocket post would seem to imply the Hash Rocket syntax ( :foo => "bar" ) is deprecated in favor of the new-to-Ruby JSON-style hash ( foo: "bar" ), but I can't find any definitive reference stating the Hash Rocket form is actually deprecated/unadvised as of Ruby 1.9. The author of that blog post is being overly dramatic and foolish, the => is still quite necessary . In particular: You must use the rocket for symbols that require quoting: :'where.is' => x is valid but 'where.is': x is not. Ruby 2.2 has fixed this problem so you can say 'where.is': x in Ruby 2.2+. You must

Set global default encoding for ruby 1.9

China☆狼群 提交于 2019-11-26 11:24:00
问题 I want to tell ruby that everything is utf8, except when stated otherwise, so I dont have to place these # encoding: utf-8 comments everywhere. 回答1: You can either: set your RUBYOPT environment variable to "-E utf-8" or use https://github.com/m-ryan/magic_encoding 回答2: If you're using environment variables, the general way is to use LC_ALL / LANG Neither is set : fallback to US-ASCII $ LC_ALL= LANG= ruby -e 'p Encoding.default_external' #<Encoding:US-ASCII> Either is set : that value is used

Ruby 1.9 Array.to_s behaves differently?

浪子不回头ぞ 提交于 2019-11-26 09:56:08
问题 i wrote a quick little application that takes a base file of code with some keywords, a file of replacements for the keywords, and outputs a new file with the keywords replaced. When i was using Ruby 1.8, my outputs would look fine. Now when using Ruby 1.9, my replaced code has the newline characters in it instead of line feeds. For example, i see something like: [\"\\r\\nDim RunningNormal_1 As Boolean\", \"\\r\\nDim RunningNormal_2 As Boolean\", \"\\r\\nDim RunningNormal_3 As Boolean\"]

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