Sha256: 4ca20cc90bf52b447f269283ab8faaf7db387681038cad3a63188f79b7bb2fe9

Contents?: true

Size: 864 Bytes

Versions: 1

Compression:

Stored size: 864 Bytes

Contents

require 'pwd'
module Faraday::CLI::MiddlewareFetcher
  extend self

  require 'faraday/cli/middleware_fetcher/container'

  def extend!(faraday_connection_builder, *config_file_paths)
    container = Faraday::CLI::MiddlewareFetcher::Container.new(faraday_connection_builder)
    get_file_paths(config_file_paths).each { |file_path| container.merge!(file_path) }
  end

  protected

  def get_file_paths(config_file_paths)
    file_name = '{.faraday.rb,.faraday}'
    case

      when !config_file_paths.empty?
        config_file_paths

      when !(file_paths = Dir.glob(File.join(Dir.pwd, file_name))).empty?
        file_paths

      when !(file_paths = Dir.glob(File.join(PWD.pwd, file_name))).empty?
        file_paths

      when !(file_paths = Dir.glob(File.join(ENV['HOME'], file_name))).empty?
        file_paths

      else
        []

    end
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
faraday-cli-0.3.0 lib/faraday/cli/middleware_fetcher.rb