essay-carrierwave 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/essay-carrierwave.gemspec +3 -3
- data/lib/essay-carrierwave/attribute.rb +9 -13
- data/lib/essay-carrierwave/model.rb +20 -30
- metadata +10 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 09203f9f082dc0b8a416c2c8ded987260d6bf72c
|
4
|
+
data.tar.gz: 0c7edf1ba4a4a53d7d32debefc1ffaaec6f931a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79a3cf72ddc2c1901a404b72b0df274aec4ac07600e67dd75a08d87d0280015ba4d16535711f5c036d2c9222dcee6daefb0c1d18dd841b55cf195c01913cf769
|
7
|
+
data.tar.gz: 9dc4ea47f4bee36ee24f57b8820baeb8f708c3c697d162b3f5c3aaefaea4a3795f641a67758a31b4dbf913a56021e233944f740d1c02cbe4e60d95ab993e0816
|
data/essay-carrierwave.gemspec
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = 'essay-carrierwave'
|
6
|
-
s.version = '1.0.
|
6
|
+
s.version = '1.0.2'
|
7
7
|
s.authors = ['Yaroslav Konoplov']
|
8
8
|
s.email = ['eahome00@gmail.com']
|
9
9
|
s.summary = 'essay-carrierwave'
|
@@ -16,6 +16,6 @@ Gem::Specification.new do |s|
|
|
16
16
|
s.test_files = `git ls-files -z -- {test,spec,features}/*`.split("\x0")
|
17
17
|
s.require_paths = ['lib']
|
18
18
|
|
19
|
-
s.add_dependency 'carrierwave', '>= 0'
|
20
|
-
s.add_dependency 'essay', '~> 1.
|
19
|
+
s.add_dependency 'carrierwave', '>= 0', '< 1.0'
|
20
|
+
s.add_dependency 'essay', '~> 1.1'
|
21
21
|
end
|
@@ -7,7 +7,7 @@ class Essay::AttributeFeatures
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def has_carrierwave_uploader?
|
10
|
-
!!
|
10
|
+
!!active_record.features.with(:carrierwave) { |cw| cw.uploader_for(this_attribute.name) }
|
11
11
|
end
|
12
12
|
|
13
13
|
def carrierwave
|
@@ -17,10 +17,8 @@ class Essay::AttributeFeatures
|
|
17
17
|
end
|
18
18
|
|
19
19
|
serialize do
|
20
|
-
{
|
21
|
-
|
22
|
-
carrierwave: carrierwave.try(:to_hash)
|
23
|
-
}
|
20
|
+
{ has_carrierwave_uploader: has_carrierwave_uploader?,
|
21
|
+
carrierwave: carrierwave.try(:to_hash) }
|
24
22
|
end
|
25
23
|
|
26
24
|
class HasCarrierWaveUploader < Base
|
@@ -31,7 +29,7 @@ class Essay::AttributeFeatures
|
|
31
29
|
# Article.attribute_features[:poster].carrierwave.uploader => PosterUploader
|
32
30
|
#
|
33
31
|
def uploader
|
34
|
-
|
32
|
+
carrierwave_feature.uploader_for(this_attribute.name)
|
35
33
|
end
|
36
34
|
|
37
35
|
# class Article
|
@@ -41,19 +39,17 @@ class Essay::AttributeFeatures
|
|
41
39
|
# Article.attribute_features[:poster].carrierwave.mounted_as => :poster
|
42
40
|
#
|
43
41
|
def mounted_as
|
44
|
-
|
42
|
+
carrierwave_feature.accessor_for(this_attribute.name)
|
45
43
|
end
|
46
44
|
|
47
45
|
serialize do
|
48
|
-
{
|
49
|
-
|
50
|
-
mounted_as: mounted_as
|
51
|
-
}
|
46
|
+
{ uploader: uploader.name,
|
47
|
+
mounted_as: mounted_as }
|
52
48
|
end
|
53
49
|
|
54
50
|
private
|
55
|
-
def
|
56
|
-
|
51
|
+
def carrierwave_feature
|
52
|
+
active_record.features.carrierwave
|
57
53
|
end
|
58
54
|
end
|
59
55
|
end
|
@@ -18,7 +18,7 @@ class Essay::ModelFeatures
|
|
18
18
|
# Article.features.has_translated_carrierwave_uploaders? => false
|
19
19
|
#
|
20
20
|
def has_own_carrierwave_uploaders?
|
21
|
-
|
21
|
+
active_record.try(:uploaders).present?
|
22
22
|
end
|
23
23
|
|
24
24
|
# class Article
|
@@ -30,7 +30,7 @@ class Essay::ModelFeatures
|
|
30
30
|
# Article.features.has_translated_carrierwave_uploaders? => true
|
31
31
|
#
|
32
32
|
def has_translated_carrierwave_uploaders?
|
33
|
-
!!with(:globalize) { |g| g.
|
33
|
+
!!with(:globalize) { |g| g.active_record_for_translations.features.has_carrierwave_uploaders? }
|
34
34
|
end
|
35
35
|
|
36
36
|
def carrierwave
|
@@ -40,12 +40,10 @@ class Essay::ModelFeatures
|
|
40
40
|
end
|
41
41
|
|
42
42
|
serialize do
|
43
|
-
{
|
44
|
-
has_carrierwave_uploaders: has_carrierwave_uploaders?,
|
43
|
+
{ has_carrierwave_uploaders: has_carrierwave_uploaders?,
|
45
44
|
has_own_carrierwave_uploaders: has_own_carrierwave_uploaders?,
|
46
45
|
has_translated_carrierwave_uploaders: has_translated_carrierwave_uploaders?,
|
47
|
-
carrierwave: carrierwave.try(:to_hash)
|
48
|
-
}
|
46
|
+
carrierwave: carrierwave.try(:to_hash) }
|
49
47
|
end
|
50
48
|
|
51
49
|
class CarrierWave < Base
|
@@ -56,7 +54,7 @@ class Essay::ModelFeatures
|
|
56
54
|
# Article.features.carrierwave.table => { poster: PosterUploader }
|
57
55
|
#
|
58
56
|
def table
|
59
|
-
|
57
|
+
active_record.uploaders
|
60
58
|
end
|
61
59
|
|
62
60
|
# class Article
|
@@ -66,7 +64,7 @@ class Essay::ModelFeatures
|
|
66
64
|
# Article.features.carrierwave.options => { poster: { mount_on: :poster_path } }
|
67
65
|
#
|
68
66
|
def options
|
69
|
-
|
67
|
+
active_record.uploader_options
|
70
68
|
end
|
71
69
|
|
72
70
|
# class Article
|
@@ -75,14 +73,12 @@ class Essay::ModelFeatures
|
|
75
73
|
#
|
76
74
|
# Article.features.carrierwave.uploader_for(:poster_path) => PosterUploader
|
77
75
|
#
|
78
|
-
def uploader_for(
|
79
|
-
|
80
|
-
|
81
|
-
if pair = pair_for(attr_name)
|
76
|
+
def uploader_for(attribute)
|
77
|
+
if pair = pair_for(attribute.to_sym)
|
82
78
|
table[pair.first]
|
83
79
|
|
84
80
|
else
|
85
|
-
send_to_translation(:uploader_for,
|
81
|
+
send_to_translation(:uploader_for, attribute.to_sym)
|
86
82
|
end
|
87
83
|
end
|
88
84
|
|
@@ -92,31 +88,29 @@ class Essay::ModelFeatures
|
|
92
88
|
#
|
93
89
|
# Article.features.carrierwave.accessor_for(:poster_path) => :poster
|
94
90
|
#
|
95
|
-
def accessor_for(
|
96
|
-
|
91
|
+
def accessor_for(attribute)
|
92
|
+
attribute = attribute.to_sym
|
97
93
|
|
98
|
-
if table.has_key?(
|
99
|
-
|
94
|
+
if table.has_key?(attribute)
|
95
|
+
attribute
|
100
96
|
|
101
|
-
elsif pair = pair_for(
|
97
|
+
elsif pair = pair_for(attribute)
|
102
98
|
pair.first
|
103
99
|
|
104
100
|
else
|
105
|
-
send_to_translation(:accessor_for,
|
101
|
+
send_to_translation(:accessor_for, attribute)
|
106
102
|
end
|
107
103
|
end
|
108
104
|
|
109
105
|
serialize do
|
110
|
-
{
|
111
|
-
|
112
|
-
options: options
|
113
|
-
}
|
106
|
+
{ table: table,
|
107
|
+
options: options }
|
114
108
|
end
|
115
109
|
|
116
110
|
private
|
117
111
|
def pair_for(mounted_on_or_attr_name)
|
118
112
|
all_options = options
|
119
|
-
key
|
113
|
+
key = mounted_on_or_attr_name.to_sym
|
120
114
|
|
121
115
|
if all_options.has_key?(key)
|
122
116
|
{key => all_options[key]}
|
@@ -127,13 +121,9 @@ class Essay::ModelFeatures
|
|
127
121
|
end
|
128
122
|
end
|
129
123
|
|
130
|
-
def convert_key(key)
|
131
|
-
key.is_a?(Symbol) ? key : key.to_sym
|
132
|
-
end
|
133
|
-
|
134
124
|
def send_to_translation(method, *args)
|
135
|
-
|
136
|
-
g.
|
125
|
+
active_record.features.with(:globalize) do |g|
|
126
|
+
g.active_record_for_translations.features.carrierwave.send(method, *args)
|
137
127
|
end
|
138
128
|
end
|
139
129
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: essay-carrierwave
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yaroslav Konoplov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: carrierwave
|
@@ -17,6 +17,9 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '1.0'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -24,20 +27,23 @@ dependencies:
|
|
24
27
|
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '0'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '1.0'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: essay
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
37
|
- - "~>"
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
39
|
+
version: '1.1'
|
34
40
|
type: :runtime
|
35
41
|
prerelease: false
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
37
43
|
requirements:
|
38
44
|
- - "~>"
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
46
|
+
version: '1.1'
|
41
47
|
description: essay-carrierwave
|
42
48
|
email:
|
43
49
|
- eahome00@gmail.com
|