Class: Nanoc::Extra::CHiCk::Client Deprecated
- Inherits:
-
Object
- Object
- Nanoc::Extra::CHiCk::Client
- Defined in:
- lib/nanoc/extra/chick.rb
Overview
Constant Summary
- DEFAULT_OPTIONS =
{ cache: { metastore: 'file:tmp/rack/cache.meta', entitystore: 'file:tmp/rack/cache.body' }, cache_controller: { max_age: 60 } }
Instance Method Summary (collapse)
-
- (Object) get(url)
-
- (Client) initialize(options = {})
constructor
A new instance of Client.
Constructor Details
- (Client) initialize(options = {})
Returns a new instance of Client
26 27 28 29 30 31 |
# File 'lib/nanoc/extra/chick.rb', line 26 def initialize( = {}) # Get options @options = DEFAULT_OPTIONS.merge() @options[:cache] = DEFAULT_OPTIONS[:cache].merge(@options[:cache]) @options[:cache_controller] = DEFAULT_OPTIONS[:cache_controller].merge(@options[:cache_controller]) end |
Instance Method Details
- (Object) get(url)
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/nanoc/extra/chick.rb', line 33 def get(url) # Build app = @options @app ||= Rack::Builder.new do use Rack::Cache, [:cache].merge(verbose: true) use Nanoc::Extra::CHiCk::CacheController, [:cache_controller] run Nanoc::Extra::CHiCk::RackClient end # Build environment for request env = Rack::MockRequest.env_for(url, method: 'GET') # Fetch puts "[CHiCk] Fetching #{url}..." if $DEBUG status, headers, body_parts = @app.call(env) puts "[CHiCk] #{url}: #{headers['X-Rack-Cache']}" if $DEBUG # Join body body = '' body_parts.each { |part| body << part } # Done [status, headers, body] end |