class Statistrano::Deployment::LogFile

Attributes

file[R]
remote[R]
resolved_path[R]

Public Class Methods

new(path, remote) click to toggle source
# File lib/statistrano/deployment/log_file.rb, line 7
def initialize path, remote
  @remote        = remote
  @resolved_path = resolve_path path
  @file          = Remote::File.new @resolved_path, remote
end

Public Instance Methods

append!(log_entry) click to toggle source
# File lib/statistrano/deployment/log_file.rb, line 13
def append! log_entry
  file.append_content! log_entry.to_json
end
last_entry() click to toggle source
# File lib/statistrano/deployment/log_file.rb, line 17
def last_entry
  entries(1).last || {}
end
tail(length=10) click to toggle source
# File lib/statistrano/deployment/log_file.rb, line 21
def tail length=10
  entries(length)
end

Private Instance Methods

entries(length=10) click to toggle source
# File lib/statistrano/deployment/log_file.rb, line 27
def entries length=10
  entries = file.content.split("\n") || []
  entries.reverse[0...length].map do |e|
    Util.symbolize_hash_keys( JSON.parse(e) )
  end
end
resolve_path(path) click to toggle source
# File lib/statistrano/deployment/log_file.rb, line 34
def resolve_path path
  if path.start_with? '/'
    path
  else
    File.join( remote.config.remote_dir, path )
  end
end