Class: Statistrano::Deployment::LogFile

Inherits:
Object
  • Object
show all
Defined in:
lib/statistrano/deployment/log_file.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, remote) ⇒ LogFile

Returns a new instance of LogFile.



7
8
9
10
11
# 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

Instance Attribute Details

#fileObject (readonly)

Returns the value of attribute file.



5
6
7
# File 'lib/statistrano/deployment/log_file.rb', line 5

def file
  @file
end

#remoteObject (readonly)

Returns the value of attribute remote.



5
6
7
# File 'lib/statistrano/deployment/log_file.rb', line 5

def remote
  @remote
end

#resolved_pathObject (readonly)

Returns the value of attribute resolved_path.



5
6
7
# File 'lib/statistrano/deployment/log_file.rb', line 5

def resolved_path
  @resolved_path
end

Instance Method Details

#append!(log_entry) ⇒ Object



13
14
15
# File 'lib/statistrano/deployment/log_file.rb', line 13

def append! log_entry
  file.append_content! log_entry.to_json
end

#last_entryObject



17
18
19
# File 'lib/statistrano/deployment/log_file.rb', line 17

def last_entry
  entries(1).last || {}
end

#tail(length = 10) ⇒ Object



21
22
23
# File 'lib/statistrano/deployment/log_file.rb', line 21

def tail length=10
  entries(length)
end