[MacRuby-devel] macirb or not working with awesome_print

Matt Massicotte massicotte at apple.com
Wed Oct 6 09:25:58 PDT 2010


I wasn't clear at all, sorry.  I can't get *automatic* formatting to work.  My .irbrc file looks like this:

require "rubygems"
require "ap"

unless Kernel.respond_to?(:framework) #admitted ugly hack
  require 'irb/completion'
  
  IRB::Irb.class_eval do
    def output_value
      ap @context.last_value
    end
  end
  
end

This makes the default irb formatting us awesome_print.  I got this from the awesome_print github page.  If I move the class_eval statement out of the conditional, I get this:

matt$ macirb
/Users/matt/.irbrc:1:in `<main>': uninitialized constant IRB::Irb (NameError)
	from /usr/local/bin/macirb:13:in `block'
	from /usr/local/bin/macirb:9:in `block'
	from /usr/local/bin/macirb:3:in `<main>'

As an aside:
I have a ton of code that needs to run under both macruby and rubycocoa.  Due to the ObjC calling conventions and OSX module stuff, portability is kind of a pain.  I use the Kernel.respond_to?(:framework) construct often, but I welcome better suggestions.

Matt

On Oct 6, 2010, at 9:02 AM, Eloy Duran wrote:

> I did, in the email that you replied on. Could you please send some more info about what really happens?
> 
> Eloy
> 
> On Oct 6, 2010, at 5:49 PM, Matt Massicotte wrote:
> 
>> I didn't know about awesome_print, and it's kind of blown my mind.  The default irb formatting is great.  Only, I cannot get it to work in macirb.  It looks like the internals of IRB is completely different.
>> 
>> Has anyone had an luck with this?
>> 
>> Matt
>> 
>> On Oct 6, 2010, at 2:10 AM, Eloy Duran wrote:
>> 
>>> I verified that it does work:
>>> 
>>> sudo macgem install awesome_print
>>> Password:
>>> unknown: warning: ignoring alias
>>> Successfully installed awesome_print-0.2.1
>>> 1 gem installed
>>> 
>>> % cat ~/.irbrc
>>> require 'rubygems'
>>> require 'ap'
>>> 
>>> % macirb
>>> irb(main):001:0> data = [ false, 42, %w(forty two), { :now => Time.now, :class => Time.now.class, :distance => 42e42 } ]
>>> => [false, 42, ["forty", "two"], {:now=>2010-10-06 11:06:37 +0200, :class=>Time, :distance=>4.2e+43}]
>>> irb(main):002:0> ap data
>>> [
>>>     [0] false,
>>>     [1] 42,
>>>     [2] [
>>>         [0] "forty",
>>>         [1] "two"
>>>     ],
>>>     [3] {
>>>              :now => 2010-10-06 11:06:37 +0200,
>>>            :class => Time < NSDate,
>>>         :distance => 4.2e+43
>>>     }
>>> ]
>>> => nil
>>> 
>>> It’s probably, as Joshua has said, being installed with the wrong rubygems installation.
>>> 
>>> Eloy
>>> 
>>> On Oct 6, 2010, at 8:38 AM, Joshua Ballanco wrote:
>>> 
>>>> Hi Brad,
>>>> 
>>>> What's happening here is that the 'gem' command that ships with MacRuby is named 'macgem'. However, 'macirb' still looks at the same .irbrc file that the system 'irb' command does. So, if you've put in a require for awesome_print into your .irbrc, then 'macirb' will look for it but not find it.
>>>> 
>>>> Try running 'macgem install awesome_print' instead and let us know how it goes.
>>>> 
>>>> Cheers,
>>>> 
>>>> Josh
>>>> 
>>>> 
>>>> On Oct 5, 2010, at 10:29 PM, Brad Hutchins wrote:
>>>> 
>>>>> "DietRB" or "macirb" don't seem to be working after I install "gem awesome_print"
>>>>> 
>>>>> I have to "gem uninstall awesome_print" to get it to work.  
>>>>> 
>>>>> I am guessing DietRB may be the name of the IRB but it is still launches with "macirb"
>>>>> 
>>>>> 
>>>>> 
>>>>> localhost:Homebrew Brad$ rvm macruby
>>>>> 
>>>>> 
>>>>> localhost:Homebrew Brad$ macruby -v
>>>>> MacRuby 0.7 (ruby 1.9.2) [universal-darwin10.0, x86_64]
>>>>> localhost:Homebrew Brad$ DietRB
>>>>> -bash: DietRB: command not found
>>>>> 
>>>>> 
>>>>> localhost:Homebrew Brad$ macirb
>>>>> ap gem not found.  Try typing 'gem install awesome_print' to get super-fancy output.
>>>>> irb(main):001:0> exit
>>>>> 
>>>>> localhost:Homebrew Brad$ gem install awesome_print
>>>>> unknown: warning: ignoring alias
>>>>> Successfully installed awesome_print-0.2.1
>>>>> 1 gem installed
>>>>> localhost:Homebrew Brad$ macirb
>>>>> /Users/Brad/.irbrc:1:in `<main>': uninitialized constant IRB::Irb (NameError)
>>>>> 	from /usr/local/bin/macirb:13:in `block'
>>>>> 	from /usr/local/bin/macirb:9:in `block'
>>>>> 	from /usr/local/bin/macirb:3:in `<main>'
>>>>> 
>>>>> 	
>>>>> localhost:Homebrew Brad$ DietRB
>>>>> -bash: DietRB: command not found
>>>>> 
>>>>> 
>>>>> localhost:Homebrew Brad$ rvm list
>>>>> 
>>>>> rvm rubies
>>>>> 
>>>>>    jruby-1.5.2 [ x86_64-java ]
>>>>> => macruby-0.7 [ x86_64 ]
>>>>>    rbx-1.0.1-20100603 [ x86_64 ]
>>>>>    ruby-1.8.7-p302 [ x86_64 ]
>>>>>    ruby-1.9.2-p0 [ x86_64 ]
>>>>> 
>>>>> 
>>>>> localhost:Homebrew Brad$ gem uninstall awesome_print
>>>>> Successfully uninstalled awesome_print-0.2.1
>>>>> localhost:Homebrew Brad$ macirb
>>>>> ap gem not found.  Try typing 'gem install awesome_print' to get super-fancy output.
>>>>> irb(main):001:0> 
>>>>>  
>>>>> _______________________________________________
>>>>> MacRuby-devel mailing list
>>>>> MacRuby-devel at lists.macosforge.org
>>>>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>>>> 
>>>> _______________________________________________
>>>> MacRuby-devel mailing list
>>>> MacRuby-devel at lists.macosforge.org
>>>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>>> 
>>> _______________________________________________
>>> MacRuby-devel mailing list
>>> MacRuby-devel at lists.macosforge.org
>>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
>> 
>> _______________________________________________
>> MacRuby-devel mailing list
>> MacRuby-devel at lists.macosforge.org
>> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel
> 
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel at lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo.cgi/macruby-devel

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20101006/39284edf/attachment-0001.html>


More information about the MacRuby-devel mailing list