egnyte 0.0.1 → 0.0.5
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 +8 -8
- data/lib/egnyte/folder.rb +1 -0
- data/lib/egnyte/session.rb +9 -4
- data/lib/egnyte/version.rb +1 -1
- data/spec/file_spec.rb +1 -1
- data/spec/fixtures/folder_listing_no_files.json +12 -0
- data/spec/folder_spec.rb +11 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZmJiZmE1MmY3MDE0ZjY4NDE4NWQxNjY3OTZmYTYxZjk4NzViNDQzMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
M2M2OWZlNGFmZjMxMTRlMjdmZmNjZGFiODkyODEyODk0MWZkZmZhNA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDk0ZTk5MDA1ZjliYjQ5OGM4Mzc1YTE3ZjY1NzM0ZGI0OWI4ZDEwNDM4OTAw
|
10
|
+
NmViNzI4ODY3M2NlZmY4OTA0OTFiMDQ5OTY0ZDdiYjJjZjdkMjg0YmZiZTc4
|
11
|
+
NjE4ZTg0YjYzMGEzMWFkODkyMDcxMDEwNmZiOWY2YzdmMzA1ZTg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZDMyNmRmZmVmNDg0Y2ZmZmU1YmZjZTdjN2JlMWMyYzI2ODExOWU1MmQ2ODg2
|
14
|
+
NDRmZTc4MTM0ZmUzZTViZGQ4MDFlNmQ3OWVhYTVjMzYxZTZlZDRmOTA0Mjhh
|
15
|
+
M2I0OGU4Y2IzZDA4MTEzZGNiMzM0MmE1N2UyMDgxNWU0MjA3MDQ=
|
data/lib/egnyte/folder.rb
CHANGED
data/lib/egnyte/session.rb
CHANGED
@@ -3,11 +3,12 @@ module Egnyte
|
|
3
3
|
|
4
4
|
attr_accessor :domain, :api
|
5
5
|
|
6
|
-
def initialize(opts, strategy=:implicit)
|
6
|
+
def initialize(opts, strategy=:implicit, backoff=0.5)
|
7
7
|
|
8
8
|
@strategy = strategy # the authentication strategy to use.
|
9
9
|
raise Egnyte::UnsupportedAuthStrategy unless @strategy == :implicit
|
10
10
|
|
11
|
+
@backoff = backoff # only two requests are allowed a second by Egnyte.
|
11
12
|
@api = 'pubapi' # currently we only support the public API.
|
12
13
|
|
13
14
|
# the domain of the egnyte account to interact with.
|
@@ -52,9 +53,9 @@ module Egnyte
|
|
52
53
|
def multipart_post(url, filename, data)
|
53
54
|
uri = URI.parse(url)
|
54
55
|
|
55
|
-
request = Net::HTTP::Post
|
56
|
-
|
57
|
-
|
56
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
57
|
+
request.body = data.read
|
58
|
+
request.content_type = 'application/binary'
|
58
59
|
|
59
60
|
resp = request(uri, request)
|
60
61
|
end
|
@@ -83,6 +84,10 @@ module Egnyte
|
|
83
84
|
|
84
85
|
response = http.request(request)
|
85
86
|
|
87
|
+
# Egnyte throttles requests to
|
88
|
+
# two requests per second.
|
89
|
+
sleep(@backoff)
|
90
|
+
|
86
91
|
parse_response( response.code.to_i, response.body )
|
87
92
|
end
|
88
93
|
|
data/lib/egnyte/version.rb
CHANGED
data/spec/file_spec.rb
CHANGED
data/spec/folder_spec.rb
CHANGED
@@ -8,7 +8,7 @@ describe Egnyte::Folder do
|
|
8
8
|
key: 'api_key',
|
9
9
|
domain: 'test',
|
10
10
|
access_token: 'access_token'
|
11
|
-
})
|
11
|
+
}, :implicit, 0.0)
|
12
12
|
@client = Egnyte::Client.new(session)
|
13
13
|
end
|
14
14
|
|
@@ -49,6 +49,16 @@ describe Egnyte::Folder do
|
|
49
49
|
file.is_a?(Egnyte::File).should == true
|
50
50
|
file.path.should == 'Shared/test.txt'
|
51
51
|
end
|
52
|
+
|
53
|
+
it "should return an empty array if there arent any files in the folder" do
|
54
|
+
stub_request(:get, "https://test.egnyte.com/pubapi/v1/fs/Shared")
|
55
|
+
.with(:headers => { 'Authorization' => 'Bearer access_token' })
|
56
|
+
.to_return(:body => File.read('./spec/fixtures/folder_listing_no_files.json'), :status => 200)
|
57
|
+
|
58
|
+
folder = @client.folder
|
59
|
+
files = folder.files
|
60
|
+
files.size.should == 0
|
61
|
+
end
|
52
62
|
end
|
53
63
|
|
54
64
|
describe "#folders" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: egnyte
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Coe
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-07-
|
14
|
+
date: 2013-07-31 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: multipart-post
|
@@ -148,6 +148,7 @@ files:
|
|
148
148
|
- lib/egnyte/session.rb
|
149
149
|
- lib/egnyte/version.rb
|
150
150
|
- spec/file_spec.rb
|
151
|
+
- spec/fixtures/folder_listing_no_files.json
|
151
152
|
- spec/fixtures/list_file.json
|
152
153
|
- spec/fixtures/list_folder.json
|
153
154
|
- spec/folder_spec.rb
|
@@ -179,6 +180,7 @@ specification_version: 4
|
|
179
180
|
summary: Ruby client for Egnyte version 1 API. Built and maintained by Attachments.me.
|
180
181
|
test_files:
|
181
182
|
- spec/file_spec.rb
|
183
|
+
- spec/fixtures/folder_listing_no_files.json
|
182
184
|
- spec/fixtures/list_file.json
|
183
185
|
- spec/fixtures/list_folder.json
|
184
186
|
- spec/folder_spec.rb
|