condo_active_record 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 76c8f3ce62a4c460342e476d18e42ed9cb38dfbf
4
+ data.tar.gz: 672ce772a622e159548ec5bf88e39c011eb9fd83
5
+ SHA512:
6
+ metadata.gz: a1724a7e5639b9828b1f40d3cef1f9dc532a4deb59cb71e5967320c42681cddb86ac668845312c1eddca332f459247f3ec13cb9c05217d0c502822c1c206b433
7
+ data.tar.gz: a0ef973850db4ce43aedd3e832ea84a2776f24851769f97828a1262258acf8384c5e8daaa4f0e81a00459987c889592831a05b0db02dc698dafa52b22c48f187
@@ -1,28 +1,28 @@
1
- class Init < ActiveRecord::Migration
2
- def change
3
- #
4
- # Create the table for storing the uploads currently being processed
5
- #
6
- create_table :condo_uploads do |t|
7
- t.string :user_id, :allow_null => false
8
-
9
- t.string :file_name, :allow_null => false
10
- t.integer :file_size, :allow_null => false
11
- t.string :file_id
12
- t.text :custom_params
13
-
14
- t.string :provider_namespace
15
- t.string :provider_name, :allow_null => false
16
- t.string :provider_location, :allow_null => false
17
-
18
- t.string :bucket_name, :allow_null => false
19
- t.string :object_key, :allow_null => false
20
- t.text :object_options
21
-
22
- t.string :resumable_id
23
- t.boolean :resumable, :allow_null => false, :default => false
24
-
25
- t.timestamps # date_created needs to be defined
26
- end
27
- end
28
- end
1
+ class Init < ActiveRecord::Migration
2
+ def change
3
+ #
4
+ # Create the table for storing the uploads currently being processed
5
+ #
6
+ create_table :condo_uploads do |t|
7
+ t.string :user_id, :allow_null => false
8
+
9
+ t.string :file_name, :allow_null => false
10
+ t.integer :file_size, :allow_null => false
11
+ t.string :file_id
12
+ t.text :custom_params
13
+
14
+ t.string :provider_namespace
15
+ t.string :provider_name, :allow_null => false
16
+ t.string :provider_location, :allow_null => false
17
+
18
+ t.string :bucket_name, :allow_null => false
19
+ t.string :object_key, :allow_null => false
20
+ t.text :object_options
21
+
22
+ t.string :resumable_id
23
+ t.boolean :resumable, :allow_null => false, :default => false
24
+
25
+ t.timestamps # date_created needs to be defined
26
+ end
27
+ end
28
+ end
@@ -1,9 +1,9 @@
1
- class Filepath < ActiveRecord::Migration
2
- def up
3
- add_column :condo_uploads, :file_path, :text
4
- end
5
-
6
- def down
7
- remove_column :condo_uploads, :file_path
8
- end
9
- end
1
+ class Filepath < ActiveRecord::Migration
2
+ def up
3
+ add_column :condo_uploads, :file_path, :text
4
+ end
5
+
6
+ def down
7
+ remove_column :condo_uploads, :file_path
8
+ end
9
+ end
@@ -0,0 +1,7 @@
1
+ class Parallel < ActiveRecord::Migration
2
+ def change
3
+ add_column :condo_uploads, :part_list, :string
4
+ add_column :condo_uploads, :part_data, :text
5
+ remove_column :condo_uploads, :custom_params
6
+ end
7
+ end
@@ -1,105 +1,115 @@
1
- module Condo
2
- module Backend
3
-
4
- #
5
- # The following data needs to be stored in any backend
6
- # => provider_namespace (for handling multiple upload controllers, defaults to global)
7
- # => provider_name (amazon, rackspace, google, azure etc)
8
- # => provider_location (US West (Oregon) Region, Asia Pacific (Singapore) Region etc)
9
- # => user_id (the identifier for the current user as a string)
10
- # => file_name (the original upload file name)
11
- # => file_size (the file size as indicated by the client)
12
- # => file_id (some sort of identifying hash provided by the client)
13
- # => bucket_name (the name of the users bucket)
14
- # => object_key (the path to the object in the bucket)
15
- # => object_options (custom options that were applied to this object - public/private etc)
16
- # => resumable_id (the id of the chunked upload)
17
- # => resumable (true if a resumable upload - must be set)
18
- # => custom_params (application specific data - needs to be serialised and de-serialised)
19
- # => date_created (the date the upload was started)
20
- #
21
- # => Each backend should have an ID that uniquely identifies an entry - id or upload_id
22
- #
23
- #
24
- #
25
- # Backends should inherit this class, set themselves as the backend and define the following:
26
- #
27
- # Class Methods:
28
- # => check_exists ({user_id, upload_id}) returns nil or an entry where all fields match
29
- # check_exists ({user_id, file_name, file_size, file_id}) so same logic for this
30
- # => add_entry ({user_id, file_name, file_size, file_id, provider_name, provider_location, bucket_name, object_key})
31
- #
32
- #
33
- #
34
- # Instance Methods:
35
- # => update_entry ({upload_id, resumable_id})
36
- # => remove_entry (upload_id)
37
- #
38
- class ActiveRecord < ::ActiveRecord::Base
39
-
40
- attr_accessible :user_id, :file_name, :file_size, :file_id, :custom_params,
41
- :provider_namespace, :provider_name, :provider_location, :bucket_name,
42
- :object_key, :object_options, :resumable_id, :resumable, :file_path
43
-
44
-
45
- self.table_name = "#{::ActiveRecord::Base.table_name_prefix}condo_uploads"
46
-
47
-
48
- serialize :custom_params, Hash
49
- serialize :object_options, Hash
50
-
51
-
52
- #
53
- # Checks for an exact match in the database given a set of parameters
54
- #
55
- def self.check_exists(params)
56
- params = {}.merge(params)
57
- params[:user_id] = params[:user_id].to_s if params[:user_id].present?
58
- params[:id] = params.delete(:upload_id).to_i if params[:upload_id].present?
59
-
60
- self.where(params).first
61
- end
62
-
63
- #
64
- # Adds a new upload entry into the database
65
- #
66
- def self.add_entry(params)
67
- params = {}.merge(params)
68
- params.delete(:upload_id) if params[:upload_id].present?
69
- params.delete(:id) if params[:id].present?
70
- params.delete(:resumable_id) if params[:resumable_id].present?
71
-
72
- self.create!(params)
73
- end
74
-
75
- #
76
- # Updates self with the passed in parameters
77
- #
78
- def update_entry(params)
79
- result = self.update_attributes(params)
80
- raise ActiveResource::ResourceInvalid if result == false
81
- self
82
- end
83
-
84
- #
85
- # Deletes reference to the upload
86
- #
87
- def remove_entry
88
- self.destroy
89
- end
90
-
91
-
92
- #
93
- # Attribute accessors to comply with the backend spec
94
- #
95
- def upload_id
96
- self[:id]
97
- end
98
-
99
- def date_created
100
- self[:created_at]
101
- end
102
-
103
- end
104
- end
105
- end
1
+ module Condo
2
+ module Backend
3
+
4
+ #
5
+ # The following data needs to be stored in any backend
6
+ # => provider_namespace (for handling multiple upload controllers, defaults to global)
7
+ # => provider_name (amazon, rackspace, google, azure etc)
8
+ # => provider_location (US West (Oregon) Region, Asia Pacific (Singapore) Region etc)
9
+ # => user_id (the identifier for the current user as a string)
10
+ # => file_name (the original upload file name)
11
+ # => file_size (the file size as indicated by the client)
12
+ # => file_id (some sort of identifying hash provided by the client)
13
+ # => bucket_name (the name of the users bucket)
14
+ # => object_key (the path to the object in the bucket)
15
+ # => object_options (custom options that were applied to this object - public/private etc)
16
+ # => resumable_id (the id of the chunked upload)
17
+ # => resumable (true if a resumable upload - must be set)
18
+ # => date_created (the date the upload was started)
19
+ #
20
+ # => Each backend should have an ID that uniquely identifies an entry - id or upload_id
21
+ #
22
+ #
23
+ #
24
+ # Backends should inherit this class, set themselves as the backend and define the following:
25
+ #
26
+ # Class Methods:
27
+ # => check_exists ({user_id, upload_id}) returns nil or an entry where all fields match
28
+ # check_exists ({user_id, file_name, file_size, file_id}) so same logic for this
29
+ # => add_entry ({user_id, file_name, file_size, file_id, provider_name, provider_location, bucket_name, object_key})
30
+ #
31
+ #
32
+ #
33
+ # Instance Methods:
34
+ # => update_entry ({upload_id, resumable_id})
35
+ # => remove_entry (upload_id)
36
+ #
37
+ class ActiveRecord < ::ActiveRecord::Base
38
+ self.table_name = "#{::ActiveRecord::Base.table_name_prefix}condo_uploads"
39
+
40
+
41
+ serialize :object_options, JSON
42
+ serialize :part_list, JSON # example: [1,2,5]
43
+ serialize :part_data, JSON # example: {1:'abd23',2:'56sdv'}
44
+
45
+
46
+ # Checks for an exact match in the database given a set of parameters
47
+ def self.check_exists(params)
48
+ params = {}.merge(params)
49
+ params[:user_id] = params[:user_id].to_s if params[:user_id].present?
50
+ params[:id] = params.delete(:upload_id).to_i if params[:upload_id].present?
51
+
52
+ self.where(params).first
53
+ end
54
+
55
+ # Adds a new upload entry into the database
56
+ def self.add_entry(params)
57
+ params = {}.merge(params)
58
+ params.delete(:upload_id) if params[:upload_id].present?
59
+ params.delete(:id) if params[:id].present?
60
+ params.delete(:resumable_id) if params[:resumable_id].present?
61
+
62
+ self.create!(params)
63
+ end
64
+
65
+ def self.all_uploads
66
+ self.all
67
+ end
68
+
69
+ # Return a list of Uploads that were last updated before a particular time
70
+ def self.older_than(time)
71
+ self.where('updated_at < :time', time: time)
72
+ end
73
+
74
+
75
+
76
+ # Updates self with the passed in parameters
77
+ def update_entry(params)
78
+ result = self.update_attributes(params)
79
+ raise ActiveResource::ResourceInvalid if result == false
80
+ self
81
+ end
82
+
83
+ # Deletes reference to the upload
84
+ def remove_entry
85
+ self.destroy
86
+ end
87
+
88
+ # Attribute accessors to comply with the backend spec
89
+ def upload_id
90
+ self[:id]
91
+ end
92
+
93
+ def date_created
94
+ self[:created_at]
95
+ end
96
+
97
+ # Provide a clean up function that uses the condo strata to delete itself
98
+ # NOTE:: this won't work with completely dynamic providers so is really just here
99
+ # as a helper if you have pre-defined storage providers
100
+ def cleanup
101
+ options = {}
102
+ options[:namespace] = self.provider_namespace if self.provider_namespace
103
+ options[:location] = self.provider_location if self.provider_location
104
+ residence = ::Condo::Configuration.get_residence(self.provider_name, options)
105
+
106
+ if residence
107
+ residence.destroy(self)
108
+ self.destroy
109
+ else
110
+ raise NotImplementedError, 'unable to find static residence'
111
+ end
112
+ end
113
+ end
114
+ end
115
+ end
@@ -1,9 +1,5 @@
1
1
  module CondoActiveRecord
