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.88 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.87 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.86 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.85 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.84 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.83 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.82 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.81 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.80 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.79 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.78 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.77 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.76 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.75 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.74 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.73 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.72 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.71 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.70 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb
harbr-0.1.69 vendor/bundle/ruby/3.2.0/gems/standard-1.32.0/lib/standard/resolves_yaml_option.rb