ruby-box 1.8.1 → 1.9.0

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
- MmMwNGQyZjc1ODQyYTFmM2ViNWE0MWY3N2Q2NDY1YWRmZGE2ZGNmNQ==
4
+ MTU5ODI5ODE2MGFlOTRiODk3MzNlOTA1MThhNDY2NTAwZTc1MDdhZg==
5
5
  data.tar.gz: !binary |-
6
- YTE3MzlhZDhkZmI0MmU2NGQ5MzlmM2UwZGQ2MjI3NGJkYzhjMjY4NQ==
6
+ YmJjNTdkZmZjNzVmN2U3YjcyMmM0YzVhZTgzZTE5YzUyYjA5YTNiNw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MTdlOTQyYjg0ZmRiNDQ3ZjljYzM0ZDYzZTlmYzY4NDJlNWJhYTZjMGRkYWFi
10
- NzdkMWNhMDIzYWQ3MzE1MWY4YTE0M2FmMWVhMTFkZGZhYzVjZDY4MGMwZTdl
11
- ZTE1NWYzYjQ2NGQxMzY5ZjA1YjZhOGJmMDY0ZTViZTI0MmNjMmU=
9
+ OWQzMjMwMmE4ZTgxMmE3OTU2OWVkNDI0NTllODUwNTJiMjY1YzU5MzRlMzE1
10
+ YTJlNWJhMmQ2Nzk3NjU5Y2IxZDM3YjU5NGQ2OTllYjJjYWYyYjg4MDhlYjk3
11
+ NGY3ZGZhYjkzMWViMGE5NDRlNjM1YWVjYTM0YjMwZTcwMWVlOTY=
12
12
  data.tar.gz: !binary |-
13
- MmI2MzI2ZDUyOGQ0OGY3MzAyZjZkNjBmNjU1Njc5MGNmOWQ4N2Y0YzZhMDI0
14
- Y2U0M2M4YWNlMjRhNmY3ZGQyN2JjNzQyZDc3Yzk5MGEzZjJhMjRjYWQxZmMz
15
- NzNiNjUwOTk3MjFiZDY2MjRkNjJiNWZiY2I1ZjQ3ZjBhZTYyNDE=
13
+ NWJmYWNmNzViMWY3YjVlYmVkODdhODE0M2Y0MTUzMTQyYzAxZjU0ZjQ5ZGM4
14
+ M2U5NzI2OWE3MjdiOGQwODU2NjNiYjQxNmVjN2U5ZmExZjE1NGY4ODIzNjA4
15
+ NGYzNGQzMzg0ZGZhZWRkYjQ0M2ZmOTNkMzgzZTJlZjYyZjY3ZDM=
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.8.1
1
+ 1.9.0
@@ -23,7 +23,21 @@ module RubyBox
23
23
  resp = file.upload_content(data) #write a new file. If there is a conflict, update the conflicted file.
24
24
  rescue RubyBox::ItemNameInUse => e
25
25
  data.rewind
26
- file = files(filename).first
26
+
27
+ # The Box API occasionally does not return
28
+ # context info for an ItemNameInUse exception.
29
+ # This is a workaround around:
30
+ begin
31
+ # were were given context information about this conflict?
32
+ file = RubyBox::File.new(@session, {
33
+ 'id' => e['context_info']['conflicts'][0]['id']
34
+ })
35
+ rescue
36
+ # we were not given context information about this conflict.
37
+ # attempt to lookup the file.
38
+ file = files(filename).pop
39
+ end
40
+
27
41
  resp = file.update_content( data )
28
42
  end
29
43
  end
@@ -9,7 +9,10 @@ module RubyBox
9
9
  :token_url => "/api/oauth2/token"
10
10
  }
11
11
 
12
- def initialize(opts={})
12
+ def initialize(opts={}, backoff=0.1)
13
+
14
+ @backoff = backoff # try not to excessively hammer API.
15
+
13
16
  if opts[:client_id]
14
17
  @oauth2_client = OAuth2::Client.new(opts[:client_id], opts[:client_secret], OAUTH2_URLS.dup)
15
18
  @access_token = OAuth2::AccessToken.new(@oauth2_client, opts[:access_token]) if opts[:access_token]
@@ -74,6 +77,8 @@ module RubyBox
74
77
  request(uri, request, raw, retries + 1)
75
78
  end
76
79
 
80
+ sleep(@backoff) # try not to excessively hammer API.
81
+
77
82
  handle_errors( response.code.to_i, response.body, raw )
78
83
  end
79
84
 
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "ruby-box"
8
- s.version = "1.8.1"
8
+ s.version = "1.9.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Attachments.me"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-box
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.1
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Attachments.me