condo_active_record 1.0.0 → 2.0.0
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.
- checksums.yaml +7 -0
- data/db/migrate/20111001022500_init.rb +28 -28
- data/db/migrate/20111106022500_filepath.rb +9 -9
- data/db/migrate/20160214022500_parallel.rb +7 -0
- data/lib/condo/backend/active_record.rb +115 -105
- data/lib/condo_active_record/engine.rb +3 -7
- data/lib/condo_active_record/version.rb +1 -1
- metadata +24 -30
checksums.yaml
ADDED
@@ -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
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
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
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
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
|
@@ -1,105 +1,115 @@
|
|
1
|
-
module Condo
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
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
|
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:
|
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:
|
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:
|
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:
|
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:
|
122
|
+
rubygems_version: 2.4.6
|
130
123
|
signing_key:
|
131
|
-
specification_version:
|
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:
|