Sha256: 72a7be46e1f10e7cc66dcafa4900520ba0ac42b17bce747ff6a972d31dc93051

Contents?: true

Size: 706 Bytes

Versions: 108

Compression:

Stored size: 706 Bytes

Contents

require "pathname"

module Standard
  class ResolvesYamlOption
    def call(argv, search_path, option_name, default_file)
      search_argv(argv, option_name) || FileFinder.new.call(default_file, search_path)
    end

    private

    def search_argv(argv, option_name)
      return unless (config_file = argv_value_for(argv, option_name))

      resolved_config = Pathname.new(config_file)
      if resolved_config.exist?
        resolved_config.expand_path
      else
        raise "Configuration file \"#{resolved_config.expand_path}\" not found."
      end
    end

    def argv_value_for(argv, option_name)
      return unless (index = argv.index(option_name))
      argv[index + 1]
    end
  end
end

Version data entries

108 entries across 108 versions & 3 rubygems

Version Path
harbr-0.1.68 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.67 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.66 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.65 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.64 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.63 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.62 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.61 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.60 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.59 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.58 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.57 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.56 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.55 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.54 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.53 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.52 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.50 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.49 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.48 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb