Skip to content

Instantly share code, notes, and snippets.

@xiconet
Forked from cburnette/Iterate Box folders in Ruby
Last active August 29, 2015 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xiconet/6eba311c6b7351d5c8ff to your computer and use it in GitHub Desktop.
Save xiconet/6eba311c6b7351d5c8ff to your computer and use it in GitHub Desktop.
Iterate Box folders in Ruby
require 'ruby-box' #gem install ruby-box
require 'term/ansicolor' #gem install term-ansicolor
include Term::ANSIColor
MODIFIED_AT_CUTOFF = Time.new(2013,7,1)
session = RubyBox::Session.new({
client_id: "YOUR_CLIENT_ID",
client_secret: "YOUR_CLIENT_SECRET",
access_token: "YOUR_DEV_ACCESS_TOKEN"
})
@client = RubyBox::Client.new(session)
def load_folder(folder, path_prefix="/")
path = "#{path_prefix}#{folder.name}"
puts path
files = folder.files(nil,1000,0,['name','modified_at'])
files.each do |f|
output = "--> #{f.name}"
puts f.modified_at < MODIFIED_AT_CUTOFF ? red(output) : output
end
subFolders = folder.folders
subFolders.each do |f|
load_folder(f,"#{path}/")
end
end
load_folder @client.root_folder
@xiconet
Copy link
Author

xiconet commented Oct 27, 2014

Uses the "official" ruby-box gem. Might be useful

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment