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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 25dfc7308afd0409761d01f84aeef74883b0fefd
4
- data.tar.gz: a972e3e986a9effb39eabc9fce5aca542347209d
3
+ metadata.gz: 6312e9a59c93988f2cf32a545c94a95fa68c8682
4
+ data.tar.gz: f3e34f77f5e903f3952ab91f80295850b4d3f95b
5
5
  SHA512:
6
- metadata.gz: 6180e855f755b27332275e158bd3e4e1e589a9ff0c70f571983df6a424dd2403d301180e72616452c1718edfd9a22d80975cb9f41d24c630b384b54289add6bc
7
- data.tar.gz: 8f1fbff58a6d5cac0137da38841aea4b3514465935583848237d4632fc6d9f6e5383e97843d9f6a9c5cba3a093e235c8d0e62b5f770ee3dded52445d6346e46b
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
@@ -1,6 +1,6 @@
1
1
  require 'kinto_box/kinto_record'
2
2
  require 'kinto_box/kinto_object'
3
- require 'kinto_box/kinto_object'
3
+
4
4
  module KintoBox
5
5
  class KintoCollection
6
6
  include KintoObject
@@ -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
@@ -37,6 +37,8 @@ module KintoBox
37
37
  when 'create'
38
38
  return 'collection:create' if self.kind_of? KintoBucket
39
39
  return 'record:create' if self.kind_of? KintoCollection
40
+ when 'group:create'
41
+ return 'group:create'
40
42
  else
41
43
  raise Exception 'not a valid permission'
42
44
  end
@@ -1,3 +1,3 @@
1
1
  module KintoBox
2
- VERSION = "0.1.4"
2
+ VERSION = "0.1.5"
3
3
  end
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
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-06 00:00:00.000000000 Z
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