ocman 1.3.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ocman.rb +6 -2
- data/lib/ocman/dav.rb +2 -4
- data/lib/ocman/folder.rb +36 -0
- data/lib/ocman/share.rb +2 -2
- data/lib/ocman/version.rb +1 -1
- metadata +21 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01adcff61e626c6b19883ece249e25d7b7df6f5a1223aeb35b8ac117dc5eb1ab
|
4
|
+
data.tar.gz: f0231c022308483bdc19b490632d653e17c7692aa8680036423e8495bd49b7ea
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1623d11c9a31c730a3169dbae68e2454c7f03873b14254b31c4296d9cbd55bbbdd4fb64b6c00a71969795e9864087ad44d960f16966779c77c8dabbed3d8f53
|
7
|
+
data.tar.gz: 5a8fa49d48f2d1a3e66fcf7af8dddcef628567b70c835966276312c48aeb981fa43d0877adcbd728f3aea3c745069ad33050ef06a53e4cbe9f02e0523bf0693e
|
data/lib/ocman.rb
CHANGED
@@ -35,8 +35,12 @@ module Ocman
|
|
35
35
|
Ocman::Folder.list(path, options)
|
36
36
|
end
|
37
37
|
|
38
|
-
def self.create_folder(path)
|
39
|
-
|
38
|
+
def self.create_folder(path, recursive: false)
|
39
|
+
if recursive
|
40
|
+
Ocman::Folder.create_recursive(path)
|
41
|
+
else
|
42
|
+
Ocman::Folder.create(path)
|
43
|
+
end
|
40
44
|
end
|
41
45
|
|
42
46
|
### files
|
data/lib/ocman/dav.rb
CHANGED
@@ -11,10 +11,8 @@ module Ocman
|
|
11
11
|
connection.mkdir(uri(path))
|
12
12
|
end
|
13
13
|
|
14
|
-
def ls(path, options = {})
|
15
|
-
connection.find(uri(path), options)
|
16
|
-
yield(item)
|
17
|
-
end
|
14
|
+
def ls(path, options = {}, &block)
|
15
|
+
connection.find(uri(path), options, &block)
|
18
16
|
end
|
19
17
|
|
20
18
|
def put(file_path, path, options = {})
|
data/lib/ocman/folder.rb
CHANGED
@@ -7,8 +7,17 @@ require 'erb'
|
|
7
7
|
module Ocman
|
8
8
|
class Folder
|
9
9
|
class << self
|
10
|
+
def create_recursive(path)
|
11
|
+
path_list(path).each do |path_part|
|
12
|
+
next if ignore404 { list(path_part) }
|
13
|
+
|
14
|
+
create(path_part)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
10
18
|
def create(path)
|
11
19
|
Ocman::Dav.new.mkdir(escape_path(path))
|
20
|
+
wait_for_folder(path)
|
12
21
|
end
|
13
22
|
|
14
23
|
def list(path, options = {})
|
@@ -30,6 +39,33 @@ module Ocman
|
|
30
39
|
def escape_path(path)
|
31
40
|
path.split('/').map { |segment| ERB::Util.url_encode(segment) }.join('/')
|
32
41
|
end
|
42
|
+
|
43
|
+
def wait_for_folder(path)
|
44
|
+
wait_time = 1
|
45
|
+
retries = 0
|
46
|
+
loop do
|
47
|
+
raise TimeoutError if retries >= 3
|
48
|
+
break if Ocman.list(path)
|
49
|
+
|
50
|
+
sleep wait_time
|
51
|
+
wait_time *= 2
|
52
|
+
retries += 1
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def ignore404
|
57
|
+
yield
|
58
|
+
rescue Net::HTTPServerException => e
|
59
|
+
raise unless e.to_s.match?(/404.*Not found/i)
|
60
|
+
|
61
|
+
nil
|
62
|
+
end
|
63
|
+
|
64
|
+
def path_list(path)
|
65
|
+
path.split('/').reduce([]) do |acc, segment|
|
66
|
+
acc << [acc.last, segment].compact.join('/')
|
67
|
+
end
|
68
|
+
end
|
33
69
|
end
|
34
70
|
end
|
35
71
|
end
|
data/lib/ocman/share.rb
CHANGED
@@ -65,12 +65,12 @@ module Ocman
|
|
65
65
|
params: {
|
66
66
|
path: attributes[:path],
|
67
67
|
format: 'json'
|
68
|
-
}.
|
68
|
+
}.compact
|
69
69
|
}
|
70
70
|
end
|
71
71
|
|
72
72
|
def share_url(id = nil)
|
73
|
-
Ocman.configuration.base_url
|
73
|
+
"#{Ocman.configuration.base_url}/ocs/v1.php/apps/files_sharing/api/v1/shares#{"/#{id}" if id}"
|
74
74
|
end
|
75
75
|
end
|
76
76
|
end
|
data/lib/ocman/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ocman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Waldemar Gribele
|
@@ -129,28 +129,42 @@ dependencies:
|
|
129
129
|
requirements:
|
130
130
|
- - "~>"
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version:
|
132
|
+
version: 1.6.1
|
133
133
|
type: :development
|
134
134
|
prerelease: false
|
135
135
|
version_requirements: !ruby/object:Gem::Requirement
|
136
136
|
requirements:
|
137
137
|
- - "~>"
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
version:
|
139
|
+
version: 1.6.1
|
140
|
+
- !ruby/object:Gem::Dependency
|
141
|
+
name: rubocop-rake
|
142
|
+
requirement: !ruby/object:Gem::Requirement
|
143
|
+
requirements:
|
144
|
+
- - "~>"
|
145
|
+
- !ruby/object:Gem::Version
|
146
|
+
version: '0.5'
|
147
|
+
type: :development
|
148
|
+
prerelease: false
|
149
|
+
version_requirements: !ruby/object:Gem::Requirement
|
150
|
+
requirements:
|
151
|
+
- - "~>"
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
version: '0.5'
|
140
154
|
- !ruby/object:Gem::Dependency
|
141
155
|
name: rubocop-rspec
|
142
156
|
requirement: !ruby/object:Gem::Requirement
|
143
157
|
requirements:
|
144
158
|
- - "~>"
|
145
159
|
- !ruby/object:Gem::Version
|
146
|
-
version: 1.
|
160
|
+
version: 2.1.0
|
147
161
|
type: :development
|
148
162
|
prerelease: false
|
149
163
|
version_requirements: !ruby/object:Gem::Requirement
|
150
164
|
requirements:
|
151
165
|
- - "~>"
|
152
166
|
- !ruby/object:Gem::Version
|
153
|
-
version: 1.
|
167
|
+
version: 2.1.0
|
154
168
|
description: Ruby gem for file managment and sharing in nextcloud/owncloud
|
155
169
|
email: laboratories@toptranslation.com
|
156
170
|
executables: []
|
@@ -177,14 +191,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
177
191
|
requirements:
|
178
192
|
- - ">="
|
179
193
|
- !ruby/object:Gem::Version
|
180
|
-
version: '
|
194
|
+
version: '2.4'
|
181
195
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
196
|
requirements:
|
183
197
|
- - ">="
|
184
198
|
- !ruby/object:Gem::Version
|
185
199
|
version: '0'
|
186
200
|
requirements: []
|
187
|
-
rubygems_version: 3.1.
|
201
|
+
rubygems_version: 3.1.4
|
188
202
|
signing_key:
|
189
203
|
specification_version: 4
|
190
204
|
summary: Ocman - Manages files and shares in nextcloud/owncloud
|