yapc::kansai 2017 - macosネイティブアプリ作成におけるperlの活用
TRANSCRIPT
about @junnama
✴ アルファサード株式会社 代表取締役 ✴ W3Cメンバー ✴ ご当地/懇親会スポンサーになりました! ✴ CMS「PowerCMS」(Perl製)の開発 ✴ MTのプラグインを⼀番たくさん書いている⼈ ✴ macOSネイティブアプリ開発
23%
77%
macOSネイティブアプリ
for Mac OS X
Xojo
https://xojo.grapecity.com
Xojo (ゾージョー)
✴ CrossBasic => REAL Basic => REAL Studio ✴ ⾔語はBasic! ✴ macOS/Windows/Linux/iOSアプリを作成 ✴ クロスプラットフォーム ✴ Single Desktop 16,000円∼ ✴ 開発は無料(ビルドしたアプリを配布する段階でラ
イセンスが必要)
本⽇のお題
macOSネイティブアプリ
作成におけるPerlの活⽤
macOS = Unix
Dim Sh As New ShellSh.Execute( "ls" )MsgBox( Sh.ReadAll )
http://junnama.alfasado.net/online/2013/12/mac_os_x.html
screencapture
screencapture foo.pngscreencapture -R 117,226,100,100screencapture -t pdf foo.pdf
screencapture
✴ 現在の座標の周辺のキャプチャを取得
✴ Canvas に表⺬
✴ 中央の⾊(Color)を取得
✴ ⾊名に変換して表⺬する
screencapture + Xojo
say
say Hello World
say
mdfind
mdfind -onlyin /Applications/ 'kMDItemContentTypeTree=="com.apple.application"
mdfind
※Spotlightのコマンドラインツール
✴ リストボックスからドラッグされた時
✴ ⼀意の名前のファイルをテンポラリに
✴ ファイルを不可視にしてドラッグ
✴ タイマーを⾛らせる
✴ mdfindでドロップされた場所を得る
mdfind + Xojo
Dim d As Date = New DateDim hex As StringDim bytes As Stringbytes = MD5( Str( round( rnd * 3000 ) + 1 ) )Dim hex As String = EncodeHex( bytes )F = F.Child( "dragitem-" + hex +"-"F = F + Format( d.TotalSeconds, "#") + ".abcd" )FS = BinaryStream.Create( F, true )FS.closeF.visible = FalseDim di As DragItemDraggingItem = F.Name
mdfind
di = New DragItem (self,System.MouseX,System.MouseY-Main.Top,64, 64)di.FolderItem = Fdi.DragWatchFile.Mode = Timer.ModeMultipleReturn False
mdfind
Dim Command As String = "mdfind -name " + DraggingItemDim Sh As New ShellSh.Execute( Command )Dim Res As String = Sh.ReadAllif Res <> "" Then F = GetFolderItem( Res ) ...
さて、Perl
macOS = Unix
Perl, PHP, Ruby, Python...
my $StorageClient = Net::Azure::StorageClient->new( type => 'Blob', account_name => $you_account_name, primary_access_key => $your_primary_access_key, protocol => 'https', api_version => '2012-02-12' );my $res = $StorageClient->get( $url );print $res->content;
use strict;use lib qw( lib );use Getopt::Long qw/:config posix_default no_ignore_case bundling auto_help/;...
GetOptions(\my %options, qw/ account=s accesskey=s path=s action=s acl=s file=s get_all=i thread=i metadata=s pass=s proc=s/);…
cd path/to/app; perl app.pl --action=get --path https://foo.blob....
Application = Folder
Dim AppName As String = CurrentBuildAppNameAppName = ReplaceAll( AppName, " ", "\ " ) Dim AppPath As StringAppPath = CurrentBuildLocation + "/" + AppName + ".app"Dim Command As Stringcommand = "cp /path/to/src.zip " + AppPath + "/Contents/MacOS/src.zip"Call DoShellCommand( Command )command = "cd " + AppPath + "/Contents/MacOS; unzip src.zip"Call DoShellCommand( Command )command = "cd " + AppPath + "/Contents/MacOS; rm src.zip"Call DoShellCommand( Command )
ビルドの際にPerlスクリプトをコピーする
cd path/to/app;
Dim App as new applicationDim MyApp As FolderItemMyApp = App.ExecutableFileDim Name As String = MyApp.Name + ".app"MyApp = GetFolderItem( MyApp.NativePath,3 ).ParentDim CMD As String = “cd ” + MyApp.ShellPath + “;”CMD = CMD + “perl src/app.pl --account ”CMD = CMD + EscapeShell ( Account )CMD = CMD + “ --token ” + EscapeShell( Token )CMS = CMD + “ --action put --path ” + EscapeShell( Path )CMS = CMD + “ --file ” + EscapeShell( File.ShellPath )
cd path/to/MyApp/Contents/MacOS;perl ./app.pl --action=get --path https://foo.blob....
DEMO
ありがとうございました!
アルファサードではエンジニアを募集中です!