2
- class Engine < ::Rails::Engine
3
- engine_name :condo_active_record
4
-
5
-
6
-
7
-
8
- end
2
+ class Engine < ::Rails::Engine
3
+ engine_name :condo_active_record
4
+ end
9
5
  end
@@ -1,3 +1,3 @@
1
1
  module CondoActiveRecord
2
- VERSION = "1.0.0"
2
+ VERSION = "2.0.0"
3
3
  end
metadata CHANGED
@@ -1,62 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: condo_active_record
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
5
- prerelease:
4
+ version: 2.0.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Stephen von Takach
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-11-08 00:00:00.000000000 Z
11
+ date: 2016-03-01 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
- version: 3.0.0
19
+ version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
- version: 3.0.0
26
+ version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: condo
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: sqlite3
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  description: Provides database storage and migrations though utilising ActiveRecord.
@@ -66,22 +59,26 @@ executables: []
66
59
  extensions: []
67
60
  extra_rdoc_files: []
68
61
  files:
62
+ - LGPL3-LICENSE
63
+ - README.textile
64
+ - Rakefile
69
65
  - db/migrate/20111001022500_init.rb
70
66
  - db/migrate/20111106022500_filepath.rb
67
+ - db/migrate/20160214022500_parallel.rb
71
68
  - lib/condo/backend/active_record.rb
