mongo_mapper_ext 0.2.5 → 0.2.6

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.
@@ -2,8 +2,8 @@ unless Class.method_defined? :alias
2
2
  Class.class_eval do
3
3
  def alias name = nil
4
4
  if name
5
- name.must_be.a String
6
- name.must_not_be.blank
5
+ raise "alias must be a String" unless name.is_a? String
6
+ raise "alias must not be blank" if name.blank?
7
7
  @alias = name.to_s
8
8
  else
9
9
  @alias ||= self.name.split('::').last
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo_mapper_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -166,9 +166,6 @@ files:
166
166
  - lib/mongo_mapper_ext/mongo_mapper/support.rb
167
167
  - lib/mongo_mapper_ext/mongo_mapper/view_helpers.rb
168
168
  - lib/mongo_mapper_ext/mongo_mapper.rb
169
- - lib/mongo_mapper_ext/rad/file_uploader.rb
170
- - lib/mongo_mapper_ext/rad/spec.rb
171
- - lib/mongo_mapper_ext/rad.rb
172
169
  - lib/mongo_mapper_ext/tasks.rb
173
170
  - spec/carrier_wave/carrier_wave_spec/plane.jpg
174
171
  - spec/carrier_wave/carrier_wave_spec.rb
@@ -183,10 +180,6 @@ files:
183
180
  - spec/mongo_mapper/migration_spec.rb
184
181
  - spec/mongo_mapper/mongo_mapper_spec.rb
185
182
  - spec/mongo_mapper/spec_helper.rb
186
- - spec/rad/spec_helper.rb
187
- - spec/rad/uploading_spec/ship.jpg
188
- - "spec/rad/uploading_spec/\xD1\x84\xD0\xB0\xD0\xB8\xCC\x86\xD0\xBB \xD1\x81 \xD0\xBF\xD1\x80\xD0\xBE\xD0\xB1\xD0\xB5\xD0\xBB\xD0\xB0\xD0\xBC\xD0\xB8.txt"
189
- - spec/rad/uploading_spec.rb
190
183
  has_rdoc: true
191
184
  homepage: http://github.com/alexeypetrushin/mongo_mapper_ext
192
185
  licenses: []
@@ -1,26 +0,0 @@
1
- require 'carrierwave/processing/mini_magick'
2
-
3
- class Models::FileUploader < CarrierWave::Uploader::Base
4
- include CarrierWave::MiniMagick
5
-
6
- storage rad.config.fs.type(:file)
7
-
8
- # def sanitize_regexp
9
- # /[^[:word:]\.\-\+\s_]/i
10
- # end
11
-
12
- def file_path
13
- "#{rad.config.fs.prefix('/fs')}/system/#{model.class.model_name.underscore}/#{model.id}"
14
- end
15
-
16
- def store_dir
17
- "#{root}#{file_path}"
18
- end
19
-
20
- def extension_white_list
21
- [/.*/]
22
- end
23
-
24
- def cache_dir; rad.config.fs.cache_path! end
25
- def root; rad.config.fs.path! end
26
- end
@@ -1,38 +0,0 @@
1
- require 'mongo_mapper_ext/rad'
2
-
3
- require 'mongo_mapper_ext/mongo_mapper/spec'
4
-
5
- #
6
- # Files
7
- #
8
- rspec do
9
- class << self
10
- def with_files
11
- path, cache_path = '/tmp/spec_fs', '/tmp/spec_fs_cache'
12
-
13
- before do
14
- rad.config.merge!({fs: {path: path, cache_path: cache_path}}, override: true)
15
-
16
- Models::FileUploader.storage :file
17
-
18
- CarrierWave.configure do |config|
19
- config.storage = :file
20
- config.enable_processing = false
21
-
22
- config.cache_dir = rad.config.fs.cache_path!
23
- config.root = rad.config.fs.path!
24
- end
25
- end
26
-
27
- before do
28
- path.to_dir.destroy
29
- cache_path.to_dir.destroy
30
- end
31
-
32
- after do
33
- path.to_dir.destroy
34
- cache_path.to_dir.destroy
35
- end
36
- end
37
- end
38
- end
@@ -1,9 +0,0 @@
1
- require 'rad'
2
-
3
- require 'mongo_mapper_ext/mongo_mapper'
4
- require 'mongo_mapper_ext/carrier_wave'
5
-
6
- module Models
7
- end
8
-
9
- require 'mongo_mapper_ext/rad/file_uploader'
@@ -1,10 +0,0 @@
1
- require "mongo_mapper"
2
-
3
- require 'rspec_ext'
4
-
5
- require "mongo_mapper_ext/mongo_mapper"
6
- require "mongo_mapper_ext/carrier_wave"
7
- require "mongo_mapper_ext/rad"
8
-
9
- require "mongo_mapper_ext/mongo_mapper/spec"
10
- require "mongo_mapper_ext/rad/spec"
Binary file
@@ -1,48 +0,0 @@
1
- require 'rad/spec_helper'
2
-
3
- describe "Uploading" do
4
- with_tmp_spec_dir
5
- with_mongo_mapper
6
- with_files
7
-
8
- before :all do
9
- class ShipUploader < Models::FileUploader
10
- end
11
-
12
- class Ship
13
- include MongoMapper::Document
14
-
15
- key :name
16
- validates_uniqueness_of :name
17
-
18
- file_key :image, ShipUploader
19
- end
20
- end
21
- after(:all){remove_constants :Ship, :ShipUploader}
22
-
23
- it "should upload images" do
24
- ship = nil
25
- File.open "#{spec_dir}/ship.jpg" do |f|
26
- ship = Ship.new image: f
27
- ship.save!
28
- end
29
- ship.image.url.should =~ /\/ship\.jpg/
30
- ship.image_filename.should =~ /ship\.jpg/
31
- ship.image.path.should =~ /\/ship\.jpg/
32
- end
33
-
34
- it "should preserve spaces and unicode characters in filename" do
35
- File.open "#{spec_dir}/файл с пробелами.txt" do |f|
36
- ship = Ship.new image: f
37
-
38
- ship.image.url.should =~ /\/файл с пробелами\.txt/
39
- ship.image.filename =~ /файл с пробелами\.txt/
40
- ship.image.path =~ /\/файл с пробелами\.txt/
41
-
42
- # ship.smart_url.should =~ /files\/file with spaces\/file with spaces\.txt\?\d/
43
- # f.smart_url.should =~ /files\/data\/ship\?\d+/
44
- # f.smart_url(:icon).should =~ /images\/mime\/dat_icon\.png/
45
- # f.smart_url(:thumb).should =~ /images\/mime\/dat_thumb\.png/
46
- end
47
- end
48
- end