model_attachment 0.0.18 → 0.0.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +2 -0
- data/lib/model_attachment/version.rb +2 -2
- data/lib/model_attachment.rb +12 -7
- metadata +6 -15
data/Gemfile
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module ModelAttachment
|
2
|
-
VERSION = "0.0.
|
3
|
-
end
|
2
|
+
VERSION = "0.0.20"
|
3
|
+
end
|
data/lib/model_attachment.rb
CHANGED
@@ -124,13 +124,13 @@ module ModelAttachment
|
|
124
124
|
# * +path+: sets the path, defaults to /documents/send
|
125
125
|
# * +type+: sets the type, types come from the has_attachment method, ex. small, large
|
126
126
|
def url(options = {})
|
127
|
-
proto = options[:proto] || "http"
|
127
|
+
proto = options[:proto] || "http://"
|
128
128
|
port = options[:port]
|
129
129
|
server_name = options[:server_name] || "localhost"
|
130
130
|
url_path = options[:path] || "/#{self.class.to_s.downcase.pluralize}/"
|
131
131
|
type = options[:type]
|
132
132
|
|
133
|
-
server_name += ":" + port.to_s if port
|
133
|
+
server_name += ":" + port.to_s if !port.nil? && port != 80 && port != 443
|
134
134
|
type_string = "?type=#{type}" if type
|
135
135
|
|
136
136
|
# if we aren't using aws set @bucket to nil
|
@@ -142,10 +142,10 @@ module ModelAttachment
|
|
142
142
|
if public?
|
143
143
|
url_path = path.gsub(/^\/public(.*)/, '\1')
|
144
144
|
type_string = "_#{type}" if type
|
145
|
-
url = "#{proto}
|
145
|
+
url = "#{proto}#{server_name}#{url_path}#{basename}#{type_string}#{extension}"
|
146
146
|
elsif bucket.nil?
|
147
147
|
# otherwise use private url with deliver
|
148
|
-
url = "#{proto}
|
148
|
+
url = "#{proto}#{server_name}#{url_path}#{id}#{type_string}"
|
149
149
|
else
|
150
150
|
# if bucket is set, then use aws url
|
151
151
|
url = aws_url(type)
|
@@ -220,7 +220,8 @@ module ModelAttachment
|
|
220
220
|
# save the correct attribute info before the save
|
221
221
|
def save_attributes
|
222
222
|
return if file_name.nil? || file_name.class.to_s == "String"
|
223
|
-
@temp_file = self.file_name
|
223
|
+
# this used to be @temp_file = self.file_name but some change must have happened between 3.0.1 and 3.0.5
|
224
|
+
@temp_file = (self.file_name.class == "ActionDispatch::Http::UploadFile" ? self.file_name.tempfile : self.file_name)
|
224
225
|
|
225
226
|
# get original filename info and clean up for storage
|
226
227
|
filename = File.basename(@temp_file)
|
@@ -254,7 +255,11 @@ module ModelAttachment
|
|
254
255
|
FileUtils.chmod(0755, full_path)
|
255
256
|
|
256
257
|
if File.exists?(@temp_file.path)
|
257
|
-
|
258
|
+
new_file = full_path + basename + extension
|
259
|
+
FileUtils.mv(@temp_file.path, new_file)
|
260
|
+
if File.exists?(new_file)
|
261
|
+
File.open(new_file).chmod(0640)
|
262
|
+
end
|
258
263
|
else
|
259
264
|
raise "File Error: #{@temp_file.path} does not exist"
|
260
265
|
end
|
@@ -283,7 +288,7 @@ module ModelAttachment
|
|
283
288
|
new_filename = full_filename(name)
|
284
289
|
log("Create #{name} by running #{command} on #{old_filename}")
|
285
290
|
log("Created: #{new_filename}")
|
286
|
-
`#{command} #{old_filename} #{new_filename}`
|
291
|
+
`#{command} #{old_filename} #{new_filename} ; chmod 640 #{new_filename}`
|
287
292
|
rescue Exception => e
|
288
293
|
puts "Process Images Error: #{e.message}"
|
289
294
|
puts "\tBacktrace: #{e.backtrace[0]}"
|
metadata
CHANGED
@@ -1,12 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: model_attachment
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 18
|
9
|
-
version: 0.0.18
|
4
|
+
prerelease:
|
5
|
+
version: 0.0.20
|
10
6
|
platform: ruby
|
11
7
|
authors:
|
12
8
|
- Steve Walker
|
@@ -14,21 +10,19 @@ autorequire:
|
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
12
|
|
17
|
-
date:
|
13
|
+
date: 2011-03-24 00:00:00 -04:00
|
18
14
|
default_executable:
|
19
15
|
dependencies:
|
20
16
|
- !ruby/object:Gem::Dependency
|
21
17
|
name: aws-s3
|
22
|
-
prerelease: false
|
23
18
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
19
|
none: false
|
25
20
|
requirements:
|
26
21
|
- - ">="
|
27
22
|
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 0
|
30
23
|
version: "0"
|
31
24
|
type: :runtime
|
25
|
+
prerelease: false
|
32
26
|
version_requirements: *id001
|
33
27
|
description: Simple file attachment gem
|
34
28
|
email:
|
@@ -64,6 +58,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
64
58
|
requirements:
|
65
59
|
- - ">="
|
66
60
|
- !ruby/object:Gem::Version
|
61
|
+
hash: -2213741255093125105
|
67
62
|
segments:
|
68
63
|
- 0
|
69
64
|
version: "0"
|
@@ -72,15 +67,11 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
67
|
requirements:
|
73
68
|
- - ">="
|
74
69
|
- !ruby/object:Gem::Version
|
75
|
-
segments:
|
76
|
-
- 1
|
77
|
-
- 3
|
78
|
-
- 6
|
79
70
|
version: 1.3.6
|
80
71
|
requirements: []
|
81
72
|
|
82
73
|
rubyforge_project: model_attachment
|
83
|
-
rubygems_version: 1.
|
74
|
+
rubygems_version: 1.5.2
|
84
75
|
signing_key:
|
85
76
|
specification_version: 3
|
86
77
|
summary: A simple file attachment gem
|