module Support
  module Paths # TODO: switch to class
    # TODO: reduce number of methods
    class << self
      def cucumber_root
        rel = File.join(File.dirname(__FILE__), "../")
        File.expand_path(rel)
      end

      def temp_root
        File.join(cucumber_root, "temp")
      end

      def logs_root
        create_dir(cucumber_root, "logs", "cucumber")
      end

      def downloads
        create_dir(temp_root, "downloads")
      end

      def uploads
        create_dir(temp_root, "uploads")
      end

      def assets
        File.join(cucumber_root, "features", "assets")
      end

      def plugins
        File.join(cucumber_root, "features", "support", "plugins")
      end

      private

      def create_dir(*path) # move this to an entry point process
        File.join(path).tap do |dir|
          FileUtils.mkdir_p dir
        end
      end
    end
  end
end
