Class: Co2Notify

Inherits:
Thor
  • Object
show all
Defined in:
lib/co2-notify.rb,
lib/co2-notify/version.rb

Defined Under Namespace

Classes: Config, HipchatClient, Notifier, Status

Constant Summary collapse

PLIST_NAME =
"arkadiybutermanov.co2-notify".freeze
VERSION =
"0.4.9"

Instance Method Summary collapse

Instance Method Details

#autoload(path) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/co2-notify.rb', line 33

def autoload(path)
  data = {
    "KeepAlive" => true,
    "Label" => PLIST_NAME,
    "ProgramArguments" => [
      path,
      "go"
    ],
    "RunAtLoad" => true,
    "StandardOutPath" => Config.output_path,
    "StandardErrorPath" => Config.error_path
  }

  File.open(plist_path, "w") do |f|
    f.write Plist::Emit.dump(data)
  end
end

#goObject



13
14
15
# File 'lib/co2-notify.rb', line 13

def go
  Notifier.start
end

#initObject



28
29
30
# File 'lib/co2-notify.rb', line 28

def init
  Config.set
end

#startObject



18
19
20
# File 'lib/co2-notify.rb', line 18

def start
  system "launchctl load #{plist_path}"
end

#stopObject



23
24
25
# File 'lib/co2-notify.rb', line 23

def stop
  system "launchctl unload #{plist_path}"
end