disk_cache 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,3 @@
1
1
  module DiskCache
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/disk_cache.rb CHANGED
@@ -16,12 +16,11 @@ module DiskCache
16
16
  #
17
17
  # Returns: nil
18
18
  def put(url)
19
- url = escape(url)
20
19
  file = filepath(url)
21
20
  return nil if File.exist?(file)
22
21
 
23
22
  FileUtils.mkdir_p path(url)
24
- File.open(file, "wb") { |f| f << open(url).read }
23
+ File.open(file, "wb") { |f| f << open(escape(url)).read }
25
24
  nil
26
25
  end
27
26
 
@@ -39,7 +38,6 @@ module DiskCache
39
38
  #
40
39
  # Returns the File or nil
41
40
  def get(url)
42
- url = escape(url)
43
41
  File.open(filepath(url), "rb")
44
42
  rescue Errno::ENOENT
45
43
  nil
@@ -56,7 +54,6 @@ module DiskCache
56
54
  #
57
55
  # Returns a File
58
56
  def pget(url)
59
- url = escape(url)
60
57
  put(url)
61
58
  get(url)
62
59
  end
@@ -72,7 +69,6 @@ module DiskCache
72
69
  #
73
70
  # Returns nil
74
71
  def del(url)
75
- url = escape(url)
76
72
  FileUtils.rm filepath(url), force: true
77
73
  end
78
74
 
@@ -109,7 +105,7 @@ module DiskCache
109
105
  #
110
106
  # Returns String with hexdigest
111
107
  def hash(datum)
112
- Digest::SHA1.new.hexdigest(datum)
108
+ Digest::SHA1.new.hexdigest(escape(datum))
113
109
  end
114
110
 
115
111
  # Internal: Return the directory of the cache as a String
@@ -46,11 +46,10 @@ describe DiskCache do
46
46
 
47
47
  context "sanity" do
48
48
  let(:web) { 'http://example.com/Troll face.svg' }
49
- let(:cto) { File.read(path) }
50
49
 
51
50
  before(:each) do
52
51
  stub_request(:get, "http://example.com/Troll face.svg").
53
- to_return(body: cto)
52
+ to_return(body: File.read(path))
54
53
  end
55
54
 
56
55
  it "should handle urls with spaces" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: disk_cache
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -92,7 +92,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
92
92
  version: '0'
93
93
  segments:
94
94
  - 0
95
- hash: -1244554166794176728
95
+ hash: -3781426537467041070
96
96
  required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  none: false
98
98
  requirements:
@@ -101,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
101
  version: '0'
102
102
  segments:
103
103
  - 0
104
- hash: -1244554166794176728
104
+ hash: -3781426537467041070
105
105
  requirements: []
106
106
  rubyforge_project:
107
107
  rubygems_version: 1.8.24