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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 29cfba20d2b82f3a2581156273282283970097d6
4
- data.tar.gz: adc76093e8d01f11484ff464c2ee52d641aa3d3f
3
+ metadata.gz: 2d2f053305eeeb2ced2d6aa5f00e34e2ed07e3b6
4
+ data.tar.gz: 38aa8323405599845649ab978fc1cd28bbcc8cba
5
5
  SHA512:
6
- metadata.gz: cd09e8b1fca1d0ee89c06804eeea0f471ed28c7c16047c874d73e5b7386a2d8b95f98ae4bacb06e1b6ea3372692e77e71a38741e3c9000840ba41833747f64b2
7
- data.tar.gz: 0372269251ad3442532c4ea6a76c7fc755e9c6d9eb5f0aeef3d4a1e1eca24461031dfa4b1422facd339f8fc8f815777a735ee1d999f9b76cfcaaa2d9daa96749
6
+ metadata.gz: fe4167115db4d42f317c7eab268c1b5c70013981b4c587b500b5dbdb52e912d0aec577072e819c599cf95ee4aa174e893a1d3d56ab2dc63b75a0f21f15155379
7
+ data.tar.gz: 22b24e0b8a530af202fba686d0015c99d274b74ce3b39a3bfbc03bb4e50e80750c9a392c574a0a1d5650c5a2ca0042047abcbff33c149d490f40067ed72e3607
data/.travis.yml CHANGED
@@ -2,7 +2,7 @@ language: ruby
2
2
  cache: bundler
3
3
  script: 'bundle exec rake'
4
4
  rvm:
5
- - 2.2.4
5
+ - 2.2.5
6
6
  services:
7
7
  - mongodb
8
8
 
data/Gemfile CHANGED
@@ -2,7 +2,3 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in dragonfly-mongoid_data_store.gemspec
4
4
  gemspec
5
-
6
- group :test do
7
- gem 'database_cleaner', git: 'https://github.com/DatabaseCleaner/database_cleaner.git'
8
- end
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$}) { |m| "test/#{m[1]}_test.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$}) { 'test' }
8
- end
7
+ watch(%r{^test/test_helper\.rb$}) { 'test' }
8
+ end
data/Rakefile CHANGED
@@ -1,9 +1,9 @@
1
1
  require 'bundler/gem_tasks'
2
2
  require 'rake/testtask'
3
-
3
+
4
4
  Rake::TestTask.new do |t|
5
5
  t.libs << 'test'
6
6
  t.pattern = 'test/**/*_test.rb'
7
7
  end
8
8
 
9
- task :default => :test
9
+ task default: :test
@@ -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 = "dragonfly-mongoid_data_store"
7
+ spec.name = 'dragonfly-mongoid_data_store'
8
8
  spec.version = Dragonfly::MongoidDataStore::VERSION
9
- spec.authors = ["Tomáš Celizna"]
10
- spec.email = ["tomas.celizna@gmail.com"]
11
- spec.summary = %q{Dragonfly data store that uses Mongoid::GridFs.}
12
- spec.description = %q{Dragonfly data store that uses Mongoid::GridFs.}
13
- spec.homepage = "https://github.com/tomasc/dragonfly-mongoid_data_store"
14
- spec.license = "MIT"
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 = ["lib"]
19
+ spec.require_paths = ['lib']
20
20
 
21
- spec.add_dependency "dragonfly", "~> 1.0"
22
- spec.add_dependency "mongoid"
23
- spec.add_dependency "mongoid-grid_fs"
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 "bundler", "~> 1.6"
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 "rake"
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.merge!(stored_at: grid_file.upload_date) if grid_file.respond_to?(:upload_date)
31
+ meta[:stored_at] = grid_file.upload_date if grid_file.respond_to?(:upload_date)
41
32
 
42
- [ grid_file.data, meta ]
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
@@ -1,5 +1,5 @@
1
1
  module Dragonfly
2
2
  class MongoidDataStore
3
- VERSION = "0.1.3"
3
+ VERSION = '0.1.4'.freeze
4
4
  end
5
5
  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, "Foo Bar!") }
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 "stores the data in the database" do
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: marshal_b64_encode(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
@@ -6,8 +6,8 @@ require 'dragonfly/mongoid_data_store'
6
6
  require 'rubygems'
7
7
  require 'database_cleaner'
8
8
 
9
- if ENV["CI"]
10
- require "coveralls"
9
+ if ENV['CI']
10
+ require 'coveralls'
11
11
  Coveralls.wear!
12
12
  end
13
13
 
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.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
- - Tomáš Celizna
7
+ - Tomas Celizna
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-27 00:00:00.000000000 Z
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: '1.6'
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: '1.6'
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: rake
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.6.6
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.