Class: Html2rss::MCP::ConfigArgument

Inherits:
Data
  • Object
show all
Defined in:
lib/html2rss/mcp/config_argument.rb

Overview

Feed config supplied over MCP as a hash XOR a YAML string.

Config does not know MCP. YAML parsing stays on Config.from_yaml.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config

Returns:

  • (Object)

    the current value of config



8
9
10
# File 'lib/html2rss/mcp/config_argument.rb', line 8

def config
  @config
end

Class Method Details

.parse(config: nil, yaml: nil) ⇒ ConfigArgument

Parameters:

  • config (Hash, nil) (defaults to: nil)

    feed configuration hash

  • yaml (String, nil) (defaults to: nil)

    feed configuration YAML

Returns:

Raises:

  • (ArgumentError)

    unless exactly one of config or yaml is present

  • (Contract::UnpublishedRequestError)

    when the parsed config uses an unpublished MCP strategy or request.local_file_path



17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/html2rss/mcp/config_argument.rb', line 17

def parse(config: nil, yaml: nil)
  parsed = case [present?(config), present?(yaml)]
           in [true, false]
             HashUtil.deep_symbolize_keys(config, context: 'config')
           in [false, true]
             Config.from_yaml(yaml)
           else
             raise ArgumentError, 'Provide exactly one of config or yaml'
           end
  Contract.assert_published_request!(parsed)
  new(config: parsed)
end