{"id":339,"date":"2012-12-14T12:51:04","date_gmt":"2012-12-14T20:51:04","guid":{"rendered":"http:\/\/porkrind.org\/missives\/?p=339"},"modified":"2015-02-20T21:31:13","modified_gmt":"2015-02-21T05:31:13","slug":"calling-applescript-from-ruby","status":"publish","type":"post","link":"https:\/\/porkrind.org\/missives\/calling-applescript-from-ruby\/","title":{"rendered":"Calling Applescript from Ruby"},"content":{"rendered":"<p>Today I wrote a Ruby version of <a title=\"Calling Applescript from Perl\" href=\"http:\/\/porkrind.org\/missives\/calling-applescript-from-perl\/\">my quicky function for calling Applescript from Perl<\/a>:<br \/>\n<!-- <script src=\"https:\/\/gist.github.com\/4288508.js\"><\/script> --><\/p>\n<pre><code class=\"language-ruby\">def osascript(script)\r\n  system 'osascript', *script.split(\/\\n\/).map { |line| ['-e', line] }.flatten\r\nend<\/code><\/pre>\n<p>The usage looks like this (almost identical to the <a title=\"Calling Applescript from Perl\" href=\"http:\/\/porkrind.org\/missives\/calling-applescript-from-perl\/\">Perl version<\/a>):<\/p>\n<pre><code class=\"language-ruby\">osascript &lt;&lt;-END\r\n tell application \"Finder\"\r\n   display dialog \"Hello\"\r\n end tell\r\nEND<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Today I wrote a Ruby version of my quicky function for calling Applescript from Perl: def osascript(script) system &#8216;osascript&#8217;, *script.split(\/\\n\/).map { |line| [&#8216;-e&#8217;, line] }.flatten end The usage looks like this (almost identical to the Perl version): osascript &lt;&lt;-END tell application &#8220;Finder&#8221; display dialog &#8220;Hello&#8221; end tell END<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[3],"tags":[16,15],"class_list":["post-339","post","type-post","status-publish","format-standard","hentry","category-software","tag-applescript","tag-ruby"],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/porkrind.org\/missives\/wp-json\/wp\/v2\/posts\/339","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/porkrind.org\/missives\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/porkrind.org\/missives\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/porkrind.org\/missives\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/porkrind.org\/missives\/wp-json\/wp\/v2\/comments?post=339"}],"version-history":[{"count":7,"href":"https:\/\/porkrind.org\/missives\/wp-json\/wp\/v2\/posts\/339\/revisions"}],"predecessor-version":[{"id":491,"href":"https:\/\/porkrind.org\/missives\/wp-json\/wp\/v2\/posts\/339\/revisions\/491"}],"wp:attachment":[{"href":"https:\/\/porkrind.org\/missives\/wp-json\/wp\/v2\/media?parent=339"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/porkrind.org\/missives\/wp-json\/wp\/v2\/categories?post=339"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/porkrind.org\/missives\/wp-json\/wp\/v2\/tags?post=339"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}