roozer_client 0.7 → 0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MmNkOGEyOGRhMGU4NTYzNDNiMWIyOGM0YzhmMDU2ODA1NzUwOGMzNg==
4
+ NmIwZWU0ZTJlZjQyMzQwZGU5Mjc5YWUyZWUxOTQyNWQxOGViOWQwMg==
5
5
  data.tar.gz: !binary |-
6
- YmJkYjYyOWVhNjQyZjk0NzI0OGEyODdkOGE1OTc1MmVmNTliNTE0Ng==
6
+ NzU2NTk4YWVjMzliNjdhZmNjMzhmZWU3MTA5MzBiYzQ2NTAwYWJkZg==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- NTNkMzY5N2U2ZDBhMWY0YTY1NDYwNmUyODFjMjE2YzFlZWEzNzlkYWVmZTNj
10
- NmUwNzEwN2QwZTllNTMwMWFlOTI2NzU4ODBiNzdkMDBmNzY5MjJmZjEzZDJi
11
- MjcxZDI5NGMzYjNhZmRjMzMzZWIyYjZiNjZiZTM4NmQzNWU3MmQ=
9
+ MTg1MTQzNGY2Mjc0ZDMyNTJkM2I0MmMxZWQxNTE0Y2MwMjgzNzZjMDRkOTMy
10
+ ZGZkZjIzMzg5MTI4MjBmYzM4YWVlYWFlZmZjZDBjNWRhNDNhNmIyZWY0MjJl
11
+ NThjZGZhN2MxYjk4OTRkMTE2Y2VlYzBkNTlkNDU5MGZhYmY0MTk=
12
12
  data.tar.gz: !binary |-
13
- MGU3NmI2NDE4MzIxYTRiMWY5M2NkYTUxN2Q3ZDdiNDk0YzBlYmE0YjI1MmRj
14
- ZTUzNTlhOTk3ZDQyNTI4MDdjMjI5ZTE5MzVjNDZjN2U2MzljNGQ3MTIxZjQ3
15
- YjU5MDUwNzI5YTUwODAzZDEzZWZjNDgzNGQ0ZjhhMTE5MDk0MWI=
13
+ NGJjNTk3NTgyY2UyMTk2YjIwYTdmZDk3N2JiZWY3Yzc3YmI3NGViNjg4ZGQ3
14
+ NGNiYzFhODlkMjdiNmI2YmYzNDEwYWU4MTkwYTE2ZjRlMGU4MzYwZjMyNjE5
15
+ YmYxMmE2NGVkYjQ3MGI3NjBjZGQ3ZmE2N2IxYWNjNGFhNGRkNzA=
data/CHANGELOG CHANGED
@@ -1,3 +1,4 @@
1
+ v0.8. tree and deltree
1
2
  v0.7. more accurate change detection for update
2
3
  v0.6. support delete and update methods
3
4
  v0.5. Catch more network errors
data/README CHANGED
@@ -7,15 +7,27 @@ require 'roozer_client'
7
7
 
8
8
  rc = RoozerClient.new(url: 'http://orch1:2987;http://orch2:2987', path: 'rootpath')
9
9
 
10
+ # Create a file
10
11
  rc['subpath'] = { data: "abc" }
11
12
 
13
+ # List dirs
12
14
  rc.list
13
15
  => ['subpath']
14
16
 
17
+ # Read a file
15
18
  rc['subpath']
16
19
  => { "data" => "abc" }
17
20
 
21
+ # List all dirs in a depth-first traversal
22
+ rc['dir1/dir2/dir3'] = true
23
+ rc.tree 'dir1'
24
+ => ["/dir1/dir2/dir3", "/dir1/dir2", "/dir1"]
25
+
26
+ # Delete a file
18
27
  rc.delete 'subpath/data'
19
28
 
29
+ # Delete all files in a directory tree
30
+ rc.deltree 'dir1'
31
+
20
32
  # sets the data only if is different to what is already there
21
33
  rc.update(path, {...data...})
data/lib/roozer_client.rb CHANGED
@@ -39,6 +39,26 @@ class RoozerClient
39
39
  request(:delete, path)
40
40
  end
41
41
 
42
+ def deltree(path)
43
+ tree(path).each do |entry|
44
+ begin
45
+ delete(entry)
46
+ rescue RestClient::ResourceNotFound:
47
+ end
48
+ end
49
+ end
50
+
51
+ def tree(path=nil)
52
+ result = []
53
+ entries = list(path)
54
+ if entries
55
+ entries.each do |entry|
56
+ result.push(*tree("#{path}/#{entry}"))
57
+ end
58
+ end
59
+ result.push path
60
+ end
61
+
42
62
  def update(path, data)
43
63
  existing_data = get(path) rescue nil
44
64
  put(path, data) unless data && existing_data == JSON.parse(data.to_json)
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "roozer_client"
5
- s.version = "0.7"
5
+ s.version = "0.8"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Andrew Snow"]
9
- s.date = "2013-04-19"
9
+ s.date = "2013-06-05"
10
10
  s.description = "Ruby client for Roozer server"
11
11
  s.email = "andrew@modulus.org"
12
12
  s.extra_rdoc_files = ["CHANGELOG", "README", "lib/roozer_client.rb"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: roozer_client
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.7'
4
+ version: '0.8'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Snow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-04-19 00:00:00.000000000 Z
11
+ date: 2013-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  type: :runtime