canistor 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/canistor/storage.rb +1 -0
- data/lib/canistor/storage/bucket.rb +24 -0
- data/lib/canistor/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9aaf5cf5c03bbff13b6dfa068ca6c2940ac5f56c0c5bf29e8eab24f734645b43
|
4
|
+
data.tar.gz: 70b8dca807ddbbcf8899cd7d70d0aaa8f3b87a17a27049d729ee80dccaf3b69d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb0b7076e65bc20b29fff8d34ca513a25a7a645d47b50595637a9354b689b193a767b1400d0b7bd0cdbc9d1de70392b16ce39da0867ca8a8eea64aaad8af499c
|
7
|
+
data.tar.gz: 37baed4901f96624eed812223270c5bfa0f827b023ee14fd9e2193336e9575a4b8806ca222133c6fde55d150b359e60206fb684afd76166c17bba7b09046ba24
|
data/lib/canistor/storage.rb
CHANGED
@@ -14,6 +14,7 @@ module Canistor
|
|
14
14
|
|
15
15
|
attr_reader :access_keys
|
16
16
|
attr_reader :objects
|
17
|
+
attr_reader :uploads
|
17
18
|
|
18
19
|
def initialize(**attributes)
|
19
20
|
@access_keys = Set.new
|
@@ -68,6 +69,17 @@ module Canistor
|
|
68
69
|
end
|
69
70
|
end
|
70
71
|
|
72
|
+
def post(context, access_key_id, subject)
|
73
|
+
if access_keys.include?(access_key_id)
|
74
|
+
Canistor.take_fail(:store) { return }
|
75
|
+
upload = build_upload(subject, context)
|
76
|
+
self[upload.id] = upload
|
77
|
+
upload.get(context, subject)
|
78
|
+
else
|
79
|
+
Canistor::ErrorHandler.serve_access_denied(context, subject)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
71
83
|
def delete(context, access_key_id, subject)
|
72
84
|
if !access_keys.include?(access_key_id)
|
73
85
|
Canistor::ErrorHandler.serve_access_denied(context, subject)
|
@@ -81,11 +93,15 @@ module Canistor
|
|
81
93
|
|
82
94
|
def clear
|
83
95
|
@objects = {}
|
96
|
+
@uploads = {}
|
84
97
|
end
|
85
98
|
|
86
99
|
def to_s
|
87
100
|
@objects.values.map do |object|
|
88
101
|
' * ' + object.label
|
102
|
+
end.join("\n") +
|
103
|
+
@uploads.keys.each do |upload_id|
|
104
|
+
' - ' + upload_id
|
89
105
|
end.join("\n")
|
90
106
|
end
|
91
107
|
|
@@ -99,6 +115,14 @@ module Canistor
|
|
99
115
|
|
100
116
|
private
|
101
117
|
|
118
|
+
def build_upload(subject, context)
|
119
|
+
Canistor::Storage::Upload.new(
|
120
|
+
region: subject.region,
|
121
|
+
bucket: subject.bucket,
|
122
|
+
key: subject.key
|
123
|
+
)
|
124
|
+
end
|
125
|
+
|
102
126
|
def find_or_build_object(subject, context)
|
103
127
|
objects[subject.key] || Canistor::Storage::Object.new(
|
104
128
|
region: subject.region,
|
data/lib/canistor/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: canistor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Manfred Stienstra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-07-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|