egnyte 0.0.1 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MDFhNGJmODEwMWVhYzExZDM2YzI2YjYzZGQyMDM0ODQyNTc2ZTg4MA==
4
+ ZmJiZmE1MmY3MDE0ZjY4NDE4NWQxNjY3OTZmYTYxZjk4NzViNDQzMQ==
5
5
  data.tar.gz: !binary |-
6
- OTFlYjhhZjY4NzBiM2M3YzExM2M1YzEwNWU2N2M2NjBmM2QwZWQ1MA==
6
+ M2M2OWZlNGFmZjMxMTRlMjdmZmNjZGFiODkyODEyODk0MWZkZmZhNA==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- YzViMDFmN2VjMjU2N2U1MGE5OGNlYTExMzUyZDFiNzBjODQ3NjI1YzVmYTIy
10
- MWNjMzRlZDViZjI2ZmRlZmM1YWNiNGMzMWI4MTI3YjMwODI4NDBhMzUxNjJl
11
- NDNhMmZlYWU2NTg1ZWE4NzI3NTBjYzg0MWFlZTE5MDdkMTcwODg=
9
+ ZDk0ZTk5MDA1ZjliYjQ5OGM4Mzc1YTE3ZjY1NzM0ZGI0OWI4ZDEwNDM4OTAw
10
+ NmViNzI4ODY3M2NlZmY4OTA0OTFiMDQ5OTY0ZDdiYjJjZjdkMjg0YmZiZTc4
11
+ NjE4ZTg0YjYzMGEzMWFkODkyMDcxMDEwNmZiOWY2YzdmMzA1ZTg=
12
12
  data.tar.gz: !binary |-
13
- ZDA0MjNlMmY0OWFmMTY5OGFlMDdmYmNiZGFjOTQwNGJiMzVmYTFjZDUyMGNl
14
- ZTE4ZDA4ODMyMWU0YzExODA2MzBkNjhjYjFmMzhmNTU0YzllNDdhMzA5ZWRj
15
- Nzk5ZDA4OWU3MDRkMmU1YTY2ZDI0NWY4OTc5ZGFjZjE5MGY3YzM=
13
+ ZDMyNmRmZmVmNDg0Y2ZmZmU1YmZjZTdjN2JlMWMyYzI2ODExOWU1MmQ2ODg2
14
+ NDRmZTc4MTM0ZmUzZTViZGQ4MDFlNmQ3OWVhYTVjMzYxZTZlZDRmOTA0Mjhh
15
+ M2I0OGU4Y2IzZDA4MTEzZGNiMzM0MmE1N2UyMDgxNWU0MjA3MDQ=
@@ -47,6 +47,7 @@ module Egnyte
47
47
  private
48
48
 
49
49
  def create_objects(klass, key)
50
+ return [] unless @data[key]
50
51
  @data[key].map do |data|
51
52
  data = data.merge({
52
53
  'path' => "#{path}/#{data['name']}"
@@ -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::Multipart.new(uri.path, {
56
- "filename" => UploadIO.new(data, MIME::Types.type_for(filename).first, filename)
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
 
@@ -1,3 +1,3 @@
1
1
  module Egnyte
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -8,7 +8,7 @@ describe Egnyte::File 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
 
@@ -0,0 +1,12 @@
1
+ {
2
+ "name":"docs",
3
+ "is_folder":true,
4
+ "folder_id":"d7d56ebc-ce31-4ba8-a6b3-292ffb43f215",
5
+ "folders":[
6
+ {
7
+ "name":"subfolder1",
8
+ "is_folder":true,
9
+ "folder_id":"5652844d-dd48-45a9-b8be-3d06c06c819a"
10
+ }
11
+ ]
12
+ }
@@ -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.1
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-11 00:00:00.000000000 Z
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