box-com 0.0.7 → 0.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 +4 -4
- data/lib/box/authorization.rb +1 -1
- data/lib/box/client.rb +2 -2
- data/lib/box/folder.rb +5 -5
- data/lib/box/session.rb +2 -2
- data/lib/box/version.rb +1 -1
- data/lib/box.rb +5 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 421d1adf49695244d4846f6920a63eea6076e885
|
4
|
+
data.tar.gz: 11f07dbe8bbf8a88bd64566f7d5e77b55fb49768
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a726898f20e5b84f9a0f31212e5748a722d99aa8f18657a805592c1d9bc7cb4ef57c298b81a8713b2a7845c3a243e19ac31fe4abda58ea6f5ec4c292dc266bfd
|
7
|
+
data.tar.gz: 3a568e39854bf34476657f7f3b2d051ca0ca54bbf34c0b9dca0f342d7faa182bdeca014ff508d5f680f91c351cdc1beb5f9e0bd5b3780737715621fc43c4abd3
|
data/lib/box/authorization.rb
CHANGED
data/lib/box/client.rb
CHANGED
@@ -21,7 +21,7 @@ module Box
|
|
21
21
|
elsif item.file?
|
22
22
|
yield item
|
23
23
|
else
|
24
|
-
|
24
|
+
Box.log "Unknown item type #{item.id}:#{item.type}"
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -130,7 +130,7 @@ module Box
|
|
130
130
|
# params = {}
|
131
131
|
end
|
132
132
|
|
133
|
-
|
133
|
+
Box.log "#{method} #{::File.join(Box::API_URL, uri.to_s)}"
|
134
134
|
response = connection.send(method.downcase, uri.to_s, params)
|
135
135
|
|
136
136
|
case response.status
|
data/lib/box/folder.rb
CHANGED
@@ -22,15 +22,15 @@ module Box
|
|
22
22
|
folder = subfolder(folder_name)
|
23
23
|
return folder unless folder.nil?
|
24
24
|
|
25
|
-
|
25
|
+
Box.log "Creating subfolder in #{self.name} for #{folder_name}"
|
26
26
|
response = @client.post('folders', {name: folder_name, parent:{id: self.id}})
|
27
27
|
|
28
28
|
if response.status == 201 # created
|
29
29
|
folder = Box::Folder.new(@client, response.body)
|
30
|
-
|
30
|
+
Box.log "Created folder for #{folder_name} in #{name} as #{folder.id}"
|
31
31
|
folder
|
32
32
|
else
|
33
|
-
|
33
|
+
Box.log "Error creating folder, #{response.body}"
|
34
34
|
nil
|
35
35
|
end
|
36
36
|
|
@@ -43,7 +43,7 @@ module Box
|
|
43
43
|
params = {fields: 'sha1,name,path_collection,size', limit: LIMIT, offset: 0}.merge(params)
|
44
44
|
# Add expected fields and limit
|
45
45
|
response = @client.get("/folders/#{id}/items", params)
|
46
|
-
|
46
|
+
|
47
47
|
# Add the results to the total collection
|
48
48
|
collection.push *@client.parse_items(response.body)
|
49
49
|
|
@@ -51,7 +51,7 @@ module Box
|
|
51
51
|
offset = (LIMIT * (params[:offset] + 1))
|
52
52
|
|
53
53
|
if total_count > offset
|
54
|
-
|
54
|
+
Box.log "Recursively calling for items in folder #{name} - #{LIMIT}, #{offset}, #{total_count}"
|
55
55
|
return self.items({offset: offset}, collection)
|
56
56
|
end
|
57
57
|
|
data/lib/box/session.rb
CHANGED
@@ -58,8 +58,8 @@ module Box
|
|
58
58
|
rescue OAuth2::Error => e
|
59
59
|
if e.code == 'invalid_client' || ((e.code == 'invalid_grant') && (e.description == 'Refresh token has expired' || e.description == 'Invalid refresh token'))
|
60
60
|
raise e if @config[:disable_auth]
|
61
|
-
|
62
|
-
|
61
|
+
Box.log "Error authenticating Box -> #{e.message}"
|
62
|
+
Box.log 'Attempting to reauthorize and get new tokens'
|
63
63
|
@oauth2_access_token = Box::Authorization.authorize(config)
|
64
64
|
set_tokens!
|
65
65
|
return @oauth2_access_token
|
data/lib/box/version.rb
CHANGED
data/lib/box.rb
CHANGED
@@ -29,7 +29,7 @@ module Box
|
|
29
29
|
username: config['username'] || ENV['BOX_USERNAME'],
|
30
30
|
password: config['password'] || ENV['BOX_PASSWORD']
|
31
31
|
}
|
32
|
-
|
32
|
+
|
33
33
|
# Box::Authorization.authorize client_id, client_secret
|
34
34
|
session = create_session(config)
|
35
35
|
Box::Client.new(session)
|
@@ -40,6 +40,10 @@ module Box
|
|
40
40
|
Box::Session.new config
|
41
41
|
end
|
42
42
|
|
43
|
+
def log(message)
|
44
|
+
puts "[Box.com] #{message}".colorize(:color => :magenta, :background => :black)
|
45
|
+
end
|
46
|
+
|
43
47
|
end
|
44
48
|
end
|
45
49
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: box-com
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Michael
|
@@ -136,6 +136,20 @@ dependencies:
|
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: 0.9.3
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: colorize
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :runtime
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
139
153
|
description: Write a longer description. Optional.
|
140
154
|
email:
|
141
155
|
- david.michael@giantmachines.com
|