Class: InlineUploader
- Inherits:
-
Object
- Object
- InlineUploader
- Defined in:
- lib/inline_uploader.rb
Defined Under Namespace
Modules: Helpers Classes: Attacher, EndPoint
Constant Summary collapse
- TAG_PREFIX =
32 is the length of an md5 hex digest
'inline_upload_'.freeze
- TAG_REGEXP =
/\A#{TAG_PREFIX}[a-z0-9]{32,32}\Z/i.freeze
- TAG_LENGTH =
TAG_PREFIX.length + 32
- DEFAULT_ENDPOINT =
'/inline_upload'
- DEFAULT_UPLOAD_FLAG =
'has_inline_uploads'
Instance Attribute Summary collapse
-
#endpoint ⇒ Object
readonly
Returns the value of attribute endpoint.
-
#flag_param ⇒ Object
readonly
Returns the value of attribute flag_param.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#upload_dir ⇒ Object
readonly
Returns the value of attribute upload_dir.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options) ⇒ InlineUploader
constructor
A new instance of InlineUploader.
Constructor Details
#initialize(options) ⇒ InlineUploader
Returns a new instance of InlineUploader.
35 36 37 38 39 40 41 42 |
# File 'lib/inline_uploader.rb', line 35 def initialize() @upload_dir = [:tmp_dir] || File.join(Dir.tmpdir, "inline_uploader_#{Process.pid}#{Time.now.to_i}") @flag_param = [:upload_flag] || DEFAULT_UPLOAD_FLAG @endpoint = [:endpoint] || DEFAULT_ENDPOINT @logger = [:logger] || Logger.new($stderr) FileUtils.mkdir_p(upload_dir) end |
Instance Attribute Details
#endpoint ⇒ Object (readonly)
Returns the value of attribute endpoint.
33 34 35 |
# File 'lib/inline_uploader.rb', line 33 def endpoint @endpoint end |
#flag_param ⇒ Object (readonly)
Returns the value of attribute flag_param.
33 34 35 |
# File 'lib/inline_uploader.rb', line 33 def flag_param @flag_param end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
33 34 35 |
# File 'lib/inline_uploader.rb', line 33 def logger @logger end |
#upload_dir ⇒ Object (readonly)
Returns the value of attribute upload_dir.
33 34 35 |
# File 'lib/inline_uploader.rb', line 33 def upload_dir @upload_dir end |
Class Method Details
.new(inner_app, options = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/inline_uploader.rb', line 17 def self.new(inner_app, = {}) uploader = allocate uploader.send :initialize, Rack::Builder.app do map uploader.endpoint do run InlineUploader::EndPoint.new(uploader) end map '/' do use InlineUploader::Attacher, uploader run inner_app end end end |