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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a72057225c71056a2dc5988c98c289bd510f8d3e4aa349122b0320b82ad37a8
4
- data.tar.gz: b5955919a7e72c44068e83e4cb24ac531f2a35e32882008782ae4cf11e225f96
3
+ metadata.gz: 9aaf5cf5c03bbff13b6dfa068ca6c2940ac5f56c0c5bf29e8eab24f734645b43
4
+ data.tar.gz: 70b8dca807ddbbcf8899cd7d70d0aaa8f3b87a17a27049d729ee80dccaf3b69d
5
5
  SHA512:
6
- metadata.gz: 92d2ca4e756258bd8074343c113636758ac2e7a8816d9301aa00a93f31cfaafbbf45dc6f029d2eb165fa6e5494d35bfacecd2a82444352dc1564f4ad819d299b
7
- data.tar.gz: 1eea263424389acb1d6350be042feeb9419c1b7a229f50b9d7aa093832765b8e601ec7a9649e0360b3c33a68ea045e2f6337970a3c0dccd4f19f7a3e2360ffe7
6
+ metadata.gz: cb0b7076e65bc20b29fff8d34ca513a25a7a645d47b50595637a9354b689b193a767b1400d0b7bd0cdbc9d1de70392b16ce39da0867ca8a8eea64aaad8af499c
7
+ data.tar.gz: 37baed4901f96624eed812223270c5bfa0f827b023ee14fd9e2193336e9575a4b8806ca222133c6fde55d150b359e60206fb684afd76166c17bba7b09046ba24
@@ -7,3 +7,4 @@ require 'securerandom'
7
7
 
8
8
  require_relative "storage/bucket"
9
9
  require_relative "storage/object"
10
+ require_relative "storage/upload"
@@ -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,
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Canistor
4
- VERSION = '0.3.0'
4
+ VERSION = '0.3.1'
5
5
  end
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.0
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-05-29 00:00:00.000000000 Z
11
+ date: 2018-07-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler