has_media 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.2
1
+ 0.2.3
@@ -0,0 +1,4 @@
1
+ class Document < Medium
2
+ set_table_name 'media'
3
+ mount_uploader :file, DocumentUploader
4
+ end
@@ -0,0 +1,7 @@
1
+ # encoding: utf-8
2
+
3
+ class DocumentUploader < MediumUploader
4
+
5
+ # Choose what kind of storage to use for this uploader
6
+ storage :file
7
+ end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{has_media}
8
- s.version = "0.2.2"
8
+ s.version = "0.2.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["klacointe", "spk"]
12
- s.date = %q{2010-11-05}
12
+ s.date = %q{2010-11-09}
13
13
  s.description = %q{Media Managment Library for ActiveRecord and Carrierwave}
14
14
  s.email = %q{kevinlacointe@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -26,10 +26,12 @@ Gem::Specification.new do |s|
26
26
  "VERSION",
27
27
  "config/locales/en.yml",
28
28
  "examples/models/audio.rb",
29
+ "examples/models/document.rb",
29
30
  "examples/models/image.rb",
30
31
  "examples/models/pdf.rb",
31
32
  "examples/models/video.rb",
32
33
  "examples/uploaders/audio_uploader.rb",
34
+ "examples/uploaders/document_uploader.rb",
33
35
  "examples/uploaders/image_uploader.rb",
34
36
  "examples/uploaders/pdf_uploader.rb",
35
37
  "examples/uploaders/video_uploader.rb",
@@ -68,9 +70,11 @@ Gem::Specification.new do |s|
68
70
  "examples/uploaders/pdf_uploader.rb",
69
71
  "examples/uploaders/video_uploader.rb",
70
72
  "examples/uploaders/audio_uploader.rb",
73
+ "examples/uploaders/document_uploader.rb",
71
74
  "examples/models/image.rb",
72
75
  "examples/models/pdf.rb",
73
76
  "examples/models/audio.rb",
77
+ "examples/models/document.rb",
74
78
  "examples/models/video.rb"
75
79
  ]
76
80
 
@@ -1,4 +1,4 @@
1
- # Set the directory path to use to store media
1
+ # Set the directory path to use to store media in public folder
2
2
  HasMedia.directory_path = "media"
3
3
 
4
4
  # Set the base uri to access media
@@ -43,7 +43,7 @@ class Medium < ActiveRecord::Base
43
43
  medium_types = [klass]
44
44
  end
45
45
  klass = medium_types.find do |k|
46
- HasMedia.medium_types[k.to_s].include?(mime_type)
46
+ HasMedia.medium_types[k.to_s].empty? || HasMedia.medium_types[k.to_s].include?(mime_type)
47
47
  end
48
48
  if klass.nil?
49
49
  object.media_errors = [HasMedia.errors_messages[:type_error]]
@@ -13,7 +13,7 @@ class MediumUploader < CarrierWave::Uploader::Base
13
13
 
14
14
  # see https://gist.github.com/519484
15
15
  def root
16
- CarrierWave.root
16
+ Rails.root
17
17
  end
18
18
 
19
19
  end
@@ -16,6 +16,7 @@ class MediumRelatedTest < ActiveRecord::Base
16
16
  has_many_media :audios, :only => :audio
17
17
  has_one_medium :image_no_encode, :only => :image, :encode => false
18
18
  has_one_medium :pdf, :encode => false
19
+ has_one_medium :document, :encode => false
19
20
  end
20
21
 
21
22
 
@@ -28,7 +29,8 @@ describe "HasMedia" do
28
29
  "Image" => ["image/jpeg"],
29
30
  "Audio" => ["audio/wav"],
30
31
  "Pdf" => ["application/pdf"],
31
- "Video" => ["video/mp4"]
32
+ "Video" => ["video/mp4"],
33
+ "Document" => []
32
34
  }
33
35
  end
34
36
 
@@ -208,6 +210,27 @@ describe "HasMedia" do
208
210
  @medium.save.should be_false
209
211
  @medium.errors.full_messages.include?(HasMedia.errors_messages[:type_error])
210
212
  end
213
+ it "should allow to accept all mime types" do
214
+ HasMedia.medium_types = {
215
+ "Document" => [],
216
+ }
217
+ @pdf = stub_temp_file('Conversational_Capital _Explained.pdf', 'application/pdf')
218
+ @medium = MediumRelatedTest.new
219
+ @medium.document = @pdf
220
+ @medium.valid?
221
+ @medium.should be_valid
222
+ @medium.save.should be_true
223
+ @image = stub_temp_file('image.jpg', 'image/jpeg')
224
+ @medium.document = @image
225
+ @medium.valid?
226
+ @medium.should be_valid
227
+ @medium.save.should be_true
228
+ @audio = stub_temp_file('audio.wav', 'audio/wav')
229
+ @medium.document = @audio
230
+ @medium.valid?
231
+ @medium.should be_valid
232
+ @medium.save.should be_true
233
+ end
211
234
  end
212
235
 
213
236
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_media
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 2
10
- version: 0.2.2
9
+ - 3
10
+ version: 0.2.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - klacointe
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2010-11-05 00:00:00 +01:00
19
+ date: 2010-11-09 00:00:00 +01:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -117,10 +117,12 @@ files:
117
117
  - VERSION
118
118
  - config/locales/en.yml
119
119
  - examples/models/audio.rb
120
+ - examples/models/document.rb
120
121
  - examples/models/image.rb
121
122
  - examples/models/pdf.rb
122
123
  - examples/models/video.rb
123
124
  - examples/uploaders/audio_uploader.rb
125
+ - examples/uploaders/document_uploader.rb
124
126
  - examples/uploaders/image_uploader.rb
125
127
  - examples/uploaders/pdf_uploader.rb
126
128
  - examples/uploaders/video_uploader.rb
@@ -187,7 +189,9 @@ test_files:
187
189
  - examples/uploaders/pdf_uploader.rb
188
190
  - examples/uploaders/video_uploader.rb
189
191
  - examples/uploaders/audio_uploader.rb
192
+ - examples/uploaders/document_uploader.rb
190
193
  - examples/models/image.rb
191
194
  - examples/models/pdf.rb
192
195
  - examples/models/audio.rb
196
+ - examples/models/document.rb
193
197
  - examples/models/video.rb