EzDevInfo.com

MacRuby

MacRuby is an implementation of Ruby 1.9 directly on top of Mac OS X core technologies such as the Objective-C runtime and garbage collector, the LLVM compiler infrastructure and the Foundation and ICU frameworks.

How can a nested class access a method in the outer class in Ruby?

def class A
  def a
    raise "hi" #can't be reached
  end

  class B
    def b
      a() #doesn't find method a.
    end
  end
end

I want to invoke a from b and raise the exception. How can I?


Source: (StackOverflow)

Getting source HTML from a WebView in Cocoa

I'm working on a OS X program where the user does some light WYSIWYG HTML editing in a WebView. Being new to programming with Cocoa and WebKit, I have absolutely no idea how to get selected text from a WebView - the intention being to take what the user selected, add HTML code (like div's or span's) around the text, and replace the selected text with the modified code. How can this be accomplished?

I'm currently programming this project with MacRuby, but I'd appreciate help from Objective-C programmers as well. Thank you!


Source: (StackOverflow)

Advertisements

Good resources to learn MacRuby [closed]

I do not know Ruby and I am interested to learn MacRuby.
What would you recommend as your best resource (books, blogs, sites)?
Found:http://www.macruby.org/

More info her from rubyconf.org Macruby talk


Source: (StackOverflow)

Can you use MacRuby to develop applications for the Mac App Store?

I have some basic familiarity with Objective-C, but prefer Ruby, so I'm thinking of playing around with MacRuby. Is it possible to use MacRuby to develop applications for the Mac App Store, or do I have to use Objective-C? (Note that I don't care so much about iOS/the iPhone and iPad store right now, just the Mac OS X app store.)


Source: (StackOverflow)

Using MacRuby for developing iPhone apps

I'm looking to build an iPhone app, but I don't have enough time to learn Objective-C. I already know Ruby and discovered MacRuby. Is it possible to build an iPhone app using MacRuby alone, without any knowledge of Objective-C?


Source: (StackOverflow)

Should I learn MacRuby or RubyCocoa [closed]

I am wanting to learn mac development with ruby but I'm not sure which one to go at. RubyCocoa has been around longer but I think MacRuby will beat it out in the long run..

Any suggestions??


Source: (StackOverflow)

Ruby gui for Desktop apps

After long hours googling around, I'm wondering if there really exists a maintained gui based on Ruby.

Here are the one I checked:

  • Shoes: I'm not feeling like I could create rock solid platform with it

  • Cocoa and MacRuby: no fresh news, almost no tutorial

  • Qt4Ruby: same as above

  • FxRuby has almost no update

  • ...

To be short, I've looked at all gui presented here but am not convinced...

