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
  • Save xiconet/6eba311c6b7351d5c8ff to your computer and use it in GitHub Desktop.
Save xiconet/6eba311c6b7351d5c8ff to your computer and use it in GitHub Desktop.

Revisions

  1. xiconet renamed this gist Oct 27, 2014. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. @cburnette cburnette revised this gist Mar 30, 2014. 1 changed file with 6 additions and 5 deletions.
    11 changes: 6 additions & 5 deletions Iterate Box folders in Ruby
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,14 @@
    require 'ruby-box' #gem install ruby-box
    require 'term/ansicolor' #gem install term-ansicolor
    require 'parallel' #gem install Parallel

    include Term::ANSIColor

    MODIFIED_AT_CUTOFF = Time.new(2013,7,1)

    session = RubyBox::Session.new({
    client_id: "6nbxyrx54ikg9j8rb444l8uf_replace",
    client_secret: "ugVH49V8OsOnPkORHduBB_replace",
    access_token: "hNhvDFopBHbm6yOqrDuoD_replace"
    client_id: "YOUR_CLIENT_ID",
    client_secret: "YOUR_CLIENT_SECRET",
    access_token: "YOUR_DEV_ACCESS_TOKEN"
    })

    @client = RubyBox::Client.new(session)
    @@ -25,7 +24,9 @@ def load_folder(folder, path_prefix="/")
    end

    subFolders = folder.folders
    Parallel.each(subFolders, :in_threads=>1){|f| load_folder f, "#{path}/"}
    subFolders.each do |f|
    load_folder(f,"#{path}/")
    end
    end

    load_folder @client.root_folder
  3. @cburnette cburnette revised this gist Mar 28, 2014. 1 changed file with 8 additions and 13 deletions.
    21 changes: 8 additions & 13 deletions Iterate Box folders in Ruby
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,15 @@
    require 'ruby-box'
    require 'term/ansicolor' #gem install term-ansicolor
    require 'ruby-box' #gem install ruby-box
    require 'term/ansicolor' #gem install term-ansicolor
    require 'parallel' #gem install Parallel

    include Term::ANSIColor

    MODIFIED_AT_CUTOFF = Time.new(2013,7,1)

    session = RubyBox::Session.new({
    client_id: "6nbxyrx54ikg9j8rb444l8_not_real",
    client_secret: "ugVH49V8OsOnPkORHduBBql5A_not_real",
    access_token: "Xb1zHzCZM4jcs96d6Dl4kzNe_not_real"
    client_id: "6nbxyrx54ikg9j8rb444l8uf_replace",
    client_secret: "ugVH49V8OsOnPkORHduBB_replace",
    access_token: "hNhvDFopBHbm6yOqrDuoD_replace"
    })

    @client = RubyBox::Client.new(session)
    @@ -20,17 +21,11 @@ def load_folder(folder, path_prefix="/")
    files = folder.files(nil,1000,0,['name','modified_at'])
    files.each do |f|
    output = "--> #{f.name}"
    if f.modified_at < MODIFIED_AT_CUTOFF
    puts red(output)
    else
    puts output
    end
    puts f.modified_at < MODIFIED_AT_CUTOFF ? red(output) : output
    end

    subFolders = folder.folders
    subFolders.each do |f|
    load_folder f, "#{path}/"
    end
    Parallel.each(subFolders, :in_threads=>1){|f| load_folder f, "#{path}/"}
    end

    load_folder @client.root_folder
  4. @cburnette cburnette revised this gist Mar 28, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Iterate Box folders in Ruby
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    require 'ruby-box'
    require 'term/ansicolor'
    require 'term/ansicolor' #gem install term-ansicolor

    include Term::ANSIColor

  5. @cburnette cburnette created this gist Mar 28, 2014.
    36 changes: 36 additions & 0 deletions Iterate Box folders in Ruby
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    require 'ruby-box'
    require 'term/ansicolor'

    include Term::ANSIColor

    MODIFIED_AT_CUTOFF = Time.new(2013,7,1)

    session = RubyBox::Session.new({
    client_id: "6nbxyrx54ikg9j8rb444l8_not_real",
    client_secret: "ugVH49V8OsOnPkORHduBBql5A_not_real",
    access_token: "Xb1zHzCZM4jcs96d6Dl4kzNe_not_real"
    })

    @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}"
    if f.modified_at < MODIFIED_AT_CUTOFF
    puts red(output)
    else
    puts output
    end
    end

    subFolders = folder.folders
    subFolders.each do |f|
    load_folder f, "#{path}/"
    end
    end

    load_folder @client.root_folder