kinto_box 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/kinto_box/kinto_bucket.rb +16 -0
- data/lib/kinto_box/kinto_collection.rb +1 -1
- data/lib/kinto_box/kinto_group.rb +39 -0
- data/lib/kinto_box/kinto_object.rb +2 -0
- data/lib/kinto_box/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6312e9a59c93988f2cf32a545c94a95fa68c8682
|
4
|
+
data.tar.gz: f3e34f77f5e903f3952ab91f80295850b4d3f95b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5b109553b471bf1c4baecf2f24fa82cc4d50bb1cfe2c45c3cb86ad4c2082f70ed99c0de66f5318049a2f916a1e3e1a71d9330c5437f3cf8728760f68540517b5
|
7
|
+
data.tar.gz: 8d91c8afc2ba0a95149ee8de0fed7b44908efa344a1c3f03ba1cc7548e874513a60f5750cfc78e420dab60f24e0251790827a5f9bb46cf23ac85c45d9a87a004
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'kinto_box/kinto_collection'
|
2
2
|
require 'kinto_box/kinto_object'
|
3
|
+
require 'kinto_box/kinto_group'
|
3
4
|
module KintoBox
|
4
5
|
class KintoBucket
|
5
6
|
include KintoObject
|
@@ -19,16 +20,31 @@ module KintoBox
|
|
19
20
|
@kinto_client.get("#{@url_path}/collections")
|
20
21
|
end
|
21
22
|
|
23
|
+
def list_groups
|
24
|
+
@kinto_client.get("#{@url_path}/groups")
|
25
|
+
end
|
26
|
+
|
22
27
|
def collection (collection_id)
|
23
28
|
@collection = KintoCollection.new(self, collection_id)
|
24
29
|
@collection
|
25
30
|
end
|
26
31
|
|
32
|
+
def group(group_id)
|
33
|
+
@group = KintoGroup.new(self, group_id)
|
34
|
+
@group
|
35
|
+
end
|
36
|
+
|
27
37
|
def create_collection(collection_id)
|
28
38
|
@kinto_client.post("#{@url_path}/collections", { 'data' => { 'id' => collection_id}})
|
29
39
|
collection(collection_id)
|
30
40
|
end
|
31
41
|
|
42
|
+
def create_group(group_id, members)
|
43
|
+
members = [members] unless members.is_a?(Array)
|
44
|
+
@kinto_client.put("#{@url_path}/groups/#{group_id}", { 'data' => { 'members' => members}})
|
45
|
+
group(group_id)
|
46
|
+
end
|
47
|
+
|
32
48
|
def delete_collections
|
33
49
|
@kinto_client.delete("#{@url_path}/collections")
|
34
50
|
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'kinto_box/kinto_object'
|
2
|
+
|
3
|
+
module KintoBox
|
4
|
+
class KintoGroup
|
5
|
+
include KintoObject
|
6
|
+
|
7
|
+
attr_accessor :id
|
8
|
+
attr_reader :bucket
|
9
|
+
|
10
|
+
def initialize (bucket, group_id)
|
11
|
+
raise ArgumentError if bucket.nil? || group_id.nil?
|
12
|
+
@kinto_client = bucket.kinto_client
|
13
|
+
@bucket = bucket
|
14
|
+
@id = group_id
|
15
|
+
@url_path = "/buckets/#{bucket.id}/groups/#{@id}"
|
16
|
+
end
|
17
|
+
|
18
|
+
def update_members(members)
|
19
|
+
members = [members] unless members.is_a?(Array)
|
20
|
+
update({ 'members' => members })
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_member(member)
|
24
|
+
members = info['data']['members']
|
25
|
+
members << member
|
26
|
+
update({ 'members' => members })
|
27
|
+
end
|
28
|
+
|
29
|
+
def remove_member(member)
|
30
|
+
members = info['data']['members']
|
31
|
+
members.delete(member)
|
32
|
+
update({ 'members' => members })
|
33
|
+
end
|
34
|
+
|
35
|
+
def delete_records
|
36
|
+
@kinto_client.delete("#{@url_path}/records")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
data/lib/kinto_box/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kinto_box
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kavya Sukumar
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httparty
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- lib/kinto_box.rb
|
106
106
|
- lib/kinto_box/kinto_bucket.rb
|
107
107
|
- lib/kinto_box/kinto_collection.rb
|
108
|
+
- lib/kinto_box/kinto_group.rb
|
108
109
|
- lib/kinto_box/kinto_object.rb
|
109
110
|
- lib/kinto_box/kinto_record.rb
|
110
111
|
- lib/kinto_box/response_handler.rb
|