has_media 0.0.6 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,6 +20,20 @@ Easy way to link media (ie image, audio, pdf for now) on other activerecords mod
20
20
 
21
21
  has_one_medium :pdf, :encode => false
22
22
 
23
+ == Configuration
24
+
25
+ * Set custom uploaders path to overload has_media ones
26
+ HasMedia.custom_uploaders_path = File.dirname(__FILE__) + '/../../app/uploaders'
27
+
28
+ * Set the directory path to use to store media
29
+ HasMedia.directory_path = "media"
30
+
31
+ * Set the base uri to access media
32
+ HasMedia.directory_uri = "/media"
33
+
34
+ * Set custom error messages
35
+ HasMedia.errors_messages = {:type_error => I18n.t('has_media.errors.type_error')}
36
+
23
37
  == TODO
24
38
 
25
39
  * Add a video class
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.6
1
+ 0.0.8
@@ -9,6 +9,8 @@ module HasMedia
9
9
 
10
10
  @@store_dir = '/tmp'
11
11
  @@directory_uri = ''
12
+ @@custom_uploaders_path = nil
13
+ @@custom_models_path = nil
12
14
  @@errors_messages = {:type_error => 'Wrong type'}
13
15
  @@images_content_types = [
14
16
  'image/jpeg',
@@ -54,6 +56,28 @@ module HasMedia
54
56
  def self.directory_uri
55
57
  @@directory_uri
56
58
  end
59
+ def self.custom_uploaders_path=(value)
60
+ unless value.blank?
61
+ @@custom_uploaders_path = value
62
+ Dir.glob(self.custom_uploaders_path + '*.rb').each do |uploader|
63
+ require uploader
64
+ end
65
+ end
66
+ end
67
+ def self.custom_models_path
68
+ @@custom_models_path
69
+ end
70
+ def self.custom_models_path=(value)
71
+ unless value.blank?
72
+ @@custom_models_path = value
73
+ Dir.glob(self.custom_models_path + '*.rb').each do |model|
74
+ require model
75
+ end
76
+ end
77
+ end
78
+ def self.custom_uploaders_path
79
+ @@custom_uploaders_path
80
+ end
57
81
  # taken from http://github.com/technoweenie/attachment_fu/blob/master/lib/technoweenie/attachment_fu.rb
58
82
  def self.images_content_types
59
83
  @@images_content_types
@@ -0,0 +1,3 @@
1
+ class Image < Medium
2
+ raise "this exception is normal, useful for testing"
3
+ end
@@ -0,0 +1,7 @@
1
+ # encoding: utf-8
2
+
3
+ class ImageUploader < MediumUploader
4
+ storage :file
5
+ raise "this exception is normal, useful for testing"
6
+ end
7
+
@@ -163,4 +163,16 @@ describe "HasMedia" do
163
163
  @medium.errors.full_messages.include?(HasMedia.errors_messages[:type_error])
164
164
  end
165
165
 
166
+ it "should load custom uploaders" do
167
+ lambda {
168
+ HasMedia.custom_uploaders_path = File.join(File.dirname(__FILE__), 'fixtures/uploaders/')
169
+ }.should raise_error(RuntimeError, "this exception is normal, useful for testing")
170
+ end
171
+
172
+ it "should load custom models" do
173
+ lambda {
174
+ HasMedia.custom_models_path = File.join(File.dirname(__FILE__), 'fixtures/models/')
175
+ }.should raise_error(RuntimeError, "this exception is normal, useful for testing")
176
+ end
177
+
166
178
  end
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: has_media
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 8
9
+ version: 0.0.8
5
10
  platform: ruby
6
11
  authors:
7
12
  - klacointe
@@ -10,49 +15,65 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2010-03-09 00:00:00 +01:00
18
+ date: 2010-04-01 00:00:00 +02:00
14
19
  default_executable:
15
20
  dependencies:
16
21
  - !ruby/object:Gem::Dependency
17
22
  name: rspec
18
- type: :development
19
- version_requirement:
20
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
21
25
  requirements:
22
26
  - - ">="
23
27
  - !ruby/object:Gem::Version
28
+ segments:
29
+ - 1
30
+ - 2
31
+ - 9
24
32
  version: 1.2.9
25
- version:
33
+ type: :development
34
+ version_requirements: *id001
26
35
  - !ruby/object:Gem::Dependency
27
36
  name: carrierwave
28
- type: :runtime
29
- version_requirement:
30
- version_requirements: !ruby/object:Gem::Requirement
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
31
39
  requirements:
32
40
  - - ">="
33
41
  - !ruby/object:Gem::Version
42
+ segments:
43
+ - 0
44
+ - 4
45
+ - 2
34
46
  version: 0.4.2
35
- version:
47
+ type: :runtime
48
+ version_requirements: *id002
36
49
  - !ruby/object:Gem::Dependency
37
50
  name: activerecord
38
- type: :runtime
39
- version_requirement:
40
- version_requirements: !ruby/object:Gem::Requirement
51
+ prerelease: false
52
+ requirement: &id003 !ruby/object:Gem::Requirement
41
53
  requirements:
42
54
  - - ">="
43
55
  - !ruby/object:Gem::Version
56
+ segments:
57
+ - 2
58
+ - 3
59
+ - 4
44
60
  version: 2.3.4
45
- version:
61
+ type: :runtime
62
+ version_requirements: *id003
46
63
  - !ruby/object:Gem::Dependency
47
64
  name: activesupport
48
- type: :runtime
49
- version_requirement:
50
- version_requirements: !ruby/object:Gem::Requirement
65
+ prerelease: false
66
+ requirement: &id004 !ruby/object:Gem::Requirement
51
67
  requirements:
52
68
  - - ">="
53
69
  - !ruby/object:Gem::Version
70
+ segments:
71
+ - 2
72
+ - 3
73
+ - 4
54
74
  version: 2.3.4
55
- version:
75
+ type: :runtime
76
+ version_requirements: *id004
56
77
  description: Media Managment Library for ActiveRecord and Carrierwave
57
78
  email: kevinlacointe@gmail.com
58
79
  executables: []
@@ -87,6 +108,8 @@ files:
87
108
  - spec/fixtures/media/image.jpg
88
109
  - spec/fixtures/media/image_bis.jpg
89
110
  - spec/fixtures/media/lc_pdf_overview_format.pdf
111
+ - spec/fixtures/models/image.rb
112
+ - spec/fixtures/uploaders/uploader_with_exception.rb
90
113
  - spec/has_media_spec.rb
91
114
  - spec/spec.opts
92
115
  - spec/spec_helper.rb
@@ -103,21 +126,25 @@ required_ruby_version: !ruby/object:Gem::Requirement
103
126
  requirements:
104
127
  - - ">="
105
128
  - !ruby/object:Gem::Version
129
+ segments:
130
+ - 0
106
131
  version: "0"
107
- version:
108
132
  required_rubygems_version: !ruby/object:Gem::Requirement
109
133
  requirements:
110
134
  - - ">="
111
135
  - !ruby/object:Gem::Version
136
+ segments:
137
+ - 0
112
138
  version: "0"
113
- version:
114
139
  requirements: []
115
140
 
116
141
  rubyforge_project:
117
- rubygems_version: 1.3.5
142
+ rubygems_version: 1.3.6
118
143
  signing_key:
119
144
  specification_version: 3
120
145
  summary: Media Managment Library for ActiveRecord and Carrierwave
121
146
  test_files:
122
147
  - spec/spec_helper.rb
148
+ - spec/fixtures/uploaders/uploader_with_exception.rb
149
+ - spec/fixtures/models/image.rb
123
150
  - spec/has_media_spec.rb