Module: MyAtModule

Defined in:
lib/lib/myat.rb

Overview

Atコマンドを突っ込む MyGCalModuleとの連携で使う

@config
~/config.ymlに
atmodule:
  scriptdir: /Users/seijiro/scripts
  rbdir: /Users/seijiro/code/ruby

使い方など class ThisDo

include MyAtModule
include MyGCalModule

して o = ThisDo.new とかでok

Instance Method Summary collapse

Instance Method Details

#_at_command(job) ⇒ Object



45
46
47
48
49
50
51
52
# File 'lib/lib/myat.rb', line 45

def _at_command(job)
  "#! /bin/bash
#ユーザーの環境変数パスを使いたい
source ~/.bashrc
growlnotify -t 'Gcal2At' -m 'pusher tail #{job[:filename]} start . end is #{job[:start].localtime.strftime("%Y/%m/%d/%H/%M")}'
ruby #{@c['rbdir']}/pushertail.rb #{job[:filename]} '#{job[:end].to_s}'
"
end

#_at_scriptpath(job) ⇒ Object



41
42
43
# File 'lib/lib/myat.rb', line 41

def _at_scriptpath(job)
  "#{@c['scriptdir']}/job2at_#{job[:start].localtime.strftime("%Y%m%d%H%M")}.sh"
end

#gcaljobs_2_atObject



23
24
25
26
# File 'lib/lib/myat.rb', line 23

def gcaljobs_2_at
  @gcal_jobs.each { |job| jobs2at(job) }
  return self
end

#initializeObject



19
20
21
# File 'lib/lib/myat.rb', line 19

def initialize
  @c = MyConfig.get['atmodule']
end

#jobs2at(job) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/lib/myat.rb', line 28

def jobs2at(job)
  command = _at_command(job)
  File.open("#{_at_scriptpath(job)}","w") do |io|
    io.write(command)
  end

  atcommand =  "/usr/bin/at -f #{_at_scriptpath(job)} #{job[:start].localtime.strftime("%H:%M %m/%d/%y")}"
  p atcommand
  p command
  system atcommand
  gcal_checkout(job[:object])
end