filecache 0.1.0 → 1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README +11 -1
  2. data/lib/filecache.rb +4 -0
  3. metadata +3 -3
data/README CHANGED
@@ -1,9 +1,19 @@
1
1
  = FileCache
2
2
 
3
- FileCache is a file-based caching library for Ruby
3
+ FileCache is a file-based caching library for Ruby. It's
4
+ available for download from RubyForge[http://rubyforge.org/projects/filecache/]
5
+
6
+ = Installation
7
+
8
+ gem install -r filecache
9
+
10
+ (On a Unix-like system you'll probably want to run that with sudo.)
4
11
 
5
12
  = Synopsis
6
13
 
14
+ require 'rubygems'
15
+ require 'filecache'
16
+
7
17
  cache = FileCache.new
8
18
  cache.set(:key, "value")
9
19
  puts cache.get(:key) # "value"
@@ -23,6 +23,7 @@ class FileCache
23
23
  @root_dir = root_dir
24
24
  @expiry = expiry
25
25
  @depth = depth > MAX_DEPTH ? MAX_DEPTH : depth
26
+ FileUtils.mkdir_p(get_root)
26
27
  end
27
28
 
28
29
  # Set a cache value for the given key. If the cache contains an existing value for
@@ -62,6 +63,7 @@ class FileCache
62
63
  def clear
63
64
  if File.exists?(get_root)
64
65
  FileUtils.rm_r(get_root)
66
+ FileUtils.mkdir_p(get_root)
65
67
  end
66
68
  end
67
69
 
@@ -95,6 +97,8 @@ private
95
97
  if File.directory?(path)
96
98
  purge_dir(path)
97
99
  elsif @t_purge - File.new(path).mtime >= @expiry
100
+ # Ignore files starting with . - we didn't create those
101
+ next if f =~ /^\./
98
102
  FileUtils.rm(path)
99
103
  end
100
104
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filecache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: "1.0"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Whitaker
@@ -9,7 +9,7 @@ autorequire: filecache
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-07-07 00:00:00 +01:00
12
+ date: 2009-08-29 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15
 
@@ -48,7 +48,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
48
48
  version:
49
49
  requirements: []
50
50
 
51
- rubyforge_project:
51
+ rubyforge_project: filecache
52
52
  rubygems_version: 1.2.0
53
53
  signing_key:
54
54
  specification_version: 2