el_finder2 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: 41739bf13311bece185c1b2377baee7e9c048a63
4
- data.tar.gz: 6085bf6957bfa752d089f4279184d486fa6695b4
3
+ metadata.gz: ff59a1ef1adf040108a8458744fcadca984298a3
4
+ data.tar.gz: a2d3ff1f92269aa7b9b94b0313233d4335fddb8e
5
5
  SHA512:
6
- metadata.gz: b7dc8c98c5ed745a752dfdf37f3d0092aea322d82fe3dc34034a4a9a0a059bed85fd9e29f7045e017ffe9cf5f99c53031b19ad8671e05c3a00def973ba3a9d83
7
- data.tar.gz: 6049d2147de8fd34f852b81e35b57f6be2e300fccb5eebb356ad57109d98477c09acf1ed3051c281d243143d7cfe113012c1935da1a4b0e188cc78373510b638
6
+ metadata.gz: 74bf38071a64e6d5d128c885c56376c4d96b1a4252126483c83b1bb25dfef9efdbc0f104dcebf84c2b7af4f89f3ef19bf0b422ff7789db1f70f24f6cda825e4e
7
+ data.tar.gz: c7c059cfec7dcb13e10e1a54ef04d0582a05667d925c26ae127413ff92be311ff7ff83b50ce5baa8996c284a58898cafcf35d8c131a8302348611a3ba1c8f910
@@ -2,7 +2,7 @@ module ElFinder2
2
2
  class Document < ElFinder2::File
3
3
  has_attached_file :content
4
4
 
5
- do_not_validate_attachment_file_type :content
5
+ validates_attachment :content, ElFinder2.configuration.document_validations
6
6
 
7
7
  delegate :content_type, :size, :url, to: :content
8
8
  end
@@ -1,9 +1,8 @@
1
1
  module ElFinder2
2
2
  class Image < ElFinder2::File
3
- has_attached_file :content, styles: { thumb: '100x100>' }
3
+ has_attached_file :content, ElFinder2.configuration.image_attachment
4
4
 
5
- validates_attachment :content,
6
- content_type: { content_type: ElFinder2::IMAGE_MIME_REGEX }
5
+ validates_attachment :content, ElFinder2.configuration.image_validations
7
6
 
8
7
  delegate :content_type, :size, :url, to: :content
9
8
 
@@ -1,3 +1,3 @@
1
1
  module ElFinder2
2
- VERSION = '0.1.3'
2
+ VERSION = '0.1.4'
3
3
  end
data/lib/el_finder2.rb CHANGED
@@ -7,4 +7,40 @@ module ElFinder2
7
7
  API_VERSION = '2.1'
8
8
  VOLUME_ID = 'v0'
9
9
  IMAGE_MIME_REGEX = /\A(image|(x-)?application)\/(bmp|gif|p?jpeg|jpg|(x-)?png)\Z/
10
+
11
+ def self.configuration
12
+ @configuration ||= Configuration.new
13
+ end
14
+
15
+ def self.configure(&block)
16
+ configuration.tap(&block)
17
+ end
18
+
19
+ class Configuration
20
+ attr_accessor :document_validations
21
+ attr_accessor :image_styles
22
+ attr_accessor :image_validations
23
+ attr_accessor :paperclip_defaults
24
+
25
+ def initialize
26
+ @document_validations = {
27
+ presence: true,
28
+ file_type_ignorance: {}
29
+ }
30
+ @image_styles = { thumb: '100x100>' }
31
+ @image_validations = {
32
+ presence: true,
33
+ content_type: { content_type: ElFinder2::IMAGE_MIME_REGEX }
34
+ }
35
+ @paperclip_defaults = {}
36
+ end
37
+
38
+ def image_attachment
39
+ @paperclip_defaults.merge(styles: @image_styles)
40
+ end
41
+
42
+ def document_attachment
43
+ @paperclip_defaults
44
+ end
45
+ end
10
46
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: el_finder2
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
7
  - QuintEvents
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-15 00:00:00.000000000 Z
11
+ date: 2015-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers