Class: Ey::Core::Client::Log

Inherits:
Model
  • Object
show all
Extended by:
Associations
Defined in:
lib/ey-core/models/log.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Associations

assoc_accessor, assoc_coverage, assoc_reader, assoc_writer, associations, collection_reader

Methods inherited from Model

#destroy, range_parser, #save, #to_s, #update!, #url

Instance Attribute Details

#component_action_idObject

Returns the value of attribute component_action_id.



14
15
16
# File 'lib/ey-core/models/log.rb', line 14

def component_action_id
  @component_action_id
end

#fileObject

Returns the value of attribute file.



14
15
16
# File 'lib/ey-core/models/log.rb', line 14

def file
  @file
end

Instance Method Details

#contentsObject



35
36
37
38
39
40
41
42
# File 'lib/ey-core/models/log.rb', line 35

def contents
  body = Faraday.get(download_url).body
  if filename.match(/\.gz$/)
    Zlib::GzipReader.new(StringIO.new(body, "rb")).read
  else
    body
  end
end

#save!Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ey-core/models/log.rb', line 16

def save!
  if self.file.kind_of?(File)
    body = File.read(self.file)
  else
    body = self.file
  end

  params = {
    "component_action_id" => component_action_id,
    "log" => {
      "file"      => body,
      "filename"  => filename || "log",
      "mime_type" => mime_type,
    }
  }

  merge_attributes(self.connection.create_log(params).body["log"])
end