From mac at casteel.org Fri Aug 3 19:54:26 2007 From: mac at casteel.org (Michael Casteel) Date: Fri, 3 Aug 2007 16:54:26 -0700 Subject: [Rubyosa-discuss] RubyOSA vs iTunes: work-arounds Message-ID: Well, I have been partially successful using RubyOSA with iTunes. On the plus side, I find RubyOSA highly ruby-friendly. I wish I could use it for everything I need to do, but to date I have found two limitations that have forced me to (locally, for these issues) use rb-appscript as a supplement: 1. The iTunes scripting dictionary misdescribes one command I need: reveal. Since rubyOSA relies on the scripting dictionary to create ruby classes modeling the interface, this command cannot be used via rubyOSA; I use rb-appscript instead. I have filed a bug with Apple on this dictionary error (there may be more, but this is the broken command that I needed). 2. When getting text items (current track name, artist name, album name) using rubyOSA, the strings do not come through with intact Unicode; they may be converted to MacRoman or something. This garbages up display of some names, e.g. one artist in the sound track for Everything is Illuminated has a Cyrillic name. I now use rb-appscript when I want to get text info from iTunes, and the Unicode values come through fine. Just wanted to document these things for the rubyOSA list. -- Mike Casteel Seattle, WA From Christopher.Preston at csiro.au Wed Aug 15 05:28:12 2007 From: Christopher.Preston at csiro.au (Christopher.Preston at csiro.au) Date: Wed, 15 Aug 2007 19:28:12 +1000 Subject: [Rubyosa-discuss] RubyOSA/Aperture snippet Message-ID: <73141978E50F334AB7042807A520525E01DBDBF9@exvicn1-mel.nexus.csiro.au> Hi, Just though I'd share a small RubyOSA offering dealing with Aperture. This was intended to convert the offset, in H:M:S, of the Image Date from a specified starting time, to the caption. I found it necessary to first set the caption of the images being altered to an initial temporary value as otherwise the "Caption/Abstract" tag would not be found in the iptc list. I'm sure there is a nicer "Ruby" way of doing this, and I'll happily take suggestions on how to improve it. The parsedate stuff was stolen unashamedly from the Pickaxe book ;-) Cheers, Chris. ---------- require 'rbosa' require 'date' require 'parsedate' aperture = OSA.app('Aperture') selection = aperture.selection start = Time.local(2007,"Apr",11,12,5,28) puts "starting at "+start.strftime("%Y-%m-%d %H:%M:%S") selection.each {|s| s.exif_tags.each { |e| if e.name == "ImageDate" then res = ParseDate.parsedate(e.value.strftime("%Y-%m-%d %H:%M:%S")) diff = Time.local(*res) - start caption = sprintf "%d:%02d:%02d\n",(diff/3600).truncate,(diff%3600/60).truncate,diff%60 end } s.iptc_tags.each {|e| if e.name == "Caption/Abstract" then e.value = caption end } } ------------- From m1 at meso.net Fri Aug 17 05:02:09 2007 From: m1 at meso.net (Mathias Wollin) Date: Fri, 17 Aug 2007 11:02:09 +0200 Subject: [Rubyosa-discuss] Mail.app: How to save attachments? Message-ID: <46C56411.1020604@meso.net> Hello, I'm getting stuck trying to save attachments from within a selected Mail. Not sure that I understood the rdoc correct, but every step I tried is working properly except the save method. Here's my code: require 'rubygems' require 'rbosa' OSA.utf8_strings = true mApp = OSA.app('Mail') # get attachment messages = mApp.message_viewers[0].selected_messages message = messages[0] attachments = message.mail_attachments attachment = attachments[0] # save attachment # # this returns => nil and nothing happens attachment.save("./" + attachment.name) Thanks in advance. Regards, Mathias Wollin From lsansonetti at apple.com Fri Aug 17 13:16:09 2007 From: lsansonetti at apple.com (Laurent Sansonetti) Date: Fri, 17 Aug 2007 19:16:09 +0200 Subject: [Rubyosa-discuss] Not dead Message-ID: Hi guys, Lately I have been very busy on other projects, and as you could see I left many posts on this list and some bugs in the tracker unanswered. I will have the time to resume working on RubyOSA very soon, and I will be able to handle all the feedback. Thank you for your patience, Laurent From mac at casteel.org Mon Aug 20 02:30:04 2007 From: mac at casteel.org (Michael Casteel) Date: Sun, 19 Aug 2007 23:30:04 -0700 Subject: [Rubyosa-discuss] Update: RubyOSA vs iTunes: work-arounds Message-ID: On August 3 2007, I posted to document two problems I had using RubyOSA with iTunes, which I worked around by using rb-appscript. This post is to update that report with the resolution of one of those problems. I was delighted to find a hint in a post by Mathias Wollin on August 17 that one of the problems (Unicode text being transmogrified) was simply due to my failure to tell RubyOSA I wanted Unicode, with the following statement: OSA.utf8_strings = true Somehow, I just missed that in the documentation. As of now, the only workaround I need is for iTunes' bad script dictionary entry for the 'reveal' command. -- Mike Casteel Seattle, WA From i.script at gmail.com Wed Aug 29 10:29:25 2007 From: i.script at gmail.com (Tom Fuerstner) Date: Wed, 29 Aug 2007 16:29:25 +0200 Subject: [Rubyosa-discuss] Problem with specific dictionaries Message-ID: <29cddfe10708290729g1b3d68aeg10867bf094535d12@mail.gmail.com> hi, even though RubyOSA works pretty well for me, there are some tricky dictionaries, e.g. DEVONthink Pro, i can't make it work with. This is the case with "make method" of the class OSA::DEVONthinkPro::Application. rdoc tells me about the public method the following: make(new, at=nil, with_data=nil, with_properties=nil) make(new, :at => nil, :with_data => nil, :with_properties => nil) Make a new object. new: The class of the new object. at: The location at which to insert the object. Optional. Can be passed as a Hash key/value. with_data: The initial data for the object. Optional. Can be passed as a Hash key/value. with_properties: The initial values for properties of the object. Optional. Can be passed as a Hash key/value. Returns: Documentation not available. Therefore i create my call to DEVONthink to tell it to create a new Record the following way: require 'rbosa' dvp = OSA.app('DEVONthink Pro') theLoc = dvp.create_location('wiki_root/entry1/') theRec = dvp.make(OSA::DEVONthinkPro::Record, :at=>theLoc, :with_data => {}, :with_properties => {:name=>'index', :type=>'txt',:plain_text=>'da kommt der text' }) which results in getting as a response that :type2 and :plain_text are invalid keyword even though rdoc tells me otherwise. so having some experience with native AE calls i change the make call to theRec = dvp.make(OSA::DEVONthinkPro::Record, :at=>theLoc, :with_data => {}, :with_properties => {:name=>'index', :type=>'txt',:DTpl=>'da kommt der text' }) which results in: in `__send_event__': application returned error: In make new, duplicate, etc. class can't be an element of container (-10024) (RuntimeError) which seems to mean that OSA::DEVONthinkPro::Record is not accepted as the class of the object to "make" inside the application. So, now I'm stuck. I would be very thankful for any help ! Tom Fuerstner