module

Transmission::RPC::ClassicCodec

Translates between the shard's internal snake_case representation and Transmission's classic on-the-wire dialect (hyphenated/camelCase keys, camelCase responses).

The shard speaks snake_case everywhere internally (method names, argument keys, the fields array, and the {Torrent}/etc. models). This module is the single place that knows how to convert that to and from the classic wire format, so the rest of the {Client} — and models.cr — stay snake_case and protocol-agnostic.

Constants

CLASSIC_KEY_EXCEPTIONS = {"bandwidth_priority" => "bandwidthPriority", "download_limit" => "downloadLimit", "download_limited" => "downloadLimited", "honors_session_limits" => "honorsSessionLimits", "seed_idle_limit" => "seedIdleLimit", "seed_idle_mode" => "seedIdleMode", "seed_ratio_limit" => "seedRatioLimit", "seed_ratio_mode" => "seedRatioMode", "seed_ratio_limited" => "seedRatioLimited", "upload_limit" => "uploadLimit", "upload_limited" => "uploadLimited", "queue_position" => "queuePosition", "tracker_list" => "trackerList", "tracker_add" => "trackerAdd", "tracker_remove" => "trackerRemove", "tracker_replace" => "trackerReplace"}

Argument keys whose classic spelling is camelCase rather than the default snake_case→hyphen conversion. Drawn from the Transmission 4.0.6 rpc-spec.md (torrent-set/session-set mutator tables): most torrent-set keys are camelCase, while most session-set keys and the torrent-add/torrent-remove keys are hyphenated. Anything not listed here is converted snake_casehyphen-ated.

PASSTHROUGH_KEYS = ["ids", "fields", "labels", "location", "metainfo", "filename", "cookies", "paused", "format", "path", "name", "move", "group", "tag"] of ::String

Argument keys that pass through untouched (already protocol-neutral).

Instance methods

argument_key(key : String) : String

Converts an internal snake_case argument key to its classic form. Passthrough keys are returned unchanged, keys in {CLASSIC_KEY_EXCEPTIONS} get their camelCase spelling, and everything else is hyphenated (download_dirdownload-dir).

Source
arguments(arguments : Hash(String, JSON::Any)) : Hash(String, JSON::Any)

Converts a snake_case arguments hash into the classic key spelling, also translating the few values that differ between dialects (the recently_active ids selector).

Source
camel_to_snake(name : String) : String

Normalizes a classic response key to snake_case: hashStringhash_string, and torrent-addedtorrent_added (a handful of classic response keys are hyphenated rather than camelCase). Idempotent for already-snake_case input.

Source
field_name(name : String) : String

Converts a single snake_case torrent-get field name to the camelCase form classic expects: hash_stringhashString, percent_donepercentDone, idid.

Source
method_name(name : String) : String

Converts an internal snake_case method name to its classic hyphenated form: torrent_gettorrent-get.

Source
snake_to_camel(name : String) : String

hash_stringhashString. Leaves already-lowercase single words untouched.

Source
snakecase_keys(value : JSON::Any) : JSON::Any

Recursively rewrites every object key in a classic (camelCase) response value to snake_case, descending into nested objects and arrays. This lets the snake_case {Torrent}/etc. models deserialize a classic response unchanged.

Source