[#34033] The rights of ruby-core people and Myth of ruby-dev — "NARUSE, Yui" <naruse@...>

Some of you may don't know your rights.

32 messages 2011/01/03
[#34067] Re: The rights of ruby-core people and Myth of ruby-dev — Aaron Patterson <aaron@...> 2011/01/04

On Tue, Jan 04, 2011 at 06:55:47AM +0900, NARUSE, Yui wrote:

[#34043] proposal: gem_prelude needs to die — Ryan Davis <ryand-ruby@...>

I think it is time for gem_prelude to die.

21 messages 2011/01/04
[#34077] Re: proposal: gem_prelude needs to die — Tanaka Akira <akr@...> 2011/01/05

2011/1/4 Ryan Davis <ryand-ruby@zenspider.com>:

[#34091] Moving to Git? — Lucas Nussbaum <lucas@...>

Hi,

87 messages 2011/01/05
[#34099] Re: Moving to Git? — KOSAKI Motohiro <kosaki.motohiro@...> 2011/01/05

> Hi,

[#34103] Re: Moving to Git? — "U.Nakamura" <usa@...> 2011/01/05

Hello,

[#34105] Re: Moving to Git? — Rodrigo Rosenfeld Rosas <rr.rosas@...> 2011/01/05

Em 05-01-2011 13:15, U.Nakamura escreveu:

[#34106] Re: Moving to Git? — "NARUSE, Yui" <naruse@...> 2011/01/05

(2011/01/06 0:46), Rodrigo Rosenfeld Rosas wrote:

[#34112] Re: Moving to Git? — Jon <jon.forums@...> 2011/01/05

> > Well, I guess I can help listing some advantages. Using git:

[#34118] Re: Moving to Git? — mathew <meta@...> 2011/01/05

On Wed, Jan 5, 2011 at 11:28, Jon <jon.forums@gmail.com> wrote:

[#34121] Re: Moving to Git? — Rodrigo Rosenfeld Rosas <rr.rosas@...> 2011/01/05

Em 05-01-2011 17:16, mathew escreveu:

[#34129] Re: Moving to Git? — mathew <meta@...> 2011/01/05

On Wed, Jan 5, 2011 at 13:23, Rodrigo Rosenfeld Rosas

[#34138] Re: Moving to Git? — Czarek <cezary.baginski@...> 2011/01/05

On Thu, Jan 06, 2011 at 06:50:24AM +0900, mathew wrote:

[#34188] Re: Moving to Git? — mathew <meta@...> 2011/01/06

On Wed, Jan 5, 2011 at 17:02, Czarek <cezary.baginski@gmail.com> wrote:

[#34191] Re: Moving to Git? — Lucas Nussbaum <lucas@...> 2011/01/06

On 07/01/11 at 01:05 +0900, mathew wrote:

[#34201] Re: Moving to Git? — mathew <meta@...> 2011/01/06

On Thu, Jan 6, 2011 at 10:36, Lucas Nussbaum <lucas@lucas-nussbaum.net> wrote:

[#34206] Re: Moving to Git? — Lucas Nussbaum <lucas@...> 2011/01/07

On 07/01/11 at 08:07 +0900, mathew wrote:

[#34227] Re: Moving to Git? — mathew <meta@...> 2011/01/07

On Thu, Jan 6, 2011 at 23:50, Lucas Nussbaum <lucas@lucas-nussbaum.net> wrote:

[#34231] Re: Moving to Git? — Daniel Bovensiepen <bovensiepen@...> 2011/01/07

Dear all,

[#34116] Re: Moving to Git? — Yukihiro Matsumoto <matz@...> 2011/01/05

Hi,

[#34117] Re: Moving to Git? — Rodrigo Rosenfeld Rosas <rr.rosas@...> 2011/01/05

What kind of Redmine integration you are talking about? We use Redmine

[#34120] Re: Moving to Git? — Yukihiro Matsumoto <matz@...> 2011/01/05

Hi,

[#34125] Re: Moving to Git? — Nikolai Weibull <now@...> 2011/01/05

On Wed, Jan 5, 2011 at 19:57, Yukihiro Matsumoto <matz@ruby-lang.org> wrote:

[#34124] [Ruby 1.9-Bug#4235][Open] svn keywords in code prevent correct building of ruby using git mirror — Stephen Bannasch <redmine@...>

Bug #4235: svn keywords in code prevent correct building of ruby using git mirror

12 messages 2011/01/05

[#34171] [Ruby 1.8-Feature#4239][Open] Let's begin a talk for "1.8.8" -- How's needed for surviving 1.8? — Shota Fukumori <redmine@...>

Feature #4239: Let's begin a talk for "1.8.8" -- How's needed for surviving 1.8?

104 messages 2011/01/06
[#34514] [Ruby 1.8-Feature#4239] Let's begin a talk for "1.8.8" -- How's needed for surviving 1.8? — Zeno Davatz <redmine@...> 2011/01/15

Issue #4239 has been updated by Zeno Davatz.

[#34516] Re: [Ruby 1.8-Feature#4239] Let's begin a talk for "1.8.8" -- How's needed for surviving 1.8? — "NARUSE, Yui" <naruse@...> 2011/01/15

(2011/01/16 0:11), Zeno Davatz wrote:

[#34214] [Ruby 1.9-Feature#4247][Open] New features for Array#sample, Array#choice — Yoji Ojima <redmine@...>

Feature #4247: New features for Array#sample, Array#choice

10 messages 2011/01/07

[#34267] [Ruby 1.9-Feature#4254][Open] Allow method transplanting — Jonas Pfenniger <redmine@...>

Feature #4254: Allow method transplanting

23 messages 2011/01/09
[#34280] Re: [Ruby 1.9-Feature#4254][Open] Allow method transplanting — Yukihiro Matsumoto <matz@...> 2011/01/10

Hi,

[#34299] [Ruby 1.9-Bug#4256][Open] [BUG] Segmentation fault ruby 1.9.2p0 (2010-08-18) [i386-mingw32] — Rama Mahendravada <redmine@...>

Bug #4256: [BUG] Segmentation fault ruby 1.9.2p0 (2010-08-18) [i386-mingw32]

9 messages 2011/01/10

[#34318] ext/bigdecimal/lib/bigdecimal/util.rb — Aaron Patterson <aaron@...>

Hi Murata!

14 messages 2011/01/11
[#34321] Re: ext/bigdecimal/lib/bigdecimal/util.rb — Yukihiro Matsumoto <matz@...> 2011/01/11

Hi,

[#34354] [Ruby 1.9-Feature#4264][Open] General type coercion protocol for Ruby — Charles Nutter <redmine@...>

Feature #4264: General type coercion protocol for Ruby

33 messages 2011/01/11
[#34359] Re: [Ruby 1.9-Feature#4264][Open] General type coercion protocol for Ruby — Jim Weirich <jim.weirich@...> 2011/01/11

[#34355] [Ruby 1.9-Feature#4265][Open] Provide a core method Kernel#ruby for invoking a new Ruby instance — Charles Nutter <redmine@...>

Feature #4265: Provide a core method Kernel#ruby for invoking a new Ruby instance

15 messages 2011/01/11

[#34362] [Ruby 1.9-Bug#4266][Open] Timeouts in threads cause "ThreadError: deadlock; recursive locking" — Christopher Bottaro <redmine@...>

Bug #4266: Timeouts in threads cause "ThreadError: deadlock; recursive locking"

12 messages 2011/01/11

[#34399] [Ruby 1.9-Bug#4272][Open] rb_enc_str_new() causes segmentfault when using threads in parallel — Iñaki Baz Castillo <redmine@...>

Bug #4272: rb_enc_str_new() causes segmentfault when using threads in parallel

14 messages 2011/01/12

[#34534] [Ruby 1.9-Bug#4283][Open] Timeout.timeout may cause application exit unintetionally — Motohiro KOSAKI <redmine@...>

Bug #4283: Timeout.timeout may cause application exit unintetionally

11 messages 2011/01/17

[#34537] [Ruby 1.9-Bug#4285][Open] Ruby don't have asynchrounous exception safe syntax and It should have. — Motohiro KOSAKI <redmine@...>

Bug #4285: Ruby don't have asynchrounous exception safe syntax and It should have.

12 messages 2011/01/17

[#34550] [Ruby 1.9-Feature#4288][Open] Allow invoking arbitrary method names with foo."something" syntax — Charles Nutter <redmine@...>

Feature #4288: Allow invoking arbitrary method names with foo."something" syntax

13 messages 2011/01/18
[#34616] Re: [Ruby 1.9-Feature#4288][Open] Allow invoking arbitrary method names with foo."something" syntax — Gary Wright <gwtmp01@...> 2011/01/19

[#34577] Importing rubygems 1.5.0 (release candidate) into trunk. — Ryan Davis <ryand-ruby@...>

I'm going to be committing rubygems 1.5.0 into trunk in a bit.

13 messages 2011/01/18

[#34632] Ruby operator equivalent to Groovy's "?." — Rodrigo Rosenfeld Rosas <rr.rosas@...>

One of the few things I like in Groovy that Ruby doesn't support is

19 messages 2011/01/20

[#34634] Returning from the callee — Rodrigo Rosenfeld Rosas <rr.rosas@...>

Sometimes it is useful to be able to return from the callee method.

15 messages 2011/01/20

[#34648] [Ruby 1.9-Bug#4298][Open] Duration of calling String#[] with the same index is strangely related to string length. — Radosław Bułat <redmine@...>

Bug #4298: Duration of calling String#[] with the same index is strangely related to string length.

13 messages 2011/01/20

[#34861] [Ruby 1.9-Feature#4326][Open] Fiber should respond to call() and [] — Aaron Patterson <redmine@...>

Feature #4326: Fiber should respond to call() and []

21 messages 2011/01/26
[#34943] [Ruby 1.9-Feature#4326] Fiber should respond to call() and [] — Charles Nutter <redmine@...> 2011/01/28

Issue #4326 has been updated by Charles Nutter.

[#34954] Re: [Ruby 1.9-Feature#4326] Fiber should respond to call() and [] — Aaron Patterson <aaron@...> 2011/01/28

On Sat, Jan 29, 2011 at 02:58:46AM +0900, Charles Nutter wrote:

[#34957] Re: [Ruby 1.9-Feature#4326] Fiber should respond to call() and [] — Charles Oliver Nutter <headius@...> 2011/01/29

On Fri, Jan 28, 2011 at 5:29 PM, Aaron Patterson

[#34869] make ruby support line continuations ? — Marc Chantreux <khatar@...>

hello,

22 messages 2011/01/26
[#34878] Re: make ruby support line continuations ? — Jim Freeze <jimfreeze@...> 2011/01/26

> I love it so much i tried it in ruby. trying to rewrite:

[#34887] Re: make ruby support line continuations ? — Marc Chantreux <khatar@...> 2011/01/27

hello,

[#34889] Re: make ruby support line continuations ? — V咜 Ondruch <v.ondruch@...> 2011/01/27

Dne 27.1.2011 7:15, Marc Chantreux napsal(a):

[#34911] The ruby-lang.org downloads page should include RVM for OS X — Andrew Vos <andrew.vos@...>

(I sent this before I subscribed and I'm not sure if it bounced. Sorry if

21 messages 2011/01/27
[#34912] Re: The ruby-lang.org downloads page should include RVM for OS X — "Shota Fukumori (sora_h)" <sorah@...> 2011/01/27

RVM is not official, and makes problem more difficult. (magically

[#34913] Re: The ruby-lang.org downloads page should include RVM for OS X — Andrew Vos <andrew.vos@...> 2011/01/27

What do you mean by "official"? Also, what does it make more difficult? Do

[#34914] Re: The ruby-lang.org downloads page should include RVM for OS X — "Shota Fukumori (sora_h)" <sorah@...> 2011/01/27

return mail is gmail thing. I have same problem.

[#34970] [Ruby 1.9-Bug#4343][Open] Dir.glob does match files without extension — Vit Ondruch <redmine@...>

Bug #4343: Dir.glob does match files without extension

26 messages 2011/01/29
[#34975] [Ruby 1.9-Bug#4343] Dir.glob does match files without extension — Nobuyoshi Nakada <redmine@...> 2011/01/29

Issue #4343 has been updated by Nobuyoshi Nakada.

[#34978] Re: [Ruby 1.9-Bug#4343] Dir.glob does match files without extension — Jeremy Bopp <jeremy@...> 2011/01/29

On 01/29/2011 10:19 AM, Nobuyoshi Nakada wrote:

[#34979] Re: [Ruby 1.9-Bug#4343] Dir.glob does match files without extension — Vít Ondruch <v.ondruch@...> 2011/01/29

Dne 29.1.2011 17:27, Jeremy Bopp napsal(a):

[#34981] Re: [Ruby 1.9-Bug#4343] Dir.glob does match files without extension — Jeremy Bopp <jeremy@...> 2011/01/29

On 01/29/2011 10:33 AM, Vテュt Ondruch wrote:

[#34982] Re: [Ruby 1.9-Bug#4343] Dir.glob does match files without extension — Vít Ondruch <v.ondruch@...> 2011/01/29

Dne 29.1.2011 17:53, Jeremy Bopp napsal(a):

[ruby-core:34430] [Ruby 1.9-Feature#4264] General type coercion protocol for Ruby

From: Jonas Pfenniger <redmine@...>
Date: 2011-01-12 13:01:43 UTC
List: ruby-core #34430
Issue #4264 has been updated by Jonas Pfenniger.

File typecast.rb added

I have this version from 2004 that is lying around that does approximately the same. It was included in the factets gem but got pulled out at some time. It uses #cast_to and #cast_from as the methods of coercion. Each conversion is defined as a method either on the instance of the object that calls #cast_to (#cast_to_#{target_class}), or on the target class as #cast_from_#{origin_klass}. I'm not totally happy about it, since it has a strong dependence on the class name, which means that inheriting classes cannot inherit the conversion mechanisms.
----------------------------------------
http://redmine.ruby-lang.org/issues/show/4264

----------------------------------------
http://redmine.ruby-lang.org

Attachments (1)

typecast.rb (6.15 KB, text/x-ruby-script)
###
#   Copyright 2010 STVS SA <stvs@stvs.ch>
###
# = typecast.rb
#
# == Copyright (c) 2004 Jonas Pfenniger
#
#   Ruby License
#
#   This module is free software. You may use, modify, and/or redistribute this
#   software under the same terms as Ruby.
#
#   This program is distributed in the hope that it will be useful, but WITHOUT
#   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
#   FOR A PARTICULAR PURPOSE.
#
# == Author(s)
#
# * Jonas Pfenniger
#
# == Changelog
#
# 06.06.2006 - 3v1l d4y
#
#  * Removed transformation options.
#  * Removed StringIO typecast. It is not required by default.
#  * Added TypeCastException for better error reporting while coding.
#
# == Developer Notes
#
#   TODO Consider how this might fit in with method signitures, overloading,
#        and expiremental euphoria-like type system.
#
#   TODO Look to implement to_int, to_mailtext, to_r, to_rfc822text and to_str.


# Author::    Jonas Pfenniger
# Copyright:: Copyright (c) 2004 Jonas Pfenniger
# License::   Ruby License

require 'time'

#require 'alt/str_reflection'
class String
  def methodize
    to_s.gsub(/([A-Z])/, '_\1').downcase.gsub(/^_/,'').gsub(/(::|\/)_?/, '__')
  end
  
  def modulize
    to_s.gsub(/(__|\/)(.?)/){ "::" + $2.upcase }.gsub(/(^|_)(.)/){ $2.upcase }
  end
end

# = TypeCast
#
# Provides a generic simple type conversion utility. All the ruby core
# conversions are available by default.
#
# To implement a new type conversion, you have two choices :
#
# Take :
#
#  class CustomType
#    def initialize(my_var)
#      @my_var = my_var
#    end
#  end
#
# * Define a to_class_name instance method
#
#  class CustomType
#    def to_string
#      my_var.to_s
#    end
#  end
#
#  c = CustomType.new 1234
#  s.cast_to String   =>  "1234" (String)
#
# * Define a from_class_name class method
#
#  class CustomType
#    def self.from_string(str)
#      self.new(str)
#    end
#  end
#
#  "1234".cast_to CustomType  =>  #<CustomType:0xb7d1958c @my_var="1234">
#
#
# Those two methods are equivalent in the result. It was coded like that to
# avoid the pollution of core classes with tons of to_* methods.
#
# The standard methods to_s, to_f, to_i, to_a and to_sym are also used by
# this system if available.
#
# == Usage
#
#  "1234".cast_to Float     => 1234.0  (Float)
#  Time.cast_from("6:30")   => 1234.0   (Time)
#
# == FAQ
#
# Why didn't you name the `cast_to` method to `to` ?
#
#   Even if it would make the syntax more friendly, I suspect it could cause
#   a lot of collisions with already existing code. The goal is that each
#   time you call cast_to, you either get your result, either a
#   TypeCastException
#

class TypeCastException < Exception; end

#

class Object

  # class TypeCastException < Exception; end

  # Cast an object to another
  #
  #    1234.cast_to(String)  => "1234"
  #
  def cast_to(klass)
    klass.cast_from(self)
  end

  # Cast on object from another
  #
  #   String.cast_from(1234) => "1234"
  #
  def cast_from(object)
    method_to = "to_#{self.name.methodize}".to_sym
    if object.respond_to? method_to
      return object.send(method_to)
    end

    method_from = "from_#{object.class.name.methodize}".to_sym
    if respond_to? method_from
      return send(method_from, object)
    end

    raise TypeCastException, "TypeCasting from #{object.class.name} to #{self.name} not supported"
  end
end

# Extend the ruby core

class Array
  class << self
    def cast_from(object)
      return super
    rescue TypeCastException
      return object.to_a if object.respond_to? :to_a
      raise
    end
  end
end

class Float
  class << self
    def cast_from(object)
      return super
    rescue TypeCastException
      return object.to_f if object.respond_to? :to_f
      raise
    end
  end
end

class Integer
  class << self
    def cast_from(object)
      return super
    rescue TypeCastException
      return object.to_i if object.respond_to? :to_i
      raise
    end
  end
end

class String
  class << self
    def cast_from(object)
      return super
    rescue TypeCastException
      return object.to_s if object.respond_to? :to_s
      raise
    end
  end
end

class Symbol
  class << self
    def cast_from(object)
      return super
    rescue TypeCastException
      return object.to_sym if object.respond_to? :to_sym
      raise
    end
  end
end

# Extensions

class Class
  class << self

    # "string".cast_to Class         #=> String

    def from_string(string)
      string = string.to_s.modulize
      base   = string.sub!(/^::/, '') ? Object : (self.kind_of?(Module) ? self : self.class )
      klass  = string.split(/::/).inject(base){ |mod, name| mod.const_get(name) }
      return klass if klass.kind_of? Class
      nil
    rescue
      nil
    end

    alias_method :from_symbol, :from_string

  end
end

class Time
  class << self
    def from_string(string, options={})
      parse(string)
    rescue
      nil
    end
  end
end


#  _____         _
# |_   _|__  ___| |_
#   | |/ _ \/ __| __|
#   | |  __/\__ \ |_
#   |_|\___||___/\__|
#
=begin test

  require 'test/unit'

  class TestClass
    attr_accessor :my_var
    def initialize(my_var); @my_var = my_var; end

    def to_string(options={})
      @my_var
    end

    class << self
      def from_string(string, options={})
        self.new( string )
      end
    end
  end

  class TC_TypeCast < Test::Unit::TestCase

    def setup
      @test_string = "this is a test"
      @test_class = TestClass.new(@test_string)
    end

    def test_to_string
      assert_equal( '1234', 1234.cast_to(String) )
    end

    def test_custom_to_string
      assert_equal( @test_string, @test_class.cast_to(String) )
    end

    def test_custom_from_string
      assert_equal( @test_class.my_var, @test_string.cast_to(TestClass).my_var )
    end

    def test_string_to_class
      assert_equal( Test::Unit::TestCase, "Test::Unit::TestCase".cast_to(Class) )
    end

    def test_string_to_time
      assert_equal( "Mon Oct 10 00:00:00 2005", "2005-10-10".cast_to(Time).strftime("%a %b %d %H:%M:%S %Y") )
    end

    def test_no_converter
      "sfddsf".cast_to( ::Regexp )
      assert(1+1==3, 'should not get here')
    rescue TypeCastException => ex
      assert_equal(TypeCastException, ex.class)
    end
  end

=end

In This Thread