Module: Uploader
- Defined in:
- lib/uploader.rb,
lib/uploader/asset.rb,
lib/uploader/engine.rb,
lib/uploader/version.rb,
lib/uploader/fileuploads.rb,
lib/uploader/helpers/field_tag.rb,
lib/uploader/helpers/form_builder.rb,
lib/uploader/helpers/form_tag_helper.rb,
app/controllers/uploader/attachments_controller.rb
Defined Under Namespace
Modules: Asset, Fileuploads, Helpers
Classes: AttachmentsController, Engine
Constant Summary
collapse
- VERSION =
"0.2.5".freeze
Class Method Summary
collapse
Class Method Details
.assets ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/uploader.rb', line 22
def self.assets
Dir[root_path.join('vendor/assets/**/uploader/**', '*.{js,css,png,gif}')].inject([]) do |list, path|
folder = path.split('/assets/')[1].split('/')[0]
list << Pathname.new(path).relative_path_from(root_path.join("vendor/assets/#{folder}")).to_s
list
end
end
|
.constantize(klass) ⇒ Object
30
31
32
33
|
# File 'lib/uploader.rb', line 30
def self.constantize(klass)
return if klass.blank?
klass.safe_constantize
end
|
.content_type(user_agent) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
|
# File 'lib/uploader.rb', line 35
def self.content_type(user_agent)
return "application/json" if user_agent.blank?
ie_version = user_agent.scan(/(MSIE\s|rv:)([\d\.]+)/).flatten.last
if user_agent.include?("Android") || (ie_version && ie_version.to_f <= 9.0) || (user_agent =~ /Trident\/[0-9\.]+\;/i)
"text/plain"
else
"application/json"
end
end
|
.guid ⇒ Object
14
15
16
|
# File 'lib/uploader.rb', line 14
def self.guid
SecureRandom.base64(16).tr('+/=', 'xyz').slice(0, 20)
end
|
.root_path ⇒ Object
18
19
20
|
# File 'lib/uploader.rb', line 18
def self.root_path
@root_path ||= Pathname.new( File.dirname(File.expand_path('../', __FILE__)) )
end
|