Sha256: 6d24f05af8d986a1f02600f48e75f6b9f5e02993582498d663df230e1c7a5212

Contents?: true

Size: 839 Bytes

Versions: 8

Compression:

Stored size: 839 Bytes

Contents

# encoding: utf-8
require "logstash/namespace"
require_relative "file_reader"

module LogStash module Modules module ResourceBase
  attr_reader :base, :content_type, :content_path, :content_id

  def initialize(base, content_type, content_path, content = nil, content_id = nil)
    @base, @content_type, @content_path = base, content_type, content_path
    @content_id =  content_id || ::File.basename(@content_path, ".*")
    @content = content
  end

  def content
    @content ||= FileReader.read(@content_path)
  end

  def to_s
    "#{base}, #{content_type}, #{content_path}, #{content_id}"
  end

  def contains?(text)
    content.include?(text)
  end

  def content_as_object
    LogStash::Json.load(content) rescue nil
  end

  def <=>(other)
    to_s <=> other.to_s
  end

  def ==(other)
    to_s == other.to_s
  end
end end end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
logstash-core-5.5.3-java lib/logstash/modules/resource_base.rb
logstash-core-5.5.2-java lib/logstash/modules/resource_base.rb
logstash-core-5.5.1-java lib/logstash/modules/resource_base.rb
logstash-filter-cache-redis-0.3.1 vendor/bundle/jruby/1.9/gems/logstash-core-5.5.1.snapshot1-java/lib/logstash/modules/resource_base.rb
logstash-filter-cache-redis-0.3.0 vendor/bundle/jruby/1.9/gems/logstash-core-5.5.1.snapshot1-java/lib/logstash/modules/resource_base.rb
logstash-core-5.5.1.snapshot1-java lib/logstash/modules/resource_base.rb
logstash-filter-cache-redis-0.2.0 vendor/bundle/jruby/1.9/gems/logstash-core-5.5.0-java/lib/logstash/modules/resource_base.rb
logstash-core-5.5.0-java lib/logstash/modules/resource_base.rb