[#383997] CORE - Alternative Variable Substitution — Ilias Lazaridis <ilias@...>

ruby 1.9

21 messages 2011/06/01

[#384051] CORE - Replace "if __FILE__ == $0" with "executed?" — Ilias Lazaridis <ilias@...>

The construct to detect execution of the file (in order to launch main

12 messages 2011/06/02

[#384104] CORE - Altering Behaviour of "each do" (default param "item") — Ilias Lazaridis <ilias@...>

1.9

76 messages 2011/06/04
[#384111] Re: CORE - Altering Behaviour of "each do" (default param "item") — James Gray <james@...> 2011/06/04

On Sat, Jun 4, 2011 at 6:50 AM, Ilias Lazaridis <ilias@lazaridis.com> wrote:

[#384154] Re: CORE - Altering Behaviour of "each do" (default param "item") — Yukihiro Matsumoto <matz@...> 2011/06/05

Hi,

[#384168] Re: CORE - Altering Behaviour of "each do" (default param "item") — Ilias Lazaridis <ilias@...> 2011/06/06

On 6 撫, 01:11, Yukihiro Matsumoto <m...@ruby-lang.org> wrote:

[#384228] a little challenge - reproduce this error — Intransition <transfire@...>

Want to see a really amazing error I got this week? Okay... but to

24 messages 2011/06/08
[#384230] Re: a little challenge - reproduce this error — Steve Klabnik <steve@...> 2011/06/08

throw NameError.new("uninitialized constant X::Foo::X")

[#384231] Re: a little challenge - reproduce this error — John Feminella <johnf@...> 2011/06/08

This is a pretty trivial error to generate. Just reference the

[#384232] Re: a little challenge - reproduce this error — Intransition <transfire@...> 2011/06/08

[#384235] Re: a little challenge - reproduce this error — Christopher Dicely <cmdicely@...> 2011/06/08

On Wed, Jun 8, 2011 at 6:43 AM, Intransition <transfire@gmail.com> wrote:

[#384279] CORE - Literal Instantiation breaks Object Model — Ilias Lazaridis <ilias@...>

class String

14 messages 2011/06/09

[#384280] BARRIER - require "rubygems" — Ilias Lazaridis <ilias@...>

ruby 1.9.2p180 Windows 7

30 messages 2011/06/09

[#384283] Classic Computer Science Books — Stu <stu@...>

I wanted to start a thread discussion on classic computer science

38 messages 2011/06/09
[#384288] Re: Classic Computer Science Books — Josh Cheek <josh.cheek@...> 2011/06/10

On Thu, Jun 9, 2011 at 5:18 PM, Stu <stu@rubyprogrammer.net> wrote:

[#384289] Re: Classic Computer Science Books — Chad Perrin <code@...> 2011/06/10

On Fri, Jun 10, 2011 at 09:22:58AM +0900, Josh Cheek wrote:

[#384291] Re: Classic Computer Science Books — Stu <stu@...> 2011/06/10

Thank you for the responses. I look forward to reading others.

[#384346] Re: Classic Computer Science Books — Anurag Priyam <anurag08priyam@...> 2011/06/11

> queue to read Meyers C++ books and Crockford's Javascript: The Good

[#384349] Re: Classic Computer Science Books — Stu <stu@...> 2011/06/11

Hello Anurag

[#384430] Re: Classic Computer Science Books — Anurag Priyam <anurag08priyam@...> 2011/06/13

Hey Stu,

[#384464] Re: Classic Computer Science Books — Vin兤ius <undvinicius@...> 2011/06/14

Wow, those are a lot of books, as a beginner programmer, I don't have

[#384322] PSA: Ilias is Crazy — Ryan Davis <ryand-ruby@...>

I guess I have to post this periodically since our population is growing and changing so much.

18 messages 2011/06/10

[#384363] RFC - One word alias for require_relative — Ilias Lazaridis <ilias@...>

This is a simple Request for Comments.

161 messages 2011/06/11
[#384368] Re: RFC - One word alias for require_relative — Intransition <transfire@...> 2011/06/11

[#384654] Re: RFC - One word alias for require_relative — Ilias Lazaridis <ilias@...> 2011/06/17

On 11 撫, 20:35, Ilias Lazaridis <il...@lazaridis.com> wrote:

[#384676] Re: RFC - One word alias for require_relative — Yukihiro Matsumoto <matz@...> 2011/06/17

Hi,

[#384633] Re: RFC - One word alias for require_relative — Ilias Lazaridis <ilias@...> 2011/06/17

On 17 撫, 21:17, Gary Wright <gwtm...@mac.com> wrote:

[#384432] commit message conventions — Intransition <transfire@...>

When I write commit messages I add a "team" prefix to the message,

14 messages 2011/06/13
[#384433] Re: commit message conventions — John Feminella <johnf@...> 2011/06/13

I greatly dislike that style, to be frank. My commit messages usually

[#384467] A way to find out when a constant gets defined? — Josh Cheek <josh.cheek@...>

Hi, I'd like to be able to find out when a constant gets defined. I think I

14 messages 2011/06/14

[#384490] Messages to Ruby List/Forum/etc. not arriving equally? — Markus Fischer <markus@...>

Hi,

11 messages 2011/06/15

[#384500] CORE - Inconsistent Handling of Uninitialized Variables — Ilias Lazaridis <ilias@...>

puts "\n== Testin in MAIN Context =="

18 messages 2011/06/15

[#384617] get execution name of program — Chad Perrin <code@...>

Either $0 or __FILE__ will return a filename to give context for how a

13 messages 2011/06/17

[#384634] default config file location — Chad Perrin <code@...>

Is there a "better" way to specify a default config file location than

16 messages 2011/06/17
[#384637] Re: default config file location — "Matthew K. Williams" <matt@...> 2011/06/17

On Sat, 18 Jun 2011, Chad Perrin wrote:

[#384648] celluloid 0.0.3: a concurrent object framework for Ruby — Tony Arcieri <tony.arcieri@...>

Celluloid is a concurrent object framework for Ruby inspired by Erlang

12 messages 2011/06/17

[#384763] MIDASWAD - Matz is Dumb and so We are Dumb — Ilias Lazaridis <ilias@...>

(public draft)

46 messages 2011/06/20
[#384765] Re: MIDASWAD - Matz is Dumb and so We are Dumb — Chad Perrin <code@...> 2011/06/20

Before anyone engages this nonsense . . .

[#384772] Re: MIDASWAD - Matz is Dumb and so We are Dumb — Adam Prescott <adam@...> 2011/06/20

On 20 Jun 2011 20:32, "Chad Perrin" <code@apotheon.net> wrote:

[#384774] Re: MIDASWAD - Matz is Dumb and so We are Dumb — Sam Duncan <sduncan@...> 2011/06/20

Five posts in on this thread, and four of them are the self appointed

[#384779] Re: MIDASWAD - Matz is Dumb and so We are Dumb — David Masover <ninja@...> 2011/06/20

A quick, lazy response, because I shouldn't feed trolls anyway, and I simply

[#384788] Re: MIDASWAD - Matz is Dumb and so We are Dumb — Nikolai Weibull <now@...> 2011/06/21

On Mon, Jun 20, 2011 at 23:52, David Masover <ninja@slaphack.com> wrote:

[#384790] Re: MIDASWAD - Matz is Dumb and so We are Dumb — Adam Prescott <adam@...> 2011/06/21

On Tue, Jun 21, 2011 at 11:06 AM, Nikolai Weibull <now@bitwi.se> wrote:

[#384792] Re: MIDASWAD - Matz is Dumb and so We are Dumb — Nikolai Weibull <now@...> 2011/06/21

On Tue, Jun 21, 2011 at 13:37, Adam Prescott <adam@aprescott.com> wrote:

[#384800] How to order a hash based on its keys? — Iñaki Baz Castillo <ibc@...>

Hi, I want to order a hash using itds keys:

35 messages 2011/06/21
[#384808] Re: How to order a hash based on its keys? — Robert Klemme <shortcutter@...> 2011/06/21

On Tue, Jun 21, 2011 at 4:34 PM, Iki Baz Castillo <ibc@aliax.net> wrote:

[#384813] Re: How to order a hash based on its keys? — Iñaki Baz Castillo <ibc@...> 2011/06/21

2011/6/21 Robert Klemme <shortcutter@googlemail.com>:

[#384814] Re: How to order a hash based on its keys? — Iñaki Baz Castillo <ibc@...> 2011/06/21

2011/6/21 Iñaki Baz Castillo <ibc@aliax.net>:

[#384833] Re: How to order a hash based on its keys? — Robert Klemme <shortcutter@...> 2011/06/22

On Tue, Jun 21, 2011 at 6:34 PM, Iki Baz Castillo <ibc@aliax.net> wrote:

[#384837] Re: How to order a hash based on its keys? — Iñaki Baz Castillo <ibc@...> 2011/06/22

2011/6/22 Robert Klemme <shortcutter@googlemail.com>:

[#384843] Re: How to order a hash based on its keys? — Robert Klemme <shortcutter@...> 2011/06/22

On Wed, Jun 22, 2011 at 11:50 AM, Iki Baz Castillo <ibc@aliax.net> wrote:

[#384846] Re: How to order a hash based on its keys? — Iñaki Baz Castillo <ibc@...> 2011/06/22

2011/6/22 Robert Klemme <shortcutter@googlemail.com>:

[#384847] Re: How to order a hash based on its keys? — Robert Klemme <shortcutter@...> 2011/06/22

On Wed, Jun 22, 2011 at 3:47 PM, Iki Baz Castillo <ibc@aliax.net> wrote:

[#384849] Re: How to order a hash based on its keys? — Iñaki Baz Castillo <ibc@...> 2011/06/22

2011/6/22 Robert Klemme <shortcutter@googlemail.com>:

[#384855] Re: How to order a hash based on its keys? — Robert Klemme <shortcutter@...> 2011/06/22

On Wed, Jun 22, 2011 at 4:19 PM, Iki Baz Castillo <ibc@aliax.net> wrote:

[#384819] Gateway Shutting Down — James Gray <james@...>

Rubyists:

12 messages 2011/06/21

[#384873] Explicitly setting compiler to C++ in extconf.rb... — "Darryl L. Pierce" <mcpierce@...>

I'm trying to setup a Ruby gem that bundles the Swig-generated bindings

10 messages 2011/06/23

[#384907] SPDX (and the glazing of ones eyes) — Intransition <transfire@...>

Never ceases to amaze me how complicated "enterprisey" peoples can

17 messages 2011/06/25
[#384909] Re: SPDX (and the glazing of ones eyes) — Phillip Gawlowski <cmdjackryan@...> 2011/06/25

On Sat, Jun 25, 2011 at 5:00 PM, Intransition <transfire@gmail.com> wrote:

[#384996] A movie Renamer — Mayank Kohaley <mayank.kohaley@...>

Hello Guys,

20 messages 2011/06/29
[#385007] Re: A movie Renamer — Sam Duncan <sduncan@...> 2011/06/29

Please don't steal movies.

[#385010] Re: A movie Renamer — Chad Perrin <code@...> 2011/06/29

On Thu, Jun 30, 2011 at 06:17:55AM +0900, Sam Duncan wrote:

[#385011] Re: A movie Renamer — Sam Duncan <sduncan@...> 2011/06/29

*sigh*

[#385019] A File Renamer — Mayank Kohaley <mayank.kohaley@...>

I guess this thread has spawned another issue. Let me close this and say I

18 messages 2011/06/30
[#385021] Re: A File Renamer — Jeremy Heiler <jeremyheiler@...> 2011/06/30

On Thu, Jun 30, 2011 at 1:48 AM, Mayank Kohaley

[#385027] Re: A File Renamer — Johnny Morrice <spoon@...> 2011/06/30

> Is there a pattern to the file names you are working with? The key is

Re: What about Object#to_ruby ?

From: Bernard Lambeau <blambeau@...>
Date: 2011-06-20 18:02:29 UTC
List: ruby-talk #384758
Thanks a lot for your responses. I suspect that my question was not that
clear, though.

I'm not really looking or Marshal or YAML or JSON dump format, but for a
method
to print a ruby *literal* (I should have called it to_ruby_literal) from a
ruby value,
where it makes sense. The goal is to ease human-readable ruby code
generation,
I must add. Nowadays, using inspect works for all but a few basic values:

blambeau@kali:~$ irb -r time to_ruby_literal.rb
ruby-1.8.7-p334 :001 > eval(true.inspect)
 => true
ruby-1.8.7-p334 :002 > eval(1.inspect)
 => 1
ruby-1.8.7-p334 :003 > eval(1.0.inspect)
 => 1.0
ruby-1.8.7-p334 :004 > eval(nil.inspect)
 => nil
ruby-1.8.7-p334 :005 > eval("O'Neil".inspect)
 => "O'Neil"
ruby-1.8.7-p334 :006 > eval('O " Dude'.inspect)
 => "O \" Dude"
ruby-1.8.7-p334 :007 > eval([1, 2, 3].inspect)
 => [1, 2, 3]
ruby-1.8.7-p334 :008 > eval({:hello => "world"}.inspect)
 => {:hello=>"world"}
ruby-1.8.7-p334 :009 > eval(/[a-z]*/.inspect)
 => /[a-z]*/
ruby-1.8.7-p334 :010 > eval((1.0/0).inspect)
NameError: (eval):1:in `irb_binding': uninitialized constant Infinity
from to_ruby_literal.rb:10
from to_ruby_literal.rb:10
ruby-1.8.7-p334 :011 > eval(Time.now.inspect)
SyntaxError: (eval):1:in `irb_binding': compile error
(eval):1: syntax error, unexpected tINTEGER, expecting $end
Mon Jun 20 20:01:19 +0200 2011
             ^
from to_ruby_literal.rb:11
from to_ruby_literal.rb:11

Bernard

On Mon, Jun 20, 2011 at 7:37 PM, Josh Cheek <josh.cheek@gmail.com> wrote:

> On Mon, Jun 20, 2011 at 7:40 AM, Bernard Lambeau <blambeau@gmail.com>
> wrote:
>
> > Hi!
> >
> > It's not the first time that I need a to_ruby method which would
> guarantee
> > the following invariant:
> >
> >  Kernel.eval(foo.to_ruby) == foo
> >
> > It actually works when using inspect with most basic objects (Integer,
> > String,
> > True & FalseClass, etc.), without actually being the specification of
> > inspect.
> >
> > I admit that such a feature probably only makes sense for classes that
> > actually
> > capture datatypes, whose instances are then true values.
> >
> > Does anyone know a gem that provides such a feature? To your knowledge,
> > would to_ruby be a conflicting name with existing gems in the ecosystem
> > or future plans for ruby itself?
> >
> > Just in case you ask yourself whether this feature is needed, have a look
> > at rubygems itself:
> >
> >
> https://github.com/rubygems/rubygems/blob/master/lib/rubygems/specification.rb#L1899-1915
> >
> > Thanks for any suggestion,
> > Bernard
> >
> > --
> > PhD Student, Computer Science Department, EPL/INGI, UCLouvain, Belgium
> > Mail:    blambeau@gmail.com
> > Mobile:  +32 477 24 58 61
> > Blog:    http://revision-zero.org/
> > Code:    http://github.com/blambeau/
> > Follow:  http://twitter.com/blambeau/
> >
>
> # I think the following works for everything except data that contains code
> itself (closures / methods)
>
> Datum = Struct.new :some_attribute
>
> data = [
>  Datum.new("string"),
>  Datum.new(1234),
>  Datum.new(/regex/),
> ]
>
>
> serial = Marshal.dump data
> serial                        # =>
>
> "\x04\b[\bS:\nDatum\x06:\x13some_attributeI\"\vstring\x06:\x06ETS;\x00\x06;\x06i\x02\xD2\x04S;\x00\x06;\x06I/\nregex\x00\x06;\aF"
> Marshal.load(serial) == data  # => true
>
> require 'yaml'
> serial = YAML.dump data
> serial                        # => "--- \n- !ruby/struct:Datum \n
>  some_attribute: string\n- !ruby/struct:Datum \n  some_attribute: 1234\n-
> !ruby/struct:Datum \n  some_attribute: !ruby/regexp /regex/\n"
> YAML.load(serial) == data     # => true
>
> ---
>
> I think the closest things that exist right now that would be able to do
> this for closures as well, would be some of Ryan Davis' tools (last I
> heard,
> they don't work on 1.9, though):
> https://rubygems.org/gems/ruby2ruby
> https://rubygems.org/gems/ruby_parser
> https://rubygems.org/gems/sexp_processor
>
> Rubinius might also be able to do something like this.
>
>
> On Mon, Jun 20, 2011 at 12:20 PM, Steve Klabnik <steve@steveklabnik.com
> >wrote:
>
> > I believe pry has this kind of thing: https://github.com/banister/pry
> >
> > From its readme:
> >
> > pry(Pry):1> show-method rep -l
> >
> > From: /home/john/ruby/projects/pry/lib/pry/pry_instance.rb @ line 143:
> > Number of lines: 6
> >
> > 143: def rep(target=TOPLEVEL_BINDING)
> > 144:   target = Pry.binding_for(target)
> > 145:   result = re(target)
> > 146:
> > 147:   show_result(result) if should_print?
> > 148: end
> >
>
> I'm admittedly uninformed, but I think they do this by keeping track of
> where methods get defined, then opening that file and reading that
> definition (as opposed to introspecting on the object itself) in the
> example
> above, for instance, they also report the file and line numbers of the rep
> method.
>



-- 
PhD Student, Computer Science Department, EPL/INGI, UCLouvain, Belgium
Mail:    blambeau@gmail.com
Mobile:  +32 477 24 58 61
Blog:    http://revision-zero.org/
Code:    http://github.com/blambeau/
Follow:  http://twitter.com/blambeau/

In This Thread