From lrz at chopine.be Wed Nov 1 12:02:53 2006 From: lrz at chopine.be (Laurent Sansonetti) Date: Wed, 1 Nov 2006 18:02:53 +0100 Subject: [Rubyosa-discuss] OSA::Element of type alis In-Reply-To: References: Message-ID: <71B3A40A-0691-4D97-85DB-67D8C920A5F0@chopine.be> On Nov 1, 2006, at 4:26 AM, James MacAulay wrote: > On 31-Oct-06, at 9:50 PM | Oct 31, Laurent Sansonetti wrote: > > /snip >> +OSA.add_conversion_to_ruby('alis') { |value, type, object| >> object.__data__('furl') } >> > /snip > > Yeah, this is probably the best way to go as far as I can tell. > > /snip >> >> I wonder if we should implicitly use the 'uri' lib to return the >> real path though, as it wouldn't work for non-file URLs (http & co). > > So 'alis' objects are sometimes used for remote URLs? I just assumed > that is one thing which separated the use of 'alis' vs. 'furl'. You're right, sorry. AFAIK 'alis' types represent files in the file system. > If we could safely assume that 'alis' objects are always going to > represent files on mounted volumes, then we could even make ruby File > objects out of them straight away. I guess this might introduce a > fair amount of overhead when resolving a bunch of them, though. I wonder if this would be useful. Returning a File object means that we need to open the file, and sometimes you just want to deal with its path. Opening files by default might add some overhead as you said. But we should perhaps return a file system path and not a file:// localhost/... string URL. > Just coercing the alis into a furl seems like a happy medium, at > least until we or someone else makes a ruby class which converts more > smoothly to and from alis without information loss (I really don't > know what all the extra information in an alis is all about, anyway). I would say that a file path (as String) should be enough for everyone. From the Ruby side we don't have much choices, either a path or a File object (which implies to open the file, something people might not have by default). Laurent From andy at pragmaticbookshelf.com Wed Nov 1 12:30:17 2006 From: andy at pragmaticbookshelf.com (Andy Hunt) Date: Wed, 1 Nov 2006 12:30:17 -0500 Subject: [Rubyosa-discuss] Nesting, activate, and parameter arguments. Message-ID: Hi all: Given this fragment of applescript, I've got a couple of questions. tell application processName to activate tell application "System Events" tell process processName keystroke "n" using {command down, option down} -- name track 1) How do I cann activate in ruby OSA? it doesn't appear as a method on the app object, or in System Events. 2) How do I handle the nesting tell? 3) Finally, how do you pass arguments to keystroke (as in the "using" above). The bottom line is that I want to send keystrokes to an arbitrary application that doesn't have its own applescript dictionary. thanks! /\ndy From yvon_thoraval at mac.com Wed Nov 1 13:27:59 2006 From: yvon_thoraval at mac.com (Yvon Thoraval) Date: Wed, 1 Nov 2006 19:27:59 +0100 Subject: [Rubyosa-discuss] Sending keystrokes via System Events In-Reply-To: <0845848C-B3B9-48B8-8BCE-708FCCD47938@pragmaticbookshelf.com> References: <0845848C-B3B9-48B8-8BCE-708FCCD47938@pragmaticbookshelf.com> Message-ID: <43163429-8FFF-48D6-8E7C-4A896DC38B20@mac.com> Le 31 oct. 06 ? 17:31, Andy Hunt a ?crit : > > How can I do this using RubyOsa? I'm not clear on the scope of the > activate, the nesting, or passing parameters to "keystroke". But > other than that... :-) > i can't say for RubyOSA because i've mostly used RubyAEOSA to this time. but with RubyAEOSA, no real prob to pass args. usually i do read from ruby the applescript saved as text and i add whatever i want as arfs to the script being a string.(*) best, Yvon * NB : i know that's a "muddy" way to program not oop at all. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rubyosa-discuss/attachments/20061101/5473bd07/attachment.html From lrz at chopine.be Wed Nov 1 18:46:26 2006 From: lrz at chopine.be (Laurent Sansonetti) Date: Thu, 2 Nov 2006 00:46:26 +0100 Subject: [Rubyosa-discuss] Sending keystrokes via System Events In-Reply-To: <0845848C-B3B9-48B8-8BCE-708FCCD47938@pragmaticbookshelf.com> References: <0845848C-B3B9-48B8-8BCE-708FCCD47938@pragmaticbookshelf.com> Message-ID: <935997F7-4F6A-4960-801D-B377241DF9D9@chopine.be> Hi Andy, On Oct 31, 2006, at 5:31 PM, Andy Hunt wrote: > Hi all, > > I've trying to send keystrokes to a process that isn't otherwise > scriptable. There's a hunk of Applescript that does it like this: > > set processName to (...) > > tell application processName to activate > > tell application "System Events" > tell process processName > keystroke "n" using {command down, option down} > ... > end tell > end tell > > > > How can I do this using RubyOsa? I'm not clear on the scope of the > activate, the nesting, or passing parameters to "keystroke". But > other than that... :-) Most of them are unfortunately not supported yet. However the System Events sdef is parseable (e.g. RubyOSA generates a #keystroke method), and it shouldn't be difficult to provide an API to "mix" it into a given app, which is I believe what should be done here. Stay tuned, a future release should feature this :) Laurent From lsansonetti at apple.com Thu Nov 2 06:52:26 2006 From: lsansonetti at apple.com (Laurent Sansonetti) Date: Thu, 2 Nov 2006 12:52:26 +0100 Subject: [Rubyosa-discuss] Nesting, activate, and parameter arguments. In-Reply-To: References: Message-ID: <2C6CA9E3-00BD-4431-90BE-E015A535FC24@apple.com> Hi Andy, Sorry I didn't immediately see your first message in the pending requests queue. On Nov 1, 2006, at 6:30 PM, Andy Hunt wrote: > The bottom line is that I want to send keystrokes to an arbitrary > application that doesn't have its own applescript dictionary. > This may become more difficult to implement. I will nevertheless investigate. Laurent From andy at pragmaticbookshelf.com Thu Nov 2 11:14:52 2006 From: andy at pragmaticbookshelf.com (Andrew Hunt) Date: Thu, 2 Nov 2006 11:14:52 -0500 Subject: [Rubyosa-discuss] Nesting, activate, and parameter arguments. In-Reply-To: <2C6CA9E3-00BD-4431-90BE-E015A535FC24@apple.com> References: <2C6CA9E3-00BD-4431-90BE-E015A535FC24@apple.com> Message-ID: On Nov 2, 2006, at 6:52 AM, Laurent Sansonetti wrote: > >> The bottom line is that I want to send keystrokes to an arbitrary >> application that doesn't have its own applescript dictionary. >> > > This may become more difficult to implement. I will nevertheless > investigate. The particular application I'm looking to drive is Logic Pro, which would benefit greatly from this ability. (And oddly, Logic Pro isn't scriptable by normal means. Somewhat annoying for an expensive, "Professional" application!) thanks so much, /\ndy From mongillo at gmail.com Mon Nov 13 01:59:37 2006 From: mongillo at gmail.com (mongillo) Date: Sun, 12 Nov 2006 22:59:37 -0800 Subject: [Rubyosa-discuss] RubyOSA in a view Message-ID: <936F6857-EEB3-42EF-AED4-5F627AF03751@gmail.com> I've got a basic question: Is is possible to put the output of rubyOSA into a view in ruby and or in rails? I wanted to create a little widget that polls itunes and puts the current playing song into a rails view Something like this in an rhtml doc prints nothing, however the cmd line responds with the expected output. require 'rbosa' itunes = OSA.app('iTunes') track = itunes.current_track p track.name expected # -> "Over The Rainbow" # -> "" p track.artist expected # -> "Keith Jarrett" # - > "" From jeanpierre at gmail.com Mon Nov 13 14:10:59 2006 From: jeanpierre at gmail.com (jeanpierre at gmail.com) Date: Mon, 13 Nov 2006 11:10:59 -0800 Subject: [Rubyosa-discuss] RubyOSA in a view In-Reply-To: <936F6857-EEB3-42EF-AED4-5F627AF03751@gmail.com> References: <936F6857-EEB3-42EF-AED4-5F627AF03751@gmail.com> Message-ID: On 11/12/06, mongillo wrote: > I've got a basic question: Is is possible to put the output of > rubyOSA into a view in ruby and or in rails? > > I wanted to create a little widget that polls itunes and puts the > current playing song into a rails view > > Something like this in an rhtml doc prints nothing, however the cmd > line responds with the expected output. > > require 'rbosa' > itunes = OSA.app('iTunes') > track = itunes.current_track > p track.name expected # -> "Over The Rainbow" # -> "" > p track.artist expected # -> "Keith Jarrett" # - > > "" sure, you can mix ruby lib output into a rails/camping application. as a quick and ugly test, this worked for me: app/controllers/tunes_controller.rb ########## require 'rbosa' class TunesController < ApplicationController def index @name = OSA.app('iTunes').current_track.name end end ########## app/views/tunes/index.rhtml ########## <%= @name %> ########## cheers, jean-pierre From mongillo at gmail.com Fri Nov 17 20:31:37 2006 From: mongillo at gmail.com (Lincoln Mongillo) Date: Fri, 17 Nov 2006 17:31:37 -0800 Subject: [Rubyosa-discuss] RubyOSA in a view In-Reply-To: References: <936F6857-EEB3-42EF-AED4-5F627AF03751@gmail.com> Message-ID: <8a4a03f20611171731p705b2417wc0a143431bbae088@mail.gmail.com> This is absolutely wonderful. I've been playing around with rubyosa for a few days now and have been quite thrilled with its power. I've now got a little widget on my site that polls itunes and pulls out the current playing track. I'm sorry to say that I'm still getting ramped up on ruby, so I'm not exactly sure how to call methods on these classes: OSA::ITunes::Application OSA::ITunes::Artwork Does anyone have a chunk of code to share that could pull out the album artwork for the current track? cheers l On 11/13/06, jeanpierre at gmail.com wrote: > On 11/12/06, mongillo wrote: > > I've got a basic question: Is is possible to put the output of > > rubyOSA into a view in ruby and or in rails? > > > > I wanted to create a little widget that polls itunes and puts the > > current playing song into a rails view > > > > Something like this in an rhtml doc prints nothing, however the cmd > > line responds with the expected output. > > > > require 'rbosa' > > itunes = OSA.app('iTunes') > > track = itunes.current_track > > p track.name expected # -> "Over The Rainbow" # -> "" > > p track.artist expected # -> "Keith Jarrett" # - > > > "" > > sure, you can mix ruby lib output into a rails/camping application. as > a quick and ugly test, this worked for me: > > app/controllers/tunes_controller.rb ########## > > require 'rbosa' > > class TunesController < ApplicationController > def index > @name = OSA.app('iTunes').current_track.name > end > end > > ########## > app/views/tunes/index.rhtml ########## > > <%= @name %> > ########## > > cheers, > jean-pierre > From jeanpierre at gmail.com Sat Nov 18 12:49:58 2006 From: jeanpierre at gmail.com (jeanpierre at gmail.com) Date: Sat, 18 Nov 2006 09:49:58 -0800 Subject: [Rubyosa-discuss] RubyOSA in a view In-Reply-To: <8a4a03f20611171731p705b2417wc0a143431bbae088@mail.gmail.com> References: <936F6857-EEB3-42EF-AED4-5F627AF03751@gmail.com> <8a4a03f20611171731p705b2417wc0a143431bbae088@mail.gmail.com> Message-ID: On 11/17/06, Lincoln Mongillo wrote: > This is absolutely wonderful. I've been playing around with rubyosa > for a few days now and have been quite thrilled with its power. I've > now got a little widget on my site that polls itunes and pulls out the > current playing track. > > I'm sorry to say that I'm still getting ramped up on ruby, so I'm not > exactly sure how to call methods on these classes: > > OSA::ITunes::Application > OSA::ITunes::Artwork you probably would access those directly. OSA.app('iTunes') returns an OSA::ITunes::Application instance and you can access OSA::ITunes::Artwork instances with the artworks method off a track. > Does anyone have a chunk of code to share that could pull out the > album artwork for the current track? i couldn't quite figure it out but you might take a look at Doug's 'Show Artwork in Preview' script[1]. cheers, jean-pierre [1] From jeanpierre at gmail.com Mon Nov 20 15:11:01 2006 From: jeanpierre at gmail.com (jeanpierre at gmail.com) Date: Mon, 20 Nov 2006 12:11:01 -0800 Subject: [Rubyosa-discuss] RubyOSA in a view In-Reply-To: <407EE139-411D-4152-AB52-0157854DB853@chopine.be> References: <936F6857-EEB3-42EF-AED4-5F627AF03751@gmail.com> <8a4a03f20611171731p705b2417wc0a143431bbae088@mail.gmail.com> <407EE139-411D-4152-AB52-0157854DB853@chopine.be> Message-ID: On 11/20/06, Laurent Sansonetti wrote: > Hi, > > On Nov 18, 2006, at 6:49 PM, jeanpierre at gmail.com wrote: > >> Does anyone have a chunk of code to share that could pull out the > >> album artwork for the current track? > > > > i couldn't quite figure it out but you might take a look at Doug's > > 'Show Artwork in Preview' script[1]. > > > > I just added support for some picture types to trunk. excellent! after poking around with artwork.data.__data__ and trying to write that out, it is quite a lot more straightfoward and functional =) > [?] > File.open('/tmp/foo.pict', 'w') { |io| io.write(artworks[0].data) } > system("open -a Preview /tmp/foo.pict") one small suggested tweak, the image file type can be divined from OSA::ITunes::Artwork#format and using it might help prevent some confusion. # format is a 4 character code, so one should strip trailing spaces fname = '/tmp/foo.' + artworks[0].format.downcase.strip File.open(fname, 'w') { |io| io.write(artworks[0].data) } system("open -a Preview #{fname}") cheers, jean-pierre From lrz at chopine.be Mon Nov 20 15:22:32 2006 From: lrz at chopine.be (Laurent Sansonetti) Date: Mon, 20 Nov 2006 21:22:32 +0100 Subject: [Rubyosa-discuss] RubyOSA in a view In-Reply-To: References: <936F6857-EEB3-42EF-AED4-5F627AF03751@gmail.com> <8a4a03f20611171731p705b2417wc0a143431bbae088@mail.gmail.com> <407EE139-411D-4152-AB52-0157854DB853@chopine.be> Message-ID: <3C12CA6B-072F-4045-ABBD-936B696D573B@chopine.be> On Nov 20, 2006, at 9:11 PM, jeanpierre at gmail.com wrote: >> [?] >> File.open('/tmp/foo.pict', 'w') { |io| io.write(artworks[0].data) } >> system("open -a Preview /tmp/foo.pict") > > one small suggested tweak, the image file type can be divined from > OSA::ITunes::Artwork#format and using it might help prevent some > confusion. > > # format is a 4 character code, so one should strip trailing spaces > fname = '/tmp/foo.' + artworks[0].format.downcase.strip > File.open(fname, 'w') { |io| io.write(artworks[0].data) } > system("open -a Preview #{fname}") > Indeed, this is a nice tweak, I just merged it. Thanks, Laurent From jenspetr at gmail.com Wed Nov 29 22:47:39 2006 From: jenspetr at gmail.com (Jens-Petr Mikhailovich) Date: Wed, 29 Nov 2006 19:47:39 -0800 Subject: [Rubyosa-discuss] Libxml-Ruby 0.3.8.2 and RubyOSA Message-ID: Hi List, The newly released Libxml-Ruby 0.3.8.2 seems to work with RubyOSA without all of the patching that the previous release required. One can install using 'sudo gem install libxml-ruby'. - jens -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rubyosa-discuss/attachments/20061129/8aa401e7/attachment.html From jmacaulay at gmail.com Wed Nov 29 23:12:32 2006 From: jmacaulay at gmail.com (James MacAulay) Date: Wed, 29 Nov 2006 23:12:32 -0500 Subject: [Rubyosa-discuss] Libxml-Ruby 0.3.8.2 and RubyOSA In-Reply-To: References: Message-ID: <455EF741-29CD-4E35-AB41-620ED60A1AE0@gmail.com> Nice, thanks for the heads-up. It's wonderful whenever the whole RubyOSA dependency chain gets more streamlined, especially for distributing apps made with it. James On 29-Nov-06, at 10:47 PM | Nov 29, Jens-Petr Mikhailovich wrote: > Hi List, > > The newly released Libxml-Ruby 0.3.8.2 seems to work with RubyOSA > without all of the patching that the previous release required. One > can install using 'sudo gem install libxml-ruby'. > > - jens > _______________________________________________ > Rubyosa-discuss mailing list > Rubyosa-discuss at rubyforge.org > http://rubyforge.org/mailman/listinfo/rubyosa-discuss -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rubyosa-discuss/attachments/20061129/b2f66f98/attachment.html From jenspetr at gmail.com Wed Nov 29 23:36:45 2006 From: jenspetr at gmail.com (Jens-Petr Mikhailovich) Date: Wed, 29 Nov 2006 20:36:45 -0800 Subject: [Rubyosa-discuss] Libxml-Ruby 0.3.8.2 and RubyOSA In-Reply-To: <455EF741-29CD-4E35-AB41-620ED60A1AE0@gmail.com> References: <455EF741-29CD-4E35-AB41-620ED60A1AE0@gmail.com> Message-ID: On 11/29/06, James MacAulay wrote: > > Nice, thanks for the heads-up. It's wonderful whenever the whole RubyOSA > dependency chain gets more streamlined, especially for distributing apps > made with it. > Somewhat related, albeit vague and perhaps tangential, I wrote a patch for RubyOSA to use Hpricot for XML parsing when Libxml-Ruby is unavailable. In my blush and brief parsing comparisons, Libxml-Ruby outpaced Hpricot and both were quite a bit faster than REXML. The patch and more details can be found on the RubyOSA problem tracker: http://rubyforge.org/tracker/index.php?func=detail&aid=6911&group_id=1845&atid=7182 - jens -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rubyosa-discuss/attachments/20061129/20392eeb/attachment-0001.html From lrz at chopine.be Thu Nov 30 04:42:16 2006 From: lrz at chopine.be (Laurent Sansonetti) Date: Thu, 30 Nov 2006 10:42:16 +0100 Subject: [Rubyosa-discuss] Libxml-Ruby 0.3.8.2 and RubyOSA In-Reply-To: References: <455EF741-29CD-4E35-AB41-620ED60A1AE0@gmail.com> Message-ID: Hi, On Nov 30, 2006, at 5:36 AM, Jens-Petr Mikhailovich wrote: > On 11/29/06, James MacAulay wrote: > Nice, thanks for the heads-up. It's wonderful whenever the whole > RubyOSA dependency chain gets more streamlined, especially for > distributing apps made with it. > Yes I noticed that the new libxml-ruby is now working from scratch. And more importantly, I recently worked on bridging the xmlTextReader API to the project (I sent a patch and it should be part of the next release). So I will be able to re-write the RubyOSA parsing code using this API, which should definitely be faster. > Somewhat related, albeit vague and perhaps tangential, I wrote a > patch for RubyOSA to use Hpricot for XML parsing when Libxml-Ruby is > unavailable. In my blush and brief parsing comparisons, Libxml-Ruby > outpaced Hpricot and both were quite a bit faster than REXML. The > patch and more details can be found on the RubyOSA problem tracker: http://rubyforge.org/tracker/index.php?func=detail&aid=6911&group_id=1845&atid=7182 Yes thanks, I saw your patch, but didn't have the time to test it. I will check it out soon, at a glance I don't see why it shouldn't be integrated (except about maintaining another parser, but well libxml- ruby will still be the preferred one). I don't know much about Hpricot, is it sensed to replace REXML in the stdlib? Also, isn't it an HTML parser first (e.g. will it still be designed to parse plain XML files in the future)? Thanks, Laurent From jenspetr at gmail.com Thu Nov 30 11:14:24 2006 From: jenspetr at gmail.com (Jens-Petr Mikhailovich) Date: Thu, 30 Nov 2006 08:14:24 -0800 Subject: [Rubyosa-discuss] Libxml-Ruby 0.3.8.2 and RubyOSA In-Reply-To: References: <455EF741-29CD-4E35-AB41-620ED60A1AE0@gmail.com> Message-ID: On 11/30/06, Laurent Sansonetti wrote: > On Nov 30, 2006, at 5:36 AM, Jens-Petr Mikhailovich wrote: > > > Somewhat related, albeit vague and perhaps tangential, I wrote a > > patch for RubyOSA to use Hpricot for XML parsing when Libxml-Ruby is > > unavailable. In my blush and brief parsing comparisons, Libxml-Ruby > > outpaced Hpricot and both were quite a bit faster than REXML. The > > patch and more details can be found on the RubyOSA problem tracker: > http://rubyforge.org/tracker/index.php?func=detail&aid=6911&group_id=1845&atid=7182 > > Yes thanks, I saw your patch, but didn't have the time to test it. I > will check it out soon, at a glance I don't see why it shouldn't be > integrated (except about maintaining another parser, but well libxml- > ruby will still be the preferred one). No problem, I can understand if it is not taken on - adding a dependency is not always desirable =) My initial interest was to see if Hpricot would perform near to Libxml-Ruby. At the time, Libxml-Ruby was a bit of a challenge to install and I thought it would be an easy win for those who just wanted to install via gem and be done with it - the same persons that might be falling back to REXML. I don't know much about Hpricot, is it sensed to replace REXML in the > stdlib? Also, isn't it an HTML parser first (e.g. will it still be > designed to parse plain XML files in the future)? Hpricot is a wild character. While I think its intended usage is for perusing HTML, it is fully capable of working with the superset, XML. I have not heard anything about it replacing REXML in the stdlib. The library is under active development so I would hope that its performance continue to increase. - jens -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/rubyosa-discuss/attachments/20061130/9b555979/attachment.html