Parent

Class/Module Index [+]

Quicksearch

Merb::Test::Cookie

Attributes

name[R]

:api: private

value[R]

:api: private

Public Class Methods

new(raw, default_host) click to toggle source

:api: private

# File lib/merb-core/test/helpers/cookie_jar.rb, line 11
def initialize(raw, default_host)
  # separate the name / value pair from the cookie options
  @name_value_raw, options = raw.split(/[;,] */, 2)
  
  @name, @value = Merb::Parse.query(@name_value_raw, ';').to_a.first
  @options = Merb::Parse.query(options, ';')
  
  @options.delete_if { |k, v| !v || v.empty? }
  
  @options["domain"] ||= default_host
end

Public Instance Methods

<=>(other) click to toggle source

:api: private

# File lib/merb-core/test/helpers/cookie_jar.rb, line 68
def <=>(other)
  # Orders the cookies from least specific to most
  [name, path, domain.reverse] <=> [other.name, other.path, other.domain.reverse]
end
domain() click to toggle source

:api: private

# File lib/merb-core/test/helpers/cookie_jar.rb, line 34
def domain
  @options["domain"]
end
empty?() click to toggle source

:api: private

# File lib/merb-core/test/helpers/cookie_jar.rb, line 29
def empty?
  @value.nil? || @value.empty?
end
expired?() click to toggle source

:api: private

# File lib/merb-core/test/helpers/cookie_jar.rb, line 49
def expired?
  expires && expires < Time.now
end
expires() click to toggle source

:api: private

# File lib/merb-core/test/helpers/cookie_jar.rb, line 44
def expires
  Time.parse(@options["expires"]) if @options["expires"]
end
matches?(uri) click to toggle source

:api: private

# File lib/merb-core/test/helpers/cookie_jar.rb, line 63
def matches?(uri)
  ! expired? && valid?(uri)
end
path() click to toggle source

:api: private

# File lib/merb-core/test/helpers/cookie_jar.rb, line 39
def path
  @options["path"] || "/"
end
raw() click to toggle source

:api: private

# File lib/merb-core/test/helpers/cookie_jar.rb, line 24
def raw
  @name_value_raw
end
valid?(uri) click to toggle source

:api: private

# File lib/merb-core/test/helpers/cookie_jar.rb, line 54
def valid?(uri)
  domain_ = domain.index('.') == 0 ? domain[1..-1] : domain
  uri_path = uri.path.blank? ? "/" : uri.path

  uri.host =~ Regexp.new("#{Regexp.escape(domain_)}$") &&
  uri_path =~ Regexp.new("^#{Regexp.escape(path)}")
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.