Class: Aranha::Parsers::Firefox::RequestFromFirefox

Inherits:
Object
  • Object
show all
Defined in:
lib/aranha/parsers/firefox/request_from_firefox.rb

Constant Summary collapse

BASE_URL_SUBPATH =
'base_url'
BODY_SUBPATH =
'body'
REQUEST_SUBPATH =
'request'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.from_directory(path) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'lib/aranha/parsers/firefox/request_from_firefox.rb', line 14

def from_directory(path)
  path = path.to_pathname
  body_path = path.join(BODY_SUBPATH)
  new(
    path.join(BASE_URL_SUBPATH).read.strip,
    ::Aranha::Parsers::Firefox::RequestHeaderFromFirefox
    .from_file(path.join(REQUEST_SUBPATH)),
    body_path.file? ? body_path.read : nil
  )
end

Instance Method Details

#to_uri_sourceObject



31
32
33
34
35
36
37
38
# File 'lib/aranha/parsers/firefox/request_from_firefox.rb', line 31

def to_uri_source
  {
    method: header.verb,
    url: url,
    headers: header.headers,
    body: body
  }
end

#urlObject



40
41
42
# File 'lib/aranha/parsers/firefox/request_from_firefox.rb', line 40

def url
  (the_base_uri + header.uri).to_s
end