69
+ - lib/condo_active_record.rb
72
70
  - lib/condo_active_record/engine.rb
73
71
  - lib/condo_active_record/version.rb
74
- - lib/condo_active_record.rb
75
72
  - lib/tasks/condo_active_record_tasks.rake
76
- - LGPL3-LICENSE
77
- - Rakefile
78
- - README.textile
79
73
  - test/condo_active_record_test.rb
74
+ - test/dummy/README.rdoc
75
+ - test/dummy/Rakefile
80
76
  - test/dummy/app/assets/javascripts/application.js
81
77
  - test/dummy/app/assets/stylesheets/application.css
82
78
  - test/dummy/app/controllers/application_controller.rb
83
79
  - test/dummy/app/helpers/application_helper.rb
84
80
  - test/dummy/app/views/layouts/application.html.erb
81
+ - test/dummy/config.ru
85
82
  - test/dummy/config/application.rb
86
83
  - test/dummy/config/boot.rb
87
84
  - test/dummy/config/database.yml
@@ -97,38 +94,34 @@ files:
97
94
  - test/dummy/config/initializers/wrap_parameters.rb
98
95
  - test/dummy/config/locales/en.yml
99
96
  - test/dummy/config/routes.rb
100
- - test/dummy/config.ru
101
97
  - test/dummy/public/404.html
