Sha256: 83c35588c8f0e18faca541c14969542c6d89c4726cc07b3a49fbc88644b2b947

Contents?: true

Size: 384 Bytes

Versions: 3

Compression:

Stored size: 384 Bytes

Contents

module Buildbox
  class PidFile
    def exist?
      File.exist?(path)
    end

    def path
      Buildbox.root_path.join("buildbox.pid")
    end

    def pid
      File.readlines(path).first.to_i
    end

    def save
      File.open(path, 'w+') { |file| file.write(Process.pid.to_s) }
    end

    def delete
      value = pid
      File.delete(path)
      value
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
buildbox-0.0.4 lib/buildbox/pid_file.rb
buildbox-0.0.3 lib/buildbox/pid_file.rb
buildbox-0.0.2 lib/buildbox/pid_file.rb