Application for OS X Ruby

It's easy to create a ruby ​​OS X app - create a structure like this:

xxx.app
└── Contents
    β”œβ”€β”€ Info.plist
    β”œβ”€β”€ MacOS
    β”‚   └── xxx
    └── Resources
        └── xxx.icns

and enter the code to execute in xxx. But the launch time is noticeable, so I want this application to stay in the background and run some method when the application is open: therefore, when I launch this application for the first time, it executes the code that remains in the background when I I start another time, the application is already in the background, so it just starts the specified method.

Minimum Info.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  <key>CFBundlePackageType</key>
  <string>APPL</string>
  <key>CFBundleExecutable</key>
  <string>newTabHere</string>
  <key>CFBundleIconFile</key>
  <string>newTabHere</string>
  <key>LSUIElement</key>
  <true/><!-- hides icon from Dock -->
</dict>
</plist>
+3
source share
3 answers

Slowness occurs due to the launch time required for the ruby ​​interpreter. Therefore, it does not slow down for a bash script or objective-c.

:

  • gem. (, )
  • bash script telnet .
  • eventmachine ( Rubygems) , telnet.
  • telnet, , .
  • bash script , .

bash script :

  • , .
  • telnet ,
  • .
  • .

  • .
  • Telnet .
  • Bash .
  • Ruby , .

. , .

, macruby rubycocoa.

Titanium Desktop Appcelerator, javascript, ruby. , -. . http://developer.appcelerator.com/doc/desktop/ruby

+2

, " ". , - , , , , cite . , , script .

0

, . script ( script xxx):

#!/bin/sh
a=0
echo $a >> /tmp/test.txt

:

> time /usr/bin/open test.app

real    0m0.042s
user    0m0.022s
sys     0m0.010s

, 40 ( ). , ( , , applescript...). ?

edit: , '&' ( ). , 6 .

,

0
source

Source: https://habr.com/ru/post/1778540/


All Articles