Module: Scrubyt::FetchAction

Included in:
Extractor
Defined in:
lib/scrubyt/core/navigation/fetch_action.rb

Overview

Fetching pages (and related functionality)

Since lot of things are happening during (and before) the fetching of a document, I decided to move out fetching related functionality to a separate class - so if you are looking for anything which is loading a document (even by submitting a form or clicking a link) and related things like setting a proxy etc. you should find it here.

Constant Summary collapse

@@current_doc_url =
nil
@@current_doc_protocol =
nil
@@base_dir =
nil
@@host_name =
nil
@@history =
[]
@@current_form =
nil
@@extractor =
nil

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extractorObject



23
24
25
# File 'lib/scrubyt/core/navigation/fetch_action.rb', line 23

def self.extractor
  return @@extractor
end

.extractor=(extractor) ⇒ Object



19
20
21
# File 'lib/scrubyt/core/navigation/fetch_action.rb', line 19

def self.extractor=(extractor)
  @@extractor = extractor
end

.get_current_doc_urlObject

At any given point, the current document can be queried with this method; Typically used when the navigation is over and the result document is passed to the wrapper



30
31
32
# File 'lib/scrubyt/core/navigation/fetch_action.rb', line 30

def self.get_current_doc_url
  @@current_doc_url
end

.get_hpricot_docObject



38
39
40
# File 'lib/scrubyt/core/navigation/fetch_action.rb', line 38

def self.get_hpricot_doc
  @@hpricot_doc
end

.get_mechanize_docObject



34
35
36
# File 'lib/scrubyt/core/navigation/fetch_action.rb', line 34

def self.get_mechanize_doc
  @@mechanize_doc
end

Instance Method Details

#get_host_nameObject



42
43
44
# File 'lib/scrubyt/core/navigation/fetch_action.rb', line 42

def get_host_name
  @@host_name
end

#restore_host_nameObject



46
47
48
49
# File 'lib/scrubyt/core/navigation/fetch_action.rb', line 46

def restore_host_name
  return if @@current_doc_protocol == 'file'
  @@host_name = @@original_host_name
end

#restore_pageObject



55
56
57
# File 'lib/scrubyt/core/navigation/fetch_action.rb', line 55

def restore_page
  @@hpricot_doc = @@history.pop
end

#store_host_name(doc_url) ⇒ Object



59
60
61
# File 'lib/scrubyt/core/navigation/fetch_action.rb', line 59

def store_host_name(doc_url)
  FetchAction.store_host_name(doc_url)
end

#store_pageObject



51
52
53
# File 'lib/scrubyt/core/navigation/fetch_action.rb', line 51

def store_page
  @@history.push @@hpricot_doc
end