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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: edf99ee6da508219eafbbcbc063fc4746fee1282
4
- data.tar.gz: bba409b91e1dfb367a79a89583ebdbf0e22cf270
3
+ metadata.gz: 03dbf480fc489d97788200da4598d5e290185222
4
+ data.tar.gz: eeb3abe19856c898177f5149ae38f658a2811fe5
5
5
  SHA512:
6
- metadata.gz: 7740ace89d6a2e5d657a7a112db9bdd060b52b1cc627ee06a54d8c2405a3dd8e11116da0954c16568f9c383d2e9d87c7ddffd9fcf3f2534d2a647b76c7cb9520
7
- data.tar.gz: 7159e4522bafe51a929b9eab3b39814939842cf12fac5980689088de2b9dceebd9dfad24fd0af753a2f9c90dd8d884130ee5d3cf0e91bd07cb3a273a26421e05
6
+ metadata.gz: 1b04beffe73ca3e1e3ed33aeed15afbe5db890ca687392c0b452b065ab08e1cfc9670fd4b75c480a9491d0429f565f21de8935755d68180ed94ec6491b4f4fff
7
+ data.tar.gz: a9cdde7c843da1f1628c4ab11097bae5b35cc9cf418cadabbed87f83cdff1547fc290277e9fb43973d7d329a9d58703e0950739f133ebb48df87e772ebd39e51
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in refile-memory.gemspec
4
4
  gemspec
5
+
6
+ gem "refile", github: "elabs/refile"
data/Rakefile CHANGED
@@ -1,2 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task default: "spec"
2
7
 
@@ -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 ArgumentError, "are you sure? this will remove all files in the backend, call as `clear!(:confirm)` if you're sure you want to do this" unless confirm == :confirm
51
+ raise Refile::Confirm unless confirm == :confirm
51
52
  @store = {}
52
53
  end
53
54
  end
@@ -1,5 +1,5 @@
1
1
  module Refile
2
2
  module Memory
3
- VERSION = "0.1.0"
3
+ VERSION = "0.2.0"
4
4
  end
5
5
  end
@@ -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.1.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: 2014-12-09 00:00:00.000000000 Z
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.3
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: