Module: Charles
- Defined in:
- lib/charles.rb,
lib/charles/misc.rb,
lib/charles/images.rb,
lib/charles/version.rb,
lib/charles/document.rb,
lib/charles/internal_attributes.rb
Defined Under Namespace
Modules: Images, InternalAttributes, Misc
Classes: Document
Constant Summary
collapse
- VERSION =
"0.0.6"
Class Method Summary
collapse
Class Method Details
.file_cache ⇒ Object
41
42
43
|
# File 'lib/charles.rb', line 41
def self.file_cache
@file_cache ||= ActiveSupport::Cache::FileStore.new(Charles.options[:tmp_path], :namespace => 'charles')
end
|
.get(url, options = {}) ⇒ Object
29
30
31
32
33
34
35
|
# File 'lib/charles.rb', line 29
def self.get(url, options={})
agent = Mechanize.new{|a|a.user_agent_alias = 'Mac Mozilla'}
body = file_cache.fetch("Charles.get(#{url})"){
agent.get(url).body
}
return Document.new(body, {:url => url, :mechanize_agent => agent}.merge(options))
end
|
.logger ⇒ Object
25
26
27
|
# File 'lib/charles.rb', line 25
def self.logger
@logger ||= Logger.new(STDERR)
end
|
.logger=(logger) ⇒ Object
22
23
24
|
# File 'lib/charles.rb', line 22
def self.logger=(logger)
@logger = logger
end
|
.options ⇒ Object
37
38
39
|
# File 'lib/charles.rb', line 37
def self.options
@options ||= {}
end
|