dragonfly-mongoid_data_store 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/Gemfile +0 -4
- data/Guardfile +3 -3
- data/Rakefile +2 -2
- data/dragonfly-mongoid_data_store.gemspec +18 -17
- data/lib/dragonfly/mongoid_data_store.rb +10 -18
- data/lib/dragonfly/mongoid_data_store/version.rb +1 -1
- data/test/dragonfly/mongoid_data_store_test.rb +4 -16
- data/test/test_helper.rb +2 -2
- metadata +23 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d2f053305eeeb2ced2d6aa5f00e34e2ed07e3b6
|
4
|
+
data.tar.gz: 38aa8323405599845649ab978fc1cd28bbcc8cba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe4167115db4d42f317c7eab268c1b5c70013981b4c587b500b5dbdb52e912d0aec577072e819c599cf95ee4aa174e893a1d3d56ab2dc63b75a0f21f15155379
|
7
|
+
data.tar.gz: 22b24e0b8a530af202fba686d0015c99d274b74ce3b39a3bfbc03bb4e50e80750c9a392c574a0a1d5650c5a2ca0042047abcbff33c149d490f40067ed72e3607
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/Guardfile
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
# More info at https://github.com/guard/guard#readme
|
3
3
|
|
4
4
|
guard :minitest do
|
5
|
-
watch(%r{^lib/(.+)\.rb$})
|
5
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "test/#{m[1]}_test.rb" }
|
6
6
|
watch(%r{^test/.+_test\.rb$})
|
7
|
-
watch(%r{^test/test_helper\.rb$})
|
8
|
-
end
|
7
|
+
watch(%r{^test/test_helper\.rb$}) { 'test' }
|
8
|
+
end
|
data/Rakefile
CHANGED
@@ -4,28 +4,29 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'dragonfly/mongoid_data_store/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'dragonfly-mongoid_data_store'
|
8
8
|
spec.version = Dragonfly::MongoidDataStore::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
9
|
+
spec.authors = ['Tomas Celizna']
|
10
|
+
spec.email = ['tomas.celizna@gmail.com']
|
11
|
+
spec.summary = 'Dragonfly data store that uses Mongoid::GridFs.'
|
12
|
+
spec.description = 'Dragonfly data store that uses Mongoid::GridFs.'
|
13
|
+
spec.homepage = 'https://github.com/tomasc/dragonfly-mongoid_data_store'
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_dependency
|
22
|
-
spec.add_dependency
|
23
|
-
spec.add_dependency
|
21
|
+
spec.add_dependency 'dragonfly', '~> 1.0'
|
22
|
+
spec.add_dependency 'mongoid'
|
23
|
+
spec.add_dependency 'mongoid-grid_fs'
|
24
24
|
|
25
|
-
spec.add_development_dependency
|
26
|
-
spec.add_development_dependency
|
27
|
-
spec.add_development_dependency
|
28
|
-
spec.add_development_dependency
|
29
|
-
spec.add_development_dependency
|
30
|
-
spec.add_development_dependency
|
25
|
+
spec.add_development_dependency 'bundler'
|
26
|
+
spec.add_development_dependency 'coveralls'
|
27
|
+
spec.add_development_dependency 'database_cleaner', '>= 1.5.1'
|
28
|
+
spec.add_development_dependency 'guard'
|
29
|
+
spec.add_development_dependency 'guard-minitest'
|
30
|
+
spec.add_development_dependency 'minitest'
|
31
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
31
32
|
end
|
@@ -2,24 +2,17 @@ require 'dragonfly/mongoid_data_store/version'
|
|
2
2
|
require 'dragonfly'
|
3
3
|
require 'mongoid-grid_fs'
|
4
4
|
|
5
|
-
Dragonfly::App.register_datastore(:mongoid){ Dragonfly::MongoidDataStore }
|
5
|
+
Dragonfly::App.register_datastore(:mongoid) { Dragonfly::MongoidDataStore }
|
6
6
|
|
7
7
|
module Dragonfly
|
8
8
|
class MongoidDataStore
|
9
|
-
|
10
9
|
class DataNotFound < StandardError; end
|
11
10
|
|
12
|
-
# ---------------------------------------------------------------------
|
13
|
-
|
14
11
|
include Serializer
|
15
12
|
|
16
|
-
# ---------------------------------------------------------------------
|
17
|
-
|
18
13
|
OBJECT_ID = BSON::ObjectId
|
19
14
|
|
20
|
-
|
21
|
-
|
22
|
-
def write temp_object, opts={}
|
15
|
+
def write(temp_object, opts = {})
|
23
16
|
content_type = opts[:content_type] || opts[:mime_type] || 'application/octet-stream'
|
24
17
|
meta = temp_object.meta
|
25
18
|
meta = meta.merge(opts[:meta]) if opts[:meta].present?
|
@@ -30,28 +23,27 @@ module Dragonfly
|
|
30
23
|
end
|
31
24
|
end
|
32
25
|
|
33
|
-
|
34
|
-
|
35
|
-
def read uid
|
26
|
+
def read(uid)
|
36
27
|
grid_file = Mongoid::GridFS.get(uid)
|
37
28
|
|
38
29
|
meta = {}
|
39
30
|
meta = marshal_b64_decode(grid_file.meta) if grid_file.respond_to?(:meta)
|
40
|
-
meta
|
31
|
+
meta[:stored_at] = grid_file.upload_date if grid_file.respond_to?(:upload_date)
|
41
32
|
|
42
|
-
[
|
33
|
+
[grid_file.data, meta]
|
43
34
|
|
44
35
|
rescue Mongoid::Errors::DocumentNotFound => e
|
45
36
|
raise DataNotFound, "#{e} - #{uid}"
|
46
37
|
end
|
47
38
|
|
48
|
-
|
49
|
-
|
50
|
-
def destroy uid
|
39
|
+
def destroy(uid)
|
51
40
|
Mongoid::GridFs.delete(uid)
|
52
41
|
end
|
53
42
|
|
54
|
-
#
|
43
|
+
private # =============================================================
|
55
44
|
|
45
|
+
def marshal_b64_encode(object)
|
46
|
+
Dragonfly::Serializer.b64_encode(Marshal.dump(object))
|
47
|
+
end
|
56
48
|
end
|
57
49
|
end
|
@@ -3,20 +3,15 @@ require 'dragonfly/mongoid_data_store'
|
|
3
3
|
require 'dragonfly/serializer'
|
4
4
|
|
5
5
|
describe Dragonfly::MongoidDataStore do
|
6
|
-
|
7
6
|
include Dragonfly::Serializer
|
8
7
|
|
9
|
-
# ---------------------------------------------------------------------
|
10
|
-
|
11
8
|
let(:app) { Dragonfly.app }
|
12
|
-
let(:content) { Dragonfly::Content.new(app,
|
9
|
+
let(:content) { Dragonfly::Content.new(app, 'Foo Bar!') }
|
13
10
|
let(:data_store) { Dragonfly::MongoidDataStore.new }
|
14
11
|
let(:meta) { { my_meta: 'my meta' } }
|
15
12
|
|
16
|
-
# ---------------------------------------------------------------------
|
17
|
-
|
18
13
|
describe '#write' do
|
19
|
-
it
|
14
|
+
it 'stores the data in the database' do
|
20
15
|
uid = data_store.write(content)
|
21
16
|
response = Mongoid::GridFS.get(uid)
|
22
17
|
response.data.must_equal content.data
|
@@ -41,11 +36,9 @@ describe Dragonfly::MongoidDataStore do
|
|
41
36
|
end
|
42
37
|
end
|
43
38
|
|
44
|
-
# ---------------------------------------------------------------------
|
45
|
-
|
46
39
|
describe '#read' do
|
47
40
|
before do
|
48
|
-
stored_content = Mongoid::GridFS.put(content.file, content_type: 'text/plain', meta:
|
41
|
+
stored_content = Mongoid::GridFS.put(content.file, content_type: 'text/plain', meta: b64_encode(Marshal.dump(meta)))
|
49
42
|
@result = data_store.read(stored_content.id)
|
50
43
|
end
|
51
44
|
|
@@ -62,8 +55,6 @@ describe Dragonfly::MongoidDataStore do
|
|
62
55
|
end
|
63
56
|
end
|
64
57
|
|
65
|
-
# ---------------------------------------------------------------------
|
66
|
-
|
67
58
|
describe '#destroy' do
|
68
59
|
before do
|
69
60
|
@stored_content = Mongoid::GridFS.put(content.file)
|
@@ -75,7 +66,4 @@ describe Dragonfly::MongoidDataStore do
|
|
75
66
|
Mongoid::GridFS.find(_id: @stored_content.id).must_be_nil
|
76
67
|
end
|
77
68
|
end
|
78
|
-
|
79
|
-
# ---------------------------------------------------------------------
|
80
|
-
|
81
|
-
end
|
69
|
+
end
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dragonfly-mongoid_data_store
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Tomas Celizna
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dragonfly
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: coveralls
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,7 +123,7 @@ dependencies:
|
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
126
|
+
name: minitest
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - ">="
|
@@ -136,6 +136,20 @@ dependencies:
|
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rake
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '10.0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '10.0'
|
139
153
|
description: Dragonfly data store that uses Mongoid::GridFs.
|
140
154
|
email:
|
141
155
|
- tomas.celizna@gmail.com
|
@@ -176,7 +190,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
190
|
version: '0'
|
177
191
|
requirements: []
|
178
192
|
rubyforge_project:
|
179
|
-
rubygems_version: 2.
|
193
|
+
rubygems_version: 2.4.5.1
|
180
194
|
signing_key:
|
181
195
|
specification_version: 4
|
182
196
|
summary: Dragonfly data store that uses Mongoid::GridFs.
|