So:

  • Am I unable to find the proper doc for Cocoa and Qt? (I'd like it to be the answer!)

  • Is there any strong community based on a maintained Ruby gui? (please say yes again!)


Source: (StackOverflow)

Getting started with MacRuby and Xcode 4.2

I recently thought of getting started with MacRuby. I've installed Xcode 4.2 and i've installed MacRuby, but apparently i am missing something. In every tutorial i found so far it says, that i have to choose "MacRuby Application" from the Xcode templates ... but there is no such entry available. I've tried with 0.10 and with a nightly released a few days ago.

I've had a look at where MacRuby installs it's stuff and i found templates for Xcode 3.0 ... do i have to use these templates and how do i import them to Xcode 4.2?

Before i am getting started i would also like to know, if it's somehow safe to start with MacRuby? At first sight i thought 'yes', because of the new MacRuby book available -- but there seems to be not much activity on the MacRuby website (last blog entry from march, last year?) ... which can in my experience be a sign that you should better not rely on something. Does MacRuby have a future?


Source: (StackOverflow)

Interface Builder not Seeing Outlets with MacRuby

I am trying to get a basic hello world application going using XCode and Interface Builder. However, in Interface Builder I can't see my outlets to wire things up with. I go to the connections tab of the objects inspector pane and it says "New Referencing Outlet".

I am wondering if my code is wrong. Here it is

class HelloWorldController 
    attr_accessor :hello_label, :hello_button, :hello

    def awakeFromNib 
        @hello = true
    end

    def changeLabel(sender) 
        if @hello
            @hello_label.stringValue = "Good Bye" 
            @hello_button.title = "Hello" 
            @hello = false
        else
            @hello_label.stringValue = "Hello World" 
            @hello_button.title = "Good Bye" 
            @hello = true
        end 
    end
end

As I understand it I should be able to see hello, hello_label, hello_button, and changeLabel, but I don't. I thought maybe I had a misspelling somewhere, but that doesn't seem to be it either. Here is a shot of the two interface builder windows.

alt text

Any help is appreciated. I think I am just overlooking something, but not sure.

UPDATE: I solved the problem by just re-installing OS X. I suspect there was a problem because X Code 4 was installed, no idea. However, it now works with a fresh install of OS X, X Code and MacRuby


Source: (StackOverflow)

Can't submit Mac app via xcode4 - Invalid Signature

I keep getting this error:

Invalid Signature - This error occurs when you have signed your app's installer incorrectly. There are two certs required for this process: the "3rd Party Mac Developer Application" cert and the "3rd Party Mac Developer Installer" cert. When signing your package, you need to ensure that you are using the Installer cert to sign your package. Ensure that you are specifying this cert when submitting your app via the Xcode Organizer or when running productbuild from the command line.

I've googled, and have followed instructions but to no avail.

I have:

Projects > targets > build > code signing > 3rd Party Mac Developer Application:

Then when I go to archive and it opens up Organizer I go to submit I select the '3rd Party Mac Installer' key. But it still fails :(

Do I need to do anything else? Like clean and then build first? (Build for what? Or just select build? - Although I've tried pretty much all of them first, and then archive).

If it's of relevance I am using MacRuby, and had to do this first to set it up for xcode deployment: http://redwoodapp.posterous.com/macruby-and-xcode-4-build-a-self-contained-ma

Any help appreciated - I'm tearing my hair out here :(


Source: (StackOverflow)

Code completion for MacRuby/PyObjC/RubyMotion

One of Xcode's most powerful features is it's Intellisense completion, which brings up a list of potential candidates as you type the name of a Foundation/Cocoa/UIKit API. I am very interested in MacRuby, PyObjC, or the more recent RubyMotion, however without code completion these tools seem like more trouble than they're worth.

Is there any code completion feature (not necessarily Intellisense) for any of the three technologies above, for any text editor (but preferably for Vim or Xcode)? Bonus points for an IDE solution which allows for building and running the application in a single command (like Xcode's Run button).

It's my understanding that Xcode 4 dropped support for MacRuby/PyObjC, so Intellisense is no longer available. Should I install Xcode 3 alongside Xcode 4 for the code completion? How is everyone else doing it (surely you guys use some form of code completion -- I can't believe anyone can remember all the classes in Foundation/Cocoa/UIKit)?


Source: (StackOverflow)

How to run shell commands from a Mac/MacRuby application?

I am trying to write a little MacRuby status bar application that runs a command from the command line and displays the output. I don't know how to do this. How can I do this from my Mac application?

Update: The other thing that it might need to do is ask for an administrator password. Sometimes when I run this script from the command line, it asks for my password. I don't know how I would prompt the user for their password (or embed the shell so they could type it directly).


Source: (StackOverflow)

Escaping Line-Returns/End-of-Line in ERB templates

I need to be able to format unprinted logic lines in ERB without affecting the eventual text output of the template. At this point, I don't think that ERB supports such escaping.

This is my first major Ruby project. I am writing a code generator. My templates will include a considerable number of conditionals and enumerations. To make the template readable and maintainable, I need to be able to format the logical code and comments without distorting the eventual output.

E.g. Suppose I want this output:

Starting erbOutput
1
2
3
4
Ending erbOutput

I naively wrote the template something like so:

require 'erb'
h=<<H
Starting erbOutput
<%# comment %>
<%5.times do |e|%>
<%=e.to_s  %>
<%end %>
<%# comment %>
Ending erbOutput
H
s=ERB.new(h).result
puts s

... but this produces

Starting erbOutput


0

1

2

3

4


Ending erbOutput

A straight print:

"Starting erbOutput\n\n\n0\n\n1\n\n2\n\n3\n\n4\n\n\nEnding erbOutput\n"

...makes it clear that the line-returns of the logic and comment lines are being included in the ERB output.

I can produce the desired output by cramming the template into this awkward form:

h=<<H
Starting erbOutput<%# comment %>
<%5.times do |e|%><%=e.to_s  %>
<%end %><%# comment %>Ending erbOutput
H

... but I don't think I can debug and maintain templates without more readable formatting. Some of my conditionals and enumerations are as much as three levels deep and I comment heavily. Cramming all that on one or two lines makes the template utterly unreadable.

Is there a way to escape or otherwise suppress the line returns of logic an comment lines in ERB? Does one of the other commonly available Ruby template modules handle this better?

In case it matters, I am working in MacRuby 0.10 (implements Ruby 1.9.2) on MacOS 10.6.7.


Source: (StackOverflow)

License of MacRuby [closed]

I recently started using MacRuby to make some easy app, but I noticed that the MacRuby is implemented from Ruby 1.9, and the Ruby license is under GPL lilcense, I think the MacRuby is GPL too.

And here comes the question, the Xcode will pull whole MacRuby framework into the app while packing the app, does that mean my app is also under GPL license now even I don't have any modification to MacRuby?

thanks,

eddie


Source: (StackOverflow)

Can gems be used by ruby code compiled with macrubyc

MacRuby 0.5 includes a ruby compiler built on LLVM called macrubyc.

Does anyone know if it would be possible to dynamically load gems from compiled code? Or compile the gems and link them in? Is this planned? Or how compiled code will be able to make use of gems in general.


Source: (StackOverflow)