Sha256: 1e69c70bf405149a0862b1c68a228224aaef602254d375dbf66e9a13750ca1c9

Contents?: true

Size: 886 Bytes

Versions: 23

Compression:

Stored size: 886 Bytes

Contents

class Ey::Core::Client::Log < Ey::Core::Model
  extend Ey::Core::Associations

  identity :id

  attribute :created_at, type: :time
  attribute :filename
  attribute :mime_type
  attribute :download_url
  attribute :upload_url

  has_one :component_action

  attr_accessor :file, :component_action_id

  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

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

end

Version data entries

23 entries across 23 versions & 2 rubygems

Version Path
ey-core-3.6.4 lib/ey-core/models/log.rb
ey-core-3.6.3 lib/ey-core/models/log.rb
ey-core-3.6.1 lib/ey-core/models/log.rb
groove-ey-core-3.6.3 lib/ey-core/models/log.rb
groove-ey-core-3.6.2 lib/ey-core/models/log.rb
groove-ey-core-3.6.1 lib/ey-core/models/log.rb
ey-core-3.5.0 lib/ey-core/models/log.rb
ey-core-3.4.4 lib/ey-core/models/log.rb
ey-core-3.4.2 lib/ey-core/models/log.rb
ey-core-3.4.1 lib/ey-core/models/log.rb
ey-core-3.4.0 lib/ey-core/models/log.rb
ey-core-3.3.1 lib/ey-core/models/log.rb
ey-core-3.3.0 lib/ey-core/models/log.rb
ey-core-3.2.6 lib/ey-core/models/log.rb
ey-core-3.2.5 lib/ey-core/models/log.rb
ey-core-3.2.4 lib/ey-core/models/log.rb
ey-core-3.2.3 lib/ey-core/models/log.rb
ey-core-3.2.2 lib/ey-core/models/log.rb
ey-core-3.2.1 lib/ey-core/models/log.rb
ey-core-3.2.0 lib/ey-core/models/log.rb