cryx-cacheability 1.1.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
data/README CHANGED
@@ -1,16 +1,19 @@
1
- Cacheability
2
- ============
1
+ = cacheability
2
+
3
3
  A gem that makes client-side caching of HTTP requests a no-brainer. It is built upon the Rack:Cache gem from Ryan Tomayko.
4
4
 
5
5
  Cached data can be stored in heap, file or memcached. See the Rack::Cache documentation (http://tomayko.com/src/rack-cache/) for more information.
6
6
 
7
- Installation
8
- ============
9
- gem install cryx-cacheability
7
+ = Installation
8
+
9
+ gem install cacheability
10
10
 
11
- Usage
12
- =====
11
+ = Usage
12
+
13
13
  require 'cacheability/restclient'
14
+
15
+ RestClient.log = 'stdout' # displays requests and status codes
16
+
14
17
  resource = RestClient::CacheableResource.new( 'http://some/cacheable/resource',
15
18
  :cache => { :metastore => 'file:/tmp/cache/meta',
16
19
  :entitystore => 'file:/tmp/cache/body' }
@@ -27,15 +30,14 @@ Do yourself a favor and read:
27
30
  * Things Caches Do - http://tomayko.com/writings/things-caches-do
28
31
 
29
32
 
30
- Supported libraries
31
- ===================
33
+ = Supported libraries
34
+
32
35
  * rest-client > 0.9
33
36
 
34
- Dependencies
35
- ============
37
+ = Dependencies
38
+
36
39
  * rack-cache
37
40
 
38
- COPYRIGHT
39
- =========
41
+ = COPYRIGHT
40
42
 
41
43
  Copyright (c) 2008 Cyril Rohr. See LICENSE for details.
data/Rakefile CHANGED
@@ -10,11 +10,43 @@ begin
10
10
  s.description = "Transparent caching for your HTTP requests (heap, file, memcache). Built-in support for RestClient. Built upon Rack::Cache."
11
11
  s.authors = ["Cyril Rohr"]
12
12
  s.add_dependency "rack-cache"
13
+ s.rubyforge_project = 'cacheability'
14
+ end
15
+
16
+ Jeweler::RubyforgeTasks.new do |rubyforge|
17
+ rubyforge.doc_task = "rdoc"
13
18
  end
14
19
  rescue LoadError
15
20
  puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
16
21
  end
17
22
 
23
+
24
+ begin
25
+ require 'rake/contrib/sshpublisher'
26
+ namespace :rubyforge do
27
+
28
+ desc "Release gem and RDoc documentation to RubyForge"
29
+ task :release => ["rubyforge:release:gem", "rubyforge:release:docs"]
30
+
31
+ namespace :release do
32
+ desc "Publish RDoc to RubyForge."
33
+ task :docs => [:rdoc] do
34
+ config = YAML.load(
35
+ File.read(File.expand_path('~/.rubyforge/user-config.yml'))
36
+ )
37
+
38
+ host = "#{config['username']}@rubyforge.org"
39
+ remote_dir = "/var/www/gforge-projects/cacheability/"
40
+ local_dir = 'rdoc'
41
+
42
+ Rake::SshDirPublisher.new(host, remote_dir, local_dir).upload
43
+ end
44
+ end
45
+ end
46
+ rescue LoadError
47
+ puts "Rake SshDirPublisher is unavailable or your rubyforge environment is not configured."
48
+ end
49
+
18
50
  require 'rake/rdoctask'
19
51
  Rake::RDocTask.new do |rdoc|
20
52
  rdoc.rdoc_dir = 'rdoc'
@@ -43,4 +75,5 @@ rescue LoadError
43
75
  puts "Cucumber is not available. In order to run features, you must: sudo gem install cucumber"
44
76
  end
45
77
 
78
+
46
79
  task :default => :spec
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
+ :patch: 1
2
3
  :major: 1
3
- :minor: 1
4
- :patch: 0
4
+ :minor: 2
data/cacheability.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{cacheability}
8
- s.version = "1.1.0"
8
+ s.version = "1.2.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Cyril Rohr"]
@@ -32,6 +32,7 @@ Gem::Specification.new do |s|
32
32
  s.homepage = %q{http://github.com/cryx/cacheability}
33
33
  s.rdoc_options = ["--charset=UTF-8"]
34
34
  s.require_paths = ["lib"]
35
+ s.rubyforge_project = %q{cacheability}
35
36
  s.rubygems_version = %q{1.3.2}
36
37
  s.summary = %q{A gem that makes client-side caching of HTTP requests a no-brainer. Replace your calls to RestClient::Resource.new with RestClient::CacheableResource.new and the caching is taken care of for you ! Supports heap, file and memcache storage.}
37
38
  s.test_files = [
@@ -24,7 +24,7 @@ module RestClient
24
24
 
25
25
  class CacheableResource < Resource
26
26
  attr_reader :cache
27
- CACHE_DEFAULT_OPTIONS = {:verbose => true}.freeze
27
+ CACHE_DEFAULT_OPTIONS = {:verbose => false}
28
28
 
29
29
  def initialize(*args)
30
30
  super(*args)
@@ -52,12 +52,13 @@ module RestClient
52
52
  "rack.multiprocess" => true,
53
53
  "rack.url_scheme" => uri.scheme,
54
54
  "rack.input" => StringIO.new,
55
- "rack.errors" => StringIO.new # Rack-Cache writes errors into this field
55
+ "rack.errors" => logger # Rack-Cache writes errors into this field
56
56
  }
57
57
  debeautify_headers(additional_headers).each do |key, value|
58
58
  env.merge!("HTTP_"+key.to_s.gsub("-", "_").upcase => value)
59
59
  end
60
60
  response = MockHTTPResponse.new(cache.call(env))
61
+ env['rack.errors'].close if env['rack.errors'].respond_to?(:close)
61
62
  RestClient::Response.new(response.body, response)
62
63
  else
63
64
  super(additional_headers)
@@ -88,5 +89,17 @@ module RestClient
88
89
  response = RestClient::Response.new("", e.response)
89
90
  [304, debeautify_headers( response.headers ), [response.to_s]]
90
91
  end
92
+
93
+ # Ugly, but waiting for RestClient to become smarter
94
+ #
95
+ def logger
96
+ return StringIO.new unless log_to = RestClient.log
97
+ case log_to
98
+ when 'stdout' then STDOUT
99
+ when 'stderr' then STDERR
100
+ else
101
+ File.new(log_to, 'a')
102
+ end
103
+ end
91
104
  end
92
105
  end
@@ -7,6 +7,7 @@ describe RestClient::CacheableResource do
7
7
  require File.dirname(__FILE__) + '/../lib/cacheability/restclient'
8
8
  before do
9
9
  @cache_options = {:metastore => 'file:/tmp/cache/meta', :entitystore => 'file:/tmp/cache/body'}
10
+ RestClient.log = nil
10
11
  end
11
12
 
12
13
  it "should instantiate the cache at init" do
@@ -60,7 +61,7 @@ describe RestClient::CacheableResource do
60
61
  it "should render a RestClient::Response even when the data is coming from the cache" do
61
62
  @resource.cache.should_receive(:call).and_return([200, {'ADDITIONAL_HEADER' => 'whatever'}, "body"])
62
63
  response = @resource.get({'HTTP_ADDITIONAL_HEADER' => 'whatever'}, true)
63
- response.should be_is_a(RestClient::Response)
64
+ response.should be_a(RestClient::Response)
64
65
  response.code.should == 200
65
66
  response.headers.should == {:ADDITIONAL_HEADER => 'whatever'}
66
67
  response.to_s.should == "body"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cryx-cacheability
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cyril Rohr
@@ -64,7 +64,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
64
  version:
65
65
  requirements: []
66
66
 
67
- rubyforge_project:
67
+ rubyforge_project: cacheability
68
68
  rubygems_version: 1.3.5
69
69
  signing_key:
70
70
  specification_version: 3