<commit_before>helpers do

  def make_dropbox_folder(name, client)
    if client.metadata(name) == nil
      client.file_create_folder(name)
    elsif client.metadata(name)["is_deleted"] == true
      client.file_create_folder(name)
    end
  end

  def dropbox_flow
    DropboxOAuth2Flow.new( ENV['DROPBOX_KEY'],	ENV['DROPBOX_SECRET'], ENV['DROPBOX_CALLBACK'], session, :dropbox_token)
  end

  def move_dropbox_file(client, file_url, destination_url)
    client.file_move(file_url, destination_url)
  end

  def name_archive_folder
    require 'date'
    now = Date.today
    week_ago = now - 7
    today = Time.now.strftime("%Y-%m-%d")
    "#{week_ago}_to_#{today}"
  end

  def create_archive_folder(client)
    "/archive/" + name_archive_folder
  end

  def tweet_all_images_in_folder(client, user_id = current_user.id)
    archive_folder = create_archive_folder(client)
    if client.metadata('/this-week')["contents"].empty?
      #puts "I am empty"
      twitter_media_upload("I made nothing this week. Posted via @weekerapp #weekerapp", "https://www.phactual.com/wp-content/uploads/2014/11/arrested-development-snoopy.jpg")
    else
      client.metadata('/this-week')["contents"].each do |image|
        image_path = image["path"]
        content_url = client.media(image_path)["url"]
        dropbox_url = content_url + "?dl=1"
        twitter_media_upload("This is something: Posted via @weekerapp #weekerapp", dropbox_url, user_id)
        destination_url = image_path.gsub(/\/this-week/,archive_folder)
        move_dropbox_file(client, image_path, destination_url)
        sleep 5
      end
    end
  end

end 
<commit_msg>refactor dropbox_helper to reference dropbox_module<commit_after>require_relative 'dropbox_module'
helpers do

  include DropboxToTwitter

end 

{'fraction_non_alphanumeric': 0.10998877665544332, 'fraction_numerical': 0.005611672278338945, 'mean_word_length': 3.9390581717451525, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1182180', 'n_tokens_mistral': 613, 'n_tokens_neox': 593, 'n_words': 113}