module NginxTail::Uri

Public Class Methods

add_automatic_file(automatic_file) click to toggle source
# File lib/ntail/uri.rb, line 40
def self.add_automatic_file(automatic_file)
  if automatic_file.is_a? Array
    # some ducktyping, so that we can also accepts arrays of values
    automatic_file.each { |file| self.add_automatic_file(file) }
  else
    (@@automatic_files << automatic_file).uniq!
    (@@automatic_uris << Regexp.compile("^\/#{automatic_file}")).uniq!
  end
end
add_static_repo(repo) click to toggle source
# File lib/ntail/uri.rb, line 78
def self.add_static_repo(repo)
  # TODO make this DRY...
  @@static_uris << Regexp.compile("^\/#{repo}\/")
end
automatic_files() click to toggle source

mainly (solely?) for testing purposes…

# File lib/ntail/uri.rb, line 24
def self.automatic_files()
  @@automatic_files.dup
end
automatic_uri?(uri) click to toggle source
# File lib/ntail/uri.rb, line 53
def self.automatic_uri?(uri)
  !@@automatic_uris.detect { |automatic_uri_regexp| uri.match(automatic_uri_regexp) }.nil?
end
automatic_uris() click to toggle source

mainly (solely?) for testing purposes…

# File lib/ntail/uri.rb, line 29
def self.automatic_uris()
  @@automatic_uris.dup
end
reset_automatic_files() click to toggle source

mainly (solely?) for testing purposes…

# File lib/ntail/uri.rb, line 34
def self.reset_automatic_files()
  while !@@automatic_files.empty? ; @@automatic_files.pop ; end
  while !@@automatic_uris.empty? ; @@automatic_uris.pop ; end
  self.add_automatic_file(@@default_automatic_files)
end
static_uri?(uri) click to toggle source
# File lib/ntail/uri.rb, line 83
def self.static_uri?(uri)
  !@@static_uris.detect { |static_uri_regexp| uri.match(static_uri_regexp) }.nil?
end
to_uri_s(uri) click to toggle source
# File lib/ntail/uri.rb, line 87
def self.to_uri_s(uri)
  uri || "-" # will be nil if $request == "-" (ie. "dodgy" HTTP requests)
end

Public Instance Methods

automatic_uri?() click to toggle source
# File lib/ntail/uri.rb, line 101
def automatic_uri?
  self.class.automatic_uri?(self.uri)
end
static_uri?() click to toggle source
# File lib/ntail/uri.rb, line 105
def static_uri?
  self.class.static_uri?(self.uri)
end
to_uri_s() click to toggle source
# File lib/ntail/uri.rb, line 97
def to_uri_s
  self.class.to_uri_s(self.uri)
end