class Slipsquare::Middleware::MakeDirectory

Public Instance Methods

call(env) click to toggle source
# File lib/slipsquare/middleware/make_directory.rb, line 6
def call(env)
  say "Creating directory on Dropbox..."

  friendly_path = env["mkdir_path"]

  if friendly_path =~ (/[\\\:\?\*\<\>\"\|]+/)
    friendly_path = friendly_path.gsub(/[\\\:\?\*\<\>\"\|]+/, '')
    say "Illegal character found! Escaping...", :yellow
    say "Escaped directory path: #{friendly_path}"
  end

  new_folder_response = env['dropbox-client'].mkdir(env["mkdir_path"])

  say "Directory `#{friendly_path}` created successfully", :green

  @app.call(env)
end