102
98
  - test/dummy/public/422.html
103
99
  - test/dummy/public/500.html
104
100
  - test/dummy/public/favicon.ico
105
- - test/dummy/Rakefile
106
- - test/dummy/README.rdoc
107
101
  - test/dummy/script/rails
108
102
  - test/test_helper.rb
109
103
  homepage: http://cotag.me/
110
104
  licenses: []
105
+ metadata: {}
111
106
  post_install_message:
112
107
  rdoc_options: []
113
108
  require_paths:
114
109
  - lib
115
110
  required_ruby_version: !ruby/object:Gem::Requirement
116
- none: false
117
111
  requirements:
118
- - - ! '>='
112
+ - - ">="
119
113
  - !ruby/object:Gem::Version
120
114
  version: '0'
121
115
  required_rubygems_version: !ruby/object:Gem::Requirement
122
- none: false
123
116
  requirements:
124
- - - ! '>='
117
+ - - ">="
125
118
  - !ruby/object:Gem::Version
126
119
  version: '0'
127
120
  requirements: []
128
121
  rubyforge_project:
129
- rubygems_version: 1.8.24
122
+ rubygems_version: 2.4.6
130
123
  signing_key:
131
- specification_version: 3
124
+ specification_version: 4
132
125
  summary: ActiveRecord backend for the Condo project.
133
126
  test_files:
134
127
  - test/condo_active_record_test.rb
@@ -161,3 +154,4 @@ test_files:
161
154
  - test/dummy/README.rdoc
162
155
  - test/dummy/script/rails
163
156
  - test/test_helper.rb
157
+ has_rdoc: