3

I have a situation where I'm using MacRuby for a thin local gui, and most of the work is done in a Parser object that I've created. I will eventually also have an IronRuby thin client, that will also interact with the Parser object.

I turned the Parser into a gem, thinking I could just bundle it with each of the clients, but I've found out that some of the code in my gem doesn't work with MacRuby (specifically named regex groups). So I think my only other option is to run it as a service locally. Somehow this seems like overkill to me, is there any other way to isolate the functionality of a gem so that I can just pass a file path to it and have it do its thing?

In other words, is there a way to have my MacRuby app just somehow make a call to the external Parser app without having to run a local server and service. And if I do create a service, should it just be as simple as calling localhost:PORT/parser?path=/what/ever/path? and then call parser to get updates on progress like localhost:PORT/current_file, etc?

EDIT: Would using JRuby to compile the Parser app be a good idea? That would give me the encapsulation I was looking for and allow me to include the app into MacRuby.

Jeremy Smith
  • 14,727
  • 19
  • 67
  • 114
  • Running a service is more complicated, yes, but insisting on using SOAP doesn't make it simpler. How would the local service run? Also MacRuby? Hmm... so how does this help with the Regex? :( There are also many other forms of IPC, *if* IPC is required. –  Aug 17 '11 at 16:58
  • I don't understand your comment. I'm using service and SOAP interchangeably. – Jeremy Smith Aug 17 '11 at 16:59
  • "What does SOAP have to do with it?" –  Aug 17 '11 at 16:59
  • Maybe nothing. I'm new to this, and that's why I'm asking the question. I'll edit it to be clearer. – Jeremy Smith Aug 17 '11 at 17:03
  • What is the result of the parser? Abstract Syntax Tree (AST)? Would it be possible to store the result as XML or JSON? – ayckoster Aug 17 '11 at 19:17
  • The result is actually just insertions to a data store, that are then uploaded to an external server. – Jeremy Smith Aug 17 '11 at 19:53

2 Answers2

0

A client/server design does seem over complicated for what you've described.

Does your parser work in JRuby? If so, why not just use JRuby instead of Macruby? Or C-Ruby for that matter....

If you do need a client/server design, why not just use rails, thereby making the browser your front-end/client?

EDIT: Would using JRuby to compile the Parser app be a good idea? That would give me the encapsulation I was looking for and allow me to include the app into MacRuby.

By "encapsulation", do you mean in a deployment sense? If so then maybe not. JRuby server processes are typically deployed as war files to be managed by Tomcat or Jetty. Note also that you're not really compiling your app in this case - but that doesn't really matter.

You could possibly do a server process by extending webrick or mongral and packaging with rawr, but again, it's not clear why your design needs to be client/server.

Robert Brown
  • 10,888
  • 7
  • 34
  • 40
0

I'm also not sure why your design needs client/server.

Why can't you just include the parser and make it work with MacRuby? That seems the most straightforward way to go to for me. If you bundle it as a gem, you can tell the gems to run on a specific VM. So your parser could be distributed as a gem for MRI and a gem for MacRuby.

If the actual problem is to maintain a responsive GUI, I strongly encourage you to read about Grand Central Dispatch. The GCD functionality is available in MacRuby.

http://www.macruby.org/documentation/gcd.html

Overbryd
  • 4,612
  • 2
  • 33
  • 33