attachinary 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Attachinary v1
2
2
 
3
- _Note: v1 is not backward compatible._
3
+ _Note: v1 is not backward compatible. Refer to [wiki](https://github.com/assembler/attachinary/wiki/Upgrading-to-v1.0) on how to upgrade._
4
4
 
5
5
  Need lightweight attachment (photos and raw files) handler for any of your model, in either has\_one or has\_many relation, without altering your models' schema and with zero effort? Attachinary is the tool for you!
6
6
 
@@ -3,6 +3,8 @@ class AttachinaryInput < SimpleForm::Inputs::Base
3
3
 
4
4
  def input
5
5
  name = "#{@builder.object_name}[#{attribute_name}]"
6
+ input_html_options[:id] ||= "#{@builder.object_name}_#{attribute_name}"
7
+
6
8
  template.attachinary_file_field_tag name, @builder.object, attribute_name,
7
9
  { html: input_html_options }
8
10
  end
@@ -1,3 +1,3 @@
1
1
  module Attachinary
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
3
3
  end
@@ -23,7 +23,6 @@ module Attachinary
23
23
 
24
24
 
25
25
  options[:html] ||= {}
26
- options[:html][:id] = nil
27
26
  options[:html][:class] = [options[:html][:class], 'attachinary-input'].flatten.compact
28
27
 
29
28
  if !options[:html][:accept] && accepted_types = options[:attachinary][:accept]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: attachinary
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-09-08 00:00:00.000000000 Z
12
+ date: 2012-10-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70213729979420 !ruby/object:Gem::Requirement
16
+ requirement: &70198166992480 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.2'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70213729979420
24
+ version_requirements: *70198166992480
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: cloudinary
27
- requirement: &70213729994680 !ruby/object:Gem::Requirement
27
+ requirement: &70198167000640 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 1.0.30
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70213729994680
35
+ version_requirements: *70198167000640
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: sqlite3
38
- requirement: &70213729993740 !ruby/object:Gem::Requirement
38
+ requirement: &70198167040760 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70213729993740
46
+ version_requirements: *70198167040760
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rspec-rails
49
- requirement: &70213729992700 !ruby/object:Gem::Requirement
49
+ requirement: &70198167038660 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '2.5'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70213729992700
57
+ version_requirements: *70198167038660
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: valid_attribute
60
- requirement: &70213729991360 !ruby/object:Gem::Requirement
60
+ requirement: &70198167037580 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70213729991360
68
+ version_requirements: *70198167037580
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: capybara
71
- requirement: &70213730002500 !ruby/object:Gem::Requirement
71
+ requirement: &70198167055900 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70213730002500
79
+ version_requirements: *70198167055900
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: factory_girl_rails
82
- requirement: &70213729996140 !ruby/object:Gem::Requirement
82
+ requirement: &70198167053580 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '3.0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70213729996140
90
+ version_requirements: *70198167053580
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: webmock
93
- requirement: &70213729995080 !ruby/object:Gem::Requirement
93
+ requirement: &70198167052440 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70213729995080
101
+ version_requirements: *70198167052440
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: launchy
104
- requirement: &70213730007760 !ruby/object:Gem::Requirement
104
+ requirement: &70198167050240 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70213730007760
112
+ version_requirements: *70198167050240
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: database_cleaner
115
- requirement: &70213730006740 !ruby/object:Gem::Requirement
115
+ requirement: &70198167062200 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *70213730006740
123
+ version_requirements: *70198167062200
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: guard-rspec
126
- requirement: &70213730005440 !ruby/object:Gem::Requirement
126
+ requirement: &70198167059120 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,7 +131,7 @@ dependencies:
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *70213730005440
134
+ version_requirements: *70198167059120
135
135
  description: Attachments handler for Rails that uses Cloudinary for storage.
136
136
  email:
137
137
  - milovan.zogovic@gmail.com
@@ -148,7 +148,6 @@ files:
148
148
  - lib/attachinary/orm/active_record/extension.rb
149
149
  - lib/attachinary/orm/active_record/file.rb
150
150
  - lib/attachinary/orm/active_record.rb
151
- - lib/attachinary/orm/extension.rb
152
151
  - lib/attachinary/orm/file_mixin.rb
153
152
  - lib/attachinary/orm/mongoid/extension.rb
154
153
  - lib/attachinary/orm/mongoid/file.rb
@@ -175,7 +174,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
175
174
  version: '0'
176
175
  segments:
177
176
  - 0
178
- hash: -3340139382106100314
177
+ hash: -42460769790723876
179
178
  required_rubygems_version: !ruby/object:Gem::Requirement
180
179
  none: false
181
180
  requirements:
@@ -184,11 +183,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
184
183
  version: '0'
185
184
  segments:
186
185
  - 0
187
- hash: -3340139382106100314
186
+ hash: -42460769790723876
188
187
  requirements: []
189
188
  rubyforge_project:
190
189
  rubygems_version: 1.8.11
191
190
  signing_key:
192
191
  specification_version: 3
193
- summary: attachinary-1.0.0
192
+ summary: attachinary-1.0.1
194
193
  test_files: []
@@ -1,121 +0,0 @@
1
- module Attachinary
2
- module Extension
3
-
4
- def has_attachment(scope, options={})
5
- options[:single] = true
6
- attachinary scope, options
7
- end
8
-
9
- def has_attachments(scope, options={})
10
- options[:single] = false
11
- attachinary scope, options
12
- end
13
-
14
- def attachinary(scope, options)
15
- options.reverse_merge!({
16
- accessible: true
17
- })
18
-
19
- if options[:single]
20
- singular = scope.to_s
21
- plural = scope.to_s.pluralize
22
- else
23
- plural = scope.to_s
24
- singular = scope.to_s.singularize
25
- end
26
-
27
- relation = "#{singular}_files"
28
-
29
- # # has_many :photo_files, ...
30
- # # has_many :image_files, ...
31
- # has_many :"#{relation}",
32
- # as: :attachinariable,
33
- # class_name: '::Attachinary::File',
34
- # conditions: { scope: scope.to_s },
35
- # dependent: :destroy
36
-
37
- embeds_many :"#{relation}",
38
- as: :attachinariable,
39
- class_name: '::Attachinary::File',
40
- validate: false
41
-
42
- # attr_accessible :photo
43
- # attr_accessible :images
44
- attr_accessible :"#{scope}" if options[:accessible]
45
-
46
-
47
- # def photo?
48
- # photo.present?
49
- # end
50
- # def images?
51
- # images.present?
52
- # end
53
- define_method :"#{scope}?" do
54
- send(:"#{scope}").present?
55
- end
56
-
57
- # def photo_metadata
58
- # options[:scope] = 'photo'
59
- # options[:maximum] = 1 if options[:single]
60
- # options
61
- # end
62
- define_method :"#{scope}_metadata" do
63
- options[:scope] = scope
64
- options[:maximum] = 1 if options[:single]
65
- options
66
- end
67
-
68
- # def photo=(file)
69
- # if file.blank?
70
- # self.photo_files.clear
71
- # else
72
- # case file
73
- # when String
74
- # files = ... parse JSON and MAP to array of Attachinary::File ..
75
- # self.photo_files = files
76
- # else
77
- # self.photo_files = [file].flatten
78
- # end
79
- # end
80
- # end
81
- define_method "#{scope}=" do |file|
82
- if file.blank?
83
- send("#{relation}").clear
84
- else
85
- case file
86
- when String
87
- files = [JSON.parse(file)].flatten.map do |data|
88
- data = data.slice(*Attachinary::File.attr_accessible[:default].to_a)
89
- Attachinary::File.new(data) do |f|
90
- f.scope = scope.to_s if f.respond_to?(:scope)
91
- end
92
- end
93
- send("#{relation}=", files)
94
- else
95
- send("#{relation}=", [file].flatten)
96
- end
97
- end
98
- end
99
-
100
-
101
- if options[:single]
102
- # def photo
103
- # photo_files.first
104
- # end
105
- define_method "#{scope}" do
106
- send("#{relation}").first
107
- end
108
-
109
- else # plural
110
- # def images
111
- # image_files
112
- # end
113
- define_method "#{scope}" do
114
- send("#{relation}")
115
- end
116
- end
117
-
118
- end
119
-
120
- end
121
- end