s3_multipart 0.0.2 → 0.0.3

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.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- s3_multipart (0.0.1)
5
- uuid
6
- xml-simple
4
+ s3_multipart (0.0.2)
5
+ uuid (>= 2.3.6)
6
+ xml-simple (>= 1.1.2)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
@@ -5,6 +5,7 @@ module S3Multipart
5
5
  response = Upload.initiate(params)
6
6
  upload = Upload.create(key: response["key"], upload_id: response["upload_id"], name: response["name"])
7
7
  response["id"] = upload["id"]
8
+ upload.on_begin if upload.respond_to?(:on_begin)
8
9
  rescue
9
10
  response = {error: 'There was an error initiating the upload'}
10
11
  ensure
@@ -45,7 +46,7 @@ module S3Multipart
45
46
  response = Upload.complete(params)
46
47
  upload = Upload.find_by_upload_id(params[:upload_id])
47
48
  upload.update_attributes(location: response[:location])
48
- upload.on_complete
49
+ upload.on_complete if upload.respond_to?(:on_complete)
49
50
  rescue
50
51
  response = {error: 'There was an error completing the upload'}
51
52
  ensure
@@ -3,6 +3,7 @@ module S3Multipart
3
3
  class << self
4
4
  include S3Multipart::Uploader
5
5
  attr_accessor :on_complete_callback
6
+ attr_accessor :on_begin_callback
6
7
  end
7
8
 
8
9
  attr_accessible :key, :upload_id, :name, :location
@@ -1,3 +1,3 @@
1
1
  module S3Multipart
2
- VERSION = "0.0.2"
2
+ VERSION = "0.0.3"
3
3
  end
data/lib/s3_multipart.rb CHANGED
@@ -15,6 +15,7 @@ module S3Multipart
15
15
  # config.s3_secret_key = ''
16
16
  # config.bucket_name = ''
17
17
  # end
18
+
18
19
  def configure(&block)
19
20
  S3Multipart::Uploader::Config.configure(block)
20
21
  end
@@ -27,18 +28,28 @@ module S3Multipart
27
28
 
28
29
  module ActionControllerHelpers
29
30
 
30
- #
31
- # Stores a code block in the Upload class that will be executed (and passed the
32
- # completed upload object) when the on_complete method is called on an
33
- # instance of the Upload class
34
- #
35
- def attach_uploader(&block)
36
- S3Multipart::Upload.class_eval do
37
- self.on_complete_callback = block
38
- def on_complete
39
- Upload.on_complete_callback.call(self)
31
+ module AttachUploader
32
+ def self.on_begin(&block)
33
+ S3Multipart::Upload.class_eval do
34
+ self.on_begin_callback = block
35
+ def on_begin
36
+ Upload.on_begin_callback.call(self)
37
+ end
40
38
  end
41
39
  end
40
+
41
+ def self.on_complete(&block)
42
+ S3Multipart::Upload.class_eval do
43
+ self.on_complete_callback = block
44
+ def on_complete
45
+ Upload.on_complete_callback.call(self)
46
+ end
47
+ end
48
+ end
49
+ end
50
+
51
+ def attach_uploader
52
+ return AttachUploader
42
53
  end
43
54
 
44
55
  end
@@ -19,6 +19,9 @@ $(function() {
19
19
  window.SS3MP = new window.S3MP({
20
20
  bucket: 'bitcast-bucket',
21
21
  fileSelector: "#uploader",
22
+ onStart: function(num) {
23
+ console.log("File "+num+" has started uploading")
24
+ },
22
25
  onComplete: function(num) {
23
26
  console.log("File "+num+" successfully uploaded")
24
27
  },
@@ -1,9 +1,13 @@
1
1
  class PagesController < ApplicationController
2
2
 
3
3
  def upload
4
- attach_uploader do |upload|
5
- upload.update_attributes(name: "modified")
4
+ upload = attach_uploader
5
+ upload.on_begin do |upload|
6
+ upload.update_attributes(name: "begun")
7
+ end
8
+ upload.on_complete do |upload|
9
+ upload.update_attributes(name: "completed")
6
10
  end
7
11
  end
8
-
12
+
9
13
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: s3_multipart
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-04 00:00:00.000000000 Z
12
+ date: 2013-01-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: uuid
@@ -166,7 +166,6 @@ files:
166
166
  - lib/s3_multipart/uploader.rb
167
167
  - lib/s3_multipart/uploader/config.rb
168
168
  - lib/s3_multipart/version.rb
169
- - s3_multipart-0.0.1.gem
170
169
  - s3_multipart.gemspec
171
170
  - spec/integration/uploads_controller_spec.rb
172
171
  - spec/internal/app/assets/javascripts/application.js
Binary file