refile-memory 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/Rakefile +5 -0
- data/lib/refile/memory.rb +11 -10
- data/lib/refile/memory/version.rb +1 -1
- data/refile-memory.gemspec +1 -0
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03dbf480fc489d97788200da4598d5e290185222
|
4
|
+
data.tar.gz: eeb3abe19856c898177f5149ae38f658a2811fe5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1b04beffe73ca3e1e3ed33aeed15afbe5db890ca687392c0b452b065ab08e1cfc9670fd4b75c480a9491d0429f565f21de8935755d68180ed94ec6491b4f4fff
|
7
|
+
data.tar.gz: a9cdde7c843da1f1628c4ab11097bae5b35cc9cf418cadabbed87f83cdff1547fc290277e9fb43973d7d329a9d58703e0950739f133ebb48df87e772ebd39e51
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/lib/refile/memory.rb
CHANGED
@@ -4,17 +4,18 @@ require "refile/memory/version"
|
|
4
4
|
module Refile
|
5
5
|
module Memory
|
6
6
|
class Backend
|
7
|
+
extend Refile::BackendMacros
|
7
8
|
attr_reader :directory
|
8
9
|
|
10
|
+
attr_reader :max_size
|
11
|
+
|
9
12
|
def initialize(max_size: nil, hasher: Refile::RandomHasher.new)
|
10
13
|
@hasher = hasher
|
11
14
|
@max_size = max_size
|
12
15
|
@store = {}
|
13
16
|
end
|
14
17
|
|
15
|
-
def upload(uploadable)
|
16
|
-
Refile.verify_uploadable(uploadable, @max_size)
|
17
|
-
|
18
|
+
verify_uploadable def upload(uploadable)
|
18
19
|
id = @hasher.hash(uploadable)
|
19
20
|
|
20
21
|
@store[id] = uploadable.read
|
@@ -22,32 +23,32 @@ module Refile
|
|
22
23
|
Refile::File.new(self, id)
|
23
24
|
end
|
24
25
|
|
25
|
-
def get(id)
|
26
|
+
verify_id def get(id)
|
26
27
|
Refile::File.new(self, id)
|
27
28
|
end
|
28
29
|
|
29
|
-
def delete(id)
|
30
|
+
verify_id def delete(id)
|
30
31
|
@store.delete(id)
|
31
32
|
end
|
32
33
|
|
33
|
-
def open(id)
|
34
|
+
verify_id def open(id)
|
34
35
|
StringIO.new(@store[id])
|
35
36
|
end
|
36
37
|
|
37
|
-
def read(id)
|
38
|
+
verify_id def read(id)
|
38
39
|
@store[id]
|
39
40
|
end
|
40
41
|
|
41
|
-
def size(id)
|
42
|
+
verify_id def size(id)
|
42
43
|
@store[id].bytesize if exists?(id)
|
43
44
|
end
|
44
45
|
|
45
|
-
def exists?(id)
|
46
|
+
verify_id def exists?(id)
|
46
47
|
@store.has_key?(id)
|
47
48
|
end
|
48
49
|
|
49
50
|
def clear!(confirm = nil)
|
50
|
-
raise
|
51
|
+
raise Refile::Confirm unless confirm == :confirm
|
51
52
|
@store = {}
|
52
53
|
end
|
53
54
|
end
|
data/refile-memory.gemspec
CHANGED
@@ -20,6 +20,7 @@ Gem::Specification.new do |spec|
|
|
20
20
|
|
21
21
|
spec.add_dependency "refile"
|
22
22
|
|
23
|
+
spec.add_development_dependency "webmock", "~> 1.20.4"
|
23
24
|
spec.add_development_dependency "bundler", "~> 1.7"
|
24
25
|
spec.add_development_dependency "rake", "~> 10.0"
|
25
26
|
spec.add_development_dependency "rspec", "~> 3.0"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: refile-memory
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jonas Nicklas
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: refile
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: webmock
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 1.20.4
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 1.20.4
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -102,9 +116,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
102
116
|
version: '0'
|
103
117
|
requirements: []
|
104
118
|
rubyforge_project:
|
105
|
-
rubygems_version: 2.4.
|
119
|
+
rubygems_version: 2.4.5.1
|
106
120
|
signing_key:
|
107
121
|
specification_version: 4
|
108
122
|
summary: In memory backend for Refile
|
109
123
|
test_files:
|
110
124
|
- spec/refile/memory_spec.rb
|
125
|
+
has_rdoc:
|