Skip to content

Instantly share code, notes, and snippets.

@mitakeck
Created July 24, 2014 07:32
Show Gist options
  • Save mitakeck/2ccf9fabe32a89bd2ca6 to your computer and use it in GitHub Desktop.
Save mitakeck/2ccf9fabe32a89bd2ca6 to your computer and use it in GitHub Desktop.

Ruby の Shell クラス覚書

require 'shell'
 
Shell.def_system_command("pushnotice")
sh = Shell.new
sh.pushnotice("Ruby から通知!")
mitake@sakura ruby $ ruby pushnotice.rb
shell: warn: Process finishing...
       wait for Job[pushnotice:#20480] to finish pipe importing.
       You can use Shell#transact or Shell#check_point for more safe execution.
shell: notice: Process finishing...
       wait for Job[pushnotice:#20480] to finish.
       You can use Shell#transact or Shell#check_point for more safe execution.
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
16800     1  100     1    0   167      2    356 --:--:-- --:--:-- --:--:--   893
mitake@sakura ruby $

Shell#transact を使ってくださいとのこと

require 'shell'
 
Shell.def_system_command("pushnotice")
sh = Shell.new
sh.transact do
    sh.pushnotice("Ruby から通知!")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment