blobs 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/blobs/version.rb +1 -1
- data/lib/blobs.rb +21 -14
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2db96b44e679e209d021ae68a1e2ae774587cb85
|
4
|
+
data.tar.gz: bad53bb902bb78c301e7e2ad74cc3a38f31728cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f984ca11dc6f8629ec7f64843ca4b495ef3f91cf21b91ab0806c4d29d7049543d62190664c5fb96a99c5e0a11951ece2e2819f58d4fc8137cced06d2ac1cb77c
|
7
|
+
data.tar.gz: 7399915d11a599cce6fc3d436f54b0b38d1ffe26559a8c28fadb22cd71170ec0366897f24d64f39fc3c1aa8a035b8debe27aaf55b287044e0e4b09e45fc91a07
|
data/lib/blobs/version.rb
CHANGED
data/lib/blobs.rb
CHANGED
@@ -43,20 +43,17 @@ module Blobs
|
|
43
43
|
def create_user(email, password)
|
44
44
|
raise "You need to set the master key to create users!" unless master_token
|
45
45
|
user = { email: email, password: password }
|
46
|
-
response = HTTParty.post("#{base_url}/users
|
47
|
-
body: user)
|
46
|
+
response = HTTParty.post("#{base_url}/users",
|
47
|
+
body: user, headers: { 'Authorization': "Bearer #{master_token}" })
|
48
48
|
log "#{response.parsed_response.inspect}"
|
49
|
-
|
50
|
-
return response.parsed_response
|
51
|
-
end
|
52
|
-
nil
|
49
|
+
response.parsed_response
|
53
50
|
end
|
54
51
|
|
55
52
|
def all(key = nil)
|
56
53
|
raise 'No access token!' unless self.token
|
57
|
-
url = "#{base_url}/blobs
|
54
|
+
url = "#{base_url}/blobs"
|
58
55
|
url += "&key=#{CGI::escape(sha256(key))}" if key
|
59
|
-
response = HTTParty.get(url)
|
56
|
+
response = HTTParty.get(url, { headers: headers })
|
60
57
|
log "Blobs: #{response.parsed_response.inspect}"
|
61
58
|
response.parsed_response.map do |blob|
|
62
59
|
{
|
@@ -72,7 +69,7 @@ module Blobs
|
|
72
69
|
def find(blob_id)
|
73
70
|
raise 'No access token!' unless self.token
|
74
71
|
raise "No blob id!" unless blob_id
|
75
|
-
response = HTTParty.get("#{base_url}/blobs/#{blob_id}
|
72
|
+
response = HTTParty.get("#{base_url}/blobs/#{blob_id}", { headers: headers })
|
76
73
|
log "Blob: #{response.parsed_response.inspect}"
|
77
74
|
response.parsed_response ? JSON.parse(decrypt(response.parsed_response['json'])) : nil
|
78
75
|
end
|
@@ -81,8 +78,12 @@ module Blobs
|
|
81
78
|
raise 'No access token!' unless self.token
|
82
79
|
raise "No json hash!" unless json
|
83
80
|
raise "No key!" unless key
|
84
|
-
response = HTTParty.post("#{base_url}/blobs
|
85
|
-
{
|
81
|
+
response = HTTParty.post("#{base_url}/blobs",
|
82
|
+
{
|
83
|
+
body: { json: encrypt(json.to_json), key: sha256(key), isFile: is_file },
|
84
|
+
headers: headers
|
85
|
+
}
|
86
|
+
)
|
86
87
|
log "Blob created: #{response.parsed_response.inspect}"
|
87
88
|
response.parsed_response
|
88
89
|
end
|
@@ -91,8 +92,8 @@ module Blobs
|
|
91
92
|
raise 'No access token!' unless self.token
|
92
93
|
raise "No blob id!" unless json
|
93
94
|
raise "No json hash!" unless json
|
94
|
-
response = HTTParty.put("#{base_url}/blobs/#{blob_id}
|
95
|
-
{ body: { json: encrypt(json.to_json), key: sha256(key) } })
|
95
|
+
response = HTTParty.put("#{base_url}/blobs/#{blob_id}",
|
96
|
+
{ body: { json: encrypt(json.to_json), key: sha256(key) }, headers: headers })
|
96
97
|
log "Blob update: #{response.parsed_response.inspect}"
|
97
98
|
response.parsed_response
|
98
99
|
end
|
@@ -100,7 +101,7 @@ module Blobs
|
|
100
101
|
def destroy(blob_id)
|
101
102
|
raise 'No access token!' unless self.token
|
102
103
|
raise "No blob id!" unless blob_id
|
103
|
-
response = HTTParty.delete("#{base_url}/blobs/#{blob_id}
|
104
|
+
response = HTTParty.delete("#{base_url}/blobs/#{blob_id}", { headers: headers })
|
104
105
|
log "Blob destroyed: #{response.parsed_response.inspect}"
|
105
106
|
response.parsed_response
|
106
107
|
end
|
@@ -154,6 +155,12 @@ module Blobs
|
|
154
155
|
end
|
155
156
|
|
156
157
|
private
|
158
|
+
def headers(additional_headers = {})
|
159
|
+
additional_headers.merge({
|
160
|
+
'Authorization': "Bearer #{self.token}"
|
161
|
+
})
|
162
|
+
end
|
163
|
+
|
157
164
|
def sha256(str)
|
158
165
|
Base64.encode64(Digest::SHA256.digest(str)).strip
|
159
166
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blobs
|
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
|
- Oliver Kiessler
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-07-
|
11
|
+
date: 2017-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|