mongoid-grid_fs 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,5 @@
1
+ module Mongoid
2
+ class GridFs
3
+ VERSION = "2.1.0"
4
+ end
5
+ end
data/test/helper.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
+ require 'rails'
3
4
  require 'stringio'
4
5
 
5
6
  class SIO < StringIO
@@ -11,17 +12,12 @@ class SIO < StringIO
11
12
  end
12
13
  end
13
14
 
14
-
15
15
  require_relative 'testing'
16
- require_relative '../lib/mongoid-grid_fs.rb'
16
+ require_relative '../lib/mongoid/grid_fs'
17
17
 
18
18
  Mongoid.configure do |config|
19
19
  config.connect_to('mongoid-grid_fs_test')
20
20
  end
21
21
 
22
- BEGIN {
23
- gem 'rails', '>= 3', '< 4'
24
- require 'rails'
25
- require 'active_model'
26
- }
27
-
22
+ # Avoid annoying deprecation warning
23
+ I18n.enforce_available_locales = false
@@ -3,13 +3,11 @@ require_relative 'helper'
3
3
  Testing Mongoid::GridFs do
4
4
  ##
5
5
  #
6
- GridFS =
7
- GridFs =
8
- Mongoid::GridFS
6
+ GridFs = Mongoid::GridFs
9
7
 
10
8
  prepare do
11
- GridFS::File.delete_all
12
- GridFS::Chunk.delete_all
9
+ GridFs::File.delete_all
10
+ GridFs::Chunk.delete_all
13
11
  end
14
12
 
15
13
  ##
@@ -20,7 +18,7 @@ Testing Mongoid::GridFs do
20
18
  filename = __FILE__
21
19
  basename = File.basename(filename)
22
20
 
23
- g = assert{ GridFS.put(filename) }
21
+ g = assert{ GridFs.put(filename) }
24
22
 
25
23
  assert{ g.filename =~ %r| #{ object_id_re } / #{ basename } \Z|imox }
26
24
  assert{ g.content_type == "application/x-ruby" }
@@ -30,7 +28,7 @@ Testing Mongoid::GridFs do
30
28
  test 'with a :filename' do
31
29
  filename = 'path/info/a.rb'
32
30
 
33
- g = assert{ GridFS.put(__FILE__, :filename => filename) }
31
+ g = assert{ GridFs.put(__FILE__, :filename => filename) }
34
32
 
35
33
  assert{ g.filename == filename }
36
34
  end
@@ -38,7 +36,7 @@ Testing Mongoid::GridFs do
38
36
  test 'with your own attributes' do
39
37
  my_value = "my_value"
40
38
 
41
- g = assert{ GridFS.put(__FILE__, :my_value => my_value) }
39
+ g = assert{ GridFs.put(__FILE__, :my_value => my_value) }
42
40
 
43
41
  assert{ g.my_value == my_value }
44
42
  end
@@ -57,7 +55,7 @@ Testing Mongoid::GridFs do
57
55
  context '#get' do
58
56
 
59
57
  test 'default' do
60
- id = assert{ GridFS::File.last.id }
58
+ id = assert{ GridFs::File.last.id }
61
59
  g = assert{ GridFs.get(id) }
62
60
  end
63
61
 
@@ -68,7 +66,7 @@ Testing Mongoid::GridFs do
68
66
  context '#delete' do
69
67
 
70
68
  test 'default' do
71
- id = assert{ GridFS::File.last.id }
69
+ id = assert{ GridFs::File.last.id }
72
70
  g = assert{ GridFs.get(id) }
73
71
  assert{ GridFs.delete(id) }
74
72
  assert_raises( Mongoid::Errors::DocumentNotFound){ GridFs.get(id) }
@@ -110,7 +108,7 @@ Testing Mongoid::GridFs do
110
108
  context 'data uris' do
111
109
 
112
110
  test 'default' do
113
- id = assert{ GridFS::File.last.id }
111
+ id = assert{ GridFs::File.last.id }
114
112
  g = assert{ GridFs.get(id) }
115
113
 
116
114
  content_type = g.content_type
@@ -128,32 +126,32 @@ Testing Mongoid::GridFs do
128
126
  context 'slicing and dicing' do
129
127
 
130
128
  test 'range' do
131
- id = assert { GridFS::File.last.id }
129
+ id = assert { GridFs::File.last.id }
132
130
  g = assert { GridFs.get(id) }
133
131
  assert { g.data[1..3] == g.slice(1..3) }
134
132
  end
135
133
 
136
134
  test 'start and length' do
137
- id = assert { GridFS::File.last.id }
135
+ id = assert { GridFs::File.last.id }
138
136
  g = assert { GridFs.get(id) }
139
137
  assert { g.data[1, 3] == g.slice(1, 3) }
140
138
  end
141
139
 
142
140
  test 'just a single param' do
143
- id = assert { GridFS::File.last.id }
141
+ id = assert { GridFs::File.last.id }
144
142
  g = assert {GridFs.get(id) }
145
143
 
146
144
  assert {g.data[1] == g.slice(1) }
147
145
  end
148
146
 
149
147
  test 'getting the last index' do
150
- id = assert { GridFS::File.last.id }
148
+ id = assert { GridFs::File.last.id }
151
149
  g = assert {GridFs.get(id) }
152
150
  assert {g.data[-1] == g.slice(-1) }
153
151
  end
154
152
 
155
153
  test 'yanking from the end of the data' do
156
- id = assert { GridFS::File.last.id }
154
+ id = assert { GridFs::File.last.id }
157
155
  g = assert {GridFs.get(id) }
158
156
  assert {g.data[-3, 2] == g.slice(-3, 2) }
159
157
  end
@@ -180,13 +178,14 @@ Testing Mongoid::GridFs do
180
178
  Tempfile.new("mongoid-grid_fs~43mb.#{suffix}")
181
179
  end
182
180
 
183
- assert system("dd if=/dev/zero of=#{orig.path} bs=#{43*1024*1024} count=1 &> /dev/null")
181
+ kilobyte = "x" * 1024
182
+ (43*1024).times { orig.write(kilobyte) }
184
183
 
185
184
  GridFs.get(GridFs.put(orig.path).id).each do |chunk|
186
185
  copy.print(chunk.to_s)
187
186
  end
188
187
 
189
- assert { File.size(copy.path) == File.size(orig.path) }
188
+ assert { File.size(orig.path) == File.size(copy.path) }
190
189
  end
191
190
  end
192
191
 
@@ -235,7 +234,7 @@ Testing Mongoid::GridFs do
235
234
  expanded = proc{|paths| Array(paths).map{|path| File.expand_path(path)}}
236
235
 
237
236
  assert{
238
- expanded[ Mongoid::GridFS::Engine.paths['app/models'] ] == expanded[ libdir ]
237
+ expanded[ Mongoid::GridFs::Engine.paths['app/models'] ] == expanded[ libdir ]
239
238
  }
240
239
  end
241
240
  end
metadata CHANGED
@@ -1,75 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongoid-grid_fs
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ara T. Howard
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-16 00:00:00.000000000 Z
11
+ date: 2014-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mongoid
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ! '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3.0'
20
- - - <
20
+ - - "<"
21
21
  - !ruby/object:Gem::Version
22
22
  version: '5.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ! '>='
27
+ - - ">="
28
28
  - !ruby/object:Gem::Version
29
29
  version: '3.0'
30
- - - <
30
+ - - "<"
31
31
  - !ruby/object:Gem::Version
32
32
  version: '5.0'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: mime-types
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ! '>='
37
+ - - ">="
38
38
  - !ruby/object:Gem::Version
39
39
  version: '1.0'
40
- - - <
40
+ - - "<"
41
41
  - !ruby/object:Gem::Version
42
42
  version: '3.0'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - ! '>='
47
+ - - ">="
48
48
  - !ruby/object:Gem::Version
49
49
  version: '1.0'
50
- - - <
50
+ - - "<"
51
51
  - !ruby/object:Gem::Version
52
52
  version: '3.0'
53
- description: ! 'description: mongoid-grid_fs kicks the ass'
54
- email: ara.t.howard@gmail.com
53
+ description: A pure Mongoid/Moped implementation of the MongoDB GridFS specification
54
+ email:
55
+ - ara.t.howard@gmail.com
55
56
  executables: []
56
57
  extensions: []
57
58
  extra_rdoc_files: []
58
59
  files:
59
- - Gemfile
60
60
  - LICENSE
61
61
  - README.md
62
62
  - Rakefile
63
- - config.rb
64
- - gemfiles/mongoid-3.0.gemfile
65
- - gemfiles/mongoid-3.1.gemfile
66
- - gemfiles/mongoid-4.0.gemfile
67
63
  - lib/app/models/mongoid/grid_fs.rb
68
64
  - lib/app/models/mongoid/grid_fs/fs/chunk.rb
69
65
  - lib/app/models/mongoid/grid_fs/fs/file.rb
70
66
  - lib/mongoid-grid_fs.rb
71
- - mongoid-grid_fs.gemspec
72
- - script/shell
67
+ - lib/mongoid/grid_fs.rb
68
+ - lib/mongoid/grid_fs/version.rb
73
69
  - test/helper.rb
74
70
  - test/mongoid-grid_fs_test.rb
75
71
  - test/testing.rb
@@ -83,18 +79,21 @@ require_paths:
83
79
  - lib
84
80
  required_ruby_version: !ruby/object:Gem::Requirement
85
81
  requirements:
86
- - - ! '>='
82
+ - - ">="
87
83
  - !ruby/object:Gem::Version
88
84
  version: '0'
89
85
  required_rubygems_version: !ruby/object:Gem::Requirement
90
86
  requirements:
91
- - - ! '>='
87
+ - - ">="
92
88
  - !ruby/object:Gem::Version
93
89
  version: '0'
94
90
  requirements: []
95
- rubyforge_project: codeforpeople
96
- rubygems_version: 2.0.3
91
+ rubyforge_project:
92
+ rubygems_version: 2.2.2
97
93
  signing_key:
98
94
  specification_version: 4
99
- summary: mongoid-grid_fs
100
- test_files: []
95
+ summary: A MongoDB GridFS implementation for Mongoid
96
+ test_files:
97
+ - test/helper.rb
98
+ - test/mongoid-grid_fs_test.rb
99
+ - test/testing.rb
data/Gemfile DELETED
@@ -1,5 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem "rails"
4
-
5
- gemspec
data/config.rb DELETED
@@ -1,5 +0,0 @@
1
-
2
- object "Mongoid::GridFs"
3
-
4
- synopsis "a mongoid 3/moped compatible implementation of the grid_fs specification"
5
-
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem "rails"
4
- gem "mongoid", github: "mongoid/mongoid", branch: "3.0.0-stable"
5
-
6
- gemspec path: "../"
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem "rails"
4
- gem "mongoid", github: "mongoid/mongoid", branch: "3.1.0-stable"
5
-
6
- gemspec path: "../"
@@ -1,6 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem "rails", github: "rails/rails", branch: "4-0-stable"
4
- gem "mongoid", github: "mongoid/mongoid", branch: "master"
5
-
6
- gemspec path: "../"
@@ -1,58 +0,0 @@
1
- ## mongoid-grid_fs.gemspec
2
- #
3
-
4
- Gem::Specification::new do |spec|
5
- spec.name = "mongoid-grid_fs"
6
- spec.version = "2.0.0"
7
- spec.platform = Gem::Platform::RUBY
8
- spec.summary = "mongoid-grid_fs"
9
- spec.description = "description: mongoid-grid_fs kicks the ass"
10
- spec.license = "Ruby"
11
-
12
- spec.files =
13
- ["Gemfile",
14
- "LICENSE",
15
- "README.md",
16
- "Rakefile",
17
- "config.rb",
18
- "gemfiles",
19
- "gemfiles/mongoid-3.0.gemfile",
20
- "gemfiles/mongoid-3.1.gemfile",
21
- "gemfiles/mongoid-4.0.gemfile",
22
- "lib",
23
- "lib/app",
24
- "lib/app/models",
25
- "lib/app/models/mongoid",
26
- "lib/app/models/mongoid/grid_fs",
27
- "lib/app/models/mongoid/grid_fs.rb",
28
- "lib/app/models/mongoid/grid_fs/fs",
29
- "lib/app/models/mongoid/grid_fs/fs/chunk.rb",
30
- "lib/app/models/mongoid/grid_fs/fs/file.rb",
31
- "lib/mongoid-grid_fs.rb",
32
- "mongoid-grid_fs.gemspec",
33
- "script",
34
- "script/shell",
35
- "test",
36
- "test/helper.rb",
37
- "test/mongoid-grid_fs_test.rb",
38
- "test/testing.rb"]
39
-
40
- spec.executables = []
41
-
42
- spec.require_path = "lib"
43
-
44
- spec.test_files = nil
45
-
46
-
47
- spec.add_dependency(*["mongoid", ">= 3.0", "< 5.0"])
48
-
49
- spec.add_dependency(*["mime-types", ">= 1.0", "< 3.0"])
50
-
51
-
52
- spec.extensions.push(*[])
53
-
54
- spec.rubyforge_project = "codeforpeople"
55
- spec.author = "Ara T. Howard"
56
- spec.email = "ara.t.howard@gmail.com"
57
- spec.homepage = "https://github.com/ahoward/mongoid-grid_fs"
58
- end
data/script/shell DELETED
@@ -1,51 +0,0 @@
1
- #! /usr/bin/env ruby
2
-
3
- #
4
- gem 'rails', '>= 3', '< 4'
5
- require 'rails'
6
- require 'active_model'
7
-
8
- #
9
- require 'pry'
10
-
11
- #
12
- require_relative '../lib/mongoid-grid_fs.rb'
13
-
14
- #
15
- Mongoid.configure do |config|
16
- config.connect_to('mongoid-grid_fs_test')
17
- end
18
-
19
- #
20
- require 'irb'
21
-
22
- $FUCKING_HACK = IRB.method(:load_modules)
23
-
24
- def IRB.load_modules
25
- $FUCKING_HACK.call()
26
-
27
- prompt = 'mongoid_grid_fs'
28
-
29
- IRB.conf[:PROMPT][:RO] = {
30
- :PROMPT_I=>"#{ prompt }:%03n:%i> ",
31
- :PROMPT_N=>"#{ prompt }:%03n:%i> ",
32
- :PROMPT_S=>"#{ prompt }:%03n:%i%l ",
33
- :PROMPT_C=>"#{ prompt }:%03n:%i* ",
34
- :RETURN=>"=> %s\n"
35
- }
36
-
37
- IRB.conf[:PROMPT_MODE] = :RO
38
- IRB.conf[:AUTO_INDENT] = true
39
- end
40
-
41
- #
42
- module ::Kernel
43
- def grid_fs
44
- Mongoid::GridFS
45
- end
46
- end
47
-
48
- #
49
- ARGV.clear
50
-
51
- ::IRB.start