「Ruby を実行」の版間の差分

MSY-07 (トーク | 投稿記録)
リンク用のマークアップを追加
MSY-07 (トーク | 投稿記録)
SyntaxHighlightにcopyの追加
 
(同じ利用者による、間の1版が非表示)
13行目: 13行目:


== 置き換え版 ==
== 置き換え版 ==
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript" copy>
// Rubyを実行 (置き換え版).js
// Rubyを実行 (置き換え版).js


// rubyw.exe の場所を指定
// rubyw.exe の場所を指定
var RUBY_PATH = 'C:\\Program Files\\rubyinstaller-2.7.1-1-x64\\bin\\rubyw.exe'
var RUBY_PATH = 'C:\\Program Files\\rubyinstaller-2.7.1-1-x64\\bin\\rubyw.exe';


if (document.selection.IsEmpty) {
if (document.selection.IsEmpty) {
   document.selection.EndOfLine(false, mePosLogical)
   document.selection.EndOfLine(false, mePosLogical);
   document.selection.StartOfLine(true, mePosLogical)
   document.selection.StartOfLine(true, mePosLogical);
}
}


var shell = new ActiveXObject('WScript.Shell')
var shell = new ActiveXObject('WScript.Shell');
shell.CurrentDirectory = document.Path || shell.SpecialFolders("Desktop")
shell.CurrentDirectory = document.Path || shell.SpecialFolders("Desktop");


var exec = shell.Exec(
var exec = shell.Exec(
47行目: 47行目:
       'print e(%_#<#{e.full_message}>_);' +
       'print e(%_#<#{e.full_message}>_);' +
     'end' +
     'end' +
   '"')
   '"');


exec.StdIn.WriteLine(encodeURIComponent(document.FullName))
exec.StdIn.WriteLine(encodeURIComponent(document.FullName));
exec.StdIn.Write(encodeURIComponent(document.selection.text))
exec.StdIn.Write(encodeURIComponent(document.selection.text));
exec.StdIn.Close()
exec.StdIn.Close();
document.selection.text = decodeURIComponent(exec.StdOut.ReadAll())
document.selection.text = decodeURIComponent(exec.StdOut.ReadAll());
</syntaxhighlight>
</syntaxhighlight>


== アウトプットバー版 ==
== アウトプットバー版 ==
<syntaxhighlight lang="javascript">
<syntaxhighlight lang="javascript" copy>
// Rubyを実行 (アウトプットバー版).js
// Rubyを実行 (アウトプットバー版).js
'use strict'
'use strict';


// rubyw.exe の場所を指定
// rubyw.exe の場所を指定
var RUBY_PATH = 'C:\\Program Files\\rubyinstaller-2.7.1-1-x64\\bin\\rubyw.exe'
var RUBY_PATH = 'C:\\Program Files\\rubyinstaller-2.7.1-1-x64\\bin\\rubyw.exe';


if (document.selection.IsEmpty) {
if (document.selection.IsEmpty) {
   document.selection.EndOfLine(false, mePosLogical)
   document.selection.EndOfLine(false, mePosLogical);
   document.selection.StartOfLine(true, mePosLogical)
   document.selection.StartOfLine(true, mePosLogical);
}
}


var shell = new ActiveXObject('WScript.Shell')
var shell = new ActiveXObject('WScript.Shell');
shell.CurrentDirectory = document.Path || shell.SpecialFolders("Desktop")
shell.CurrentDirectory = document.Path || shell.SpecialFolders("Desktop");


var exec = shell.Exec(
var exec = shell.Exec(
91行目: 91行目:
       'print e(%_#<#{e.full_message}>_);' +
       'print e(%_#<#{e.full_message}>_);' +
     'end' +
     'end' +
   '"')
   '"');


exec.StdIn.WriteLine(encodeURIComponent(document.FullName))
exec.StdIn.WriteLine(encodeURIComponent(document.FullName));
exec.StdIn.Write(encodeURIComponent(document.selection.text))
exec.StdIn.Write(encodeURIComponent(document.selection.text));
exec.StdIn.Close()
exec.StdIn.Close();


outputbar.visible = true
outputbar.visible = true;
outputbar.Writeln(decodeURIComponent(exec.StdOut.ReadAll()))
outputbar.Writeln(decodeURIComponent(exec.StdOut.ReadAll()));
</syntaxhighlight>
</syntaxhighlight>
スポンサーリンク