Module: AppHelper

Defined in:
spec/spec_helper.rb

Overview

A module that provides helper methods for application functionality.

The AppHelper module encapsulates various utility methods that support core application operations, including JSON object parsing and chat configuration management.

Examples:

Using the json_object method

json_object('{"key": "value"}')

Using the chat_default_config method

chat_default_config(['-m', 'llama3.1'])

Instance Method Summary collapse

Instance Method Details

#chat_default_config(argv = []) ⇒ Array<String>

The chat_default_config method constructs a default configuration array for chat sessions.

This method initializes a configuration array with a default config file path and any additional arguments provided.

Parameters:

  • argv (Array<String>) (defaults to: [])

    an array of additional arguments to prepend to the default config

Returns:

  • (Array<String>)

    a new array containing the default config file path and any additional arguments



132
133
134
# File 'spec/spec_helper.rb', line 132

def chat_default_config(argv = [])
  argv + %w[ -f lib/ollama_chat/ollama_chat_config/default_config.yml ]
end

#json_object(json_string) ⇒ JSON::GenericObject

The json_object method parses a JSON string into a structured object.

Parameters:

  • json_string (String)

    a JSON formatted string to be parsed

Returns:

  • (JSON::GenericObject)

    the parsed JSON object with generic object class



116
117
118
119
# File 'spec/spec_helper.rb', line 116

def json_object(json_string)
  json_string.full? or return
  JSON.parse(json_string, object_class: JSON::GenericObject)
end