Class: GemChangelogDiff::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/gem_changelog_diff/configuration.rb

Overview

Holds runtime settings for the gem (token, cache, format, timeouts).

Constant Summary collapse

VALID_KEYS =
%i[github_token cache_enabled cache_ttl default_format concurrency
ignore_gems no_color request_timeout total_timeout].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



22
23
24
25
26
27
28
29
30
31
# File 'lib/gem_changelog_diff/configuration.rb', line 22

def initialize
  @cache_enabled = true
  @cache_ttl = 86_400
  @default_format = "text"
  @concurrency = 4
  @ignore_gems = []
  @no_color = false
  @request_timeout = 10
  @total_timeout = 120
end

Instance Attribute Details

#cache_enabledString, ...

Returns:

  • (String, nil)

    GitHub personal access token

  • (Boolean)

    whether disk caching is enabled

  • (Integer)

    cache time-to-live in seconds

  • (String)

    default output format ("text", "json", "markdown")

  • (Integer)

    number of concurrent fetch threads

  • (Array<String>)

    gem names to skip

  • (Boolean)

    whether to disable colored output

  • (Integer)

    per-request HTTP timeout in seconds

  • (Integer)

    total operation timeout in seconds



15
16
17
# File 'lib/gem_changelog_diff/configuration.rb', line 15

def cache_enabled
  @cache_enabled
end

#cache_ttlString, ...

Returns:

  • (String, nil)

    GitHub personal access token

  • (Boolean)

    whether disk caching is enabled

  • (Integer)

    cache time-to-live in seconds

  • (String)

    default output format ("text", "json", "markdown")

  • (Integer)

    number of concurrent fetch threads

  • (Array<String>)

    gem names to skip

  • (Boolean)

    whether to disable colored output

  • (Integer)

    per-request HTTP timeout in seconds

  • (Integer)

    total operation timeout in seconds



15
16
17
# File 'lib/gem_changelog_diff/configuration.rb', line 15

def cache_ttl
  @cache_ttl
end

#concurrencyString, ...

Returns:

  • (String, nil)

    GitHub personal access token

  • (Boolean)

    whether disk caching is enabled

  • (Integer)

    cache time-to-live in seconds

  • (String)

    default output format ("text", "json", "markdown")

  • (Integer)

    number of concurrent fetch threads

  • (Array<String>)

    gem names to skip

  • (Boolean)

    whether to disable colored output

  • (Integer)

    per-request HTTP timeout in seconds

  • (Integer)

    total operation timeout in seconds



15
16
17
# File 'lib/gem_changelog_diff/configuration.rb', line 15

def concurrency
  @concurrency
end

#default_formatString, ...

Returns:

  • (String, nil)

    GitHub personal access token

  • (Boolean)

    whether disk caching is enabled

  • (Integer)

    cache time-to-live in seconds

  • (String)

    default output format ("text", "json", "markdown")

  • (Integer)

    number of concurrent fetch threads

  • (Array<String>)

    gem names to skip

  • (Boolean)

    whether to disable colored output

  • (Integer)

    per-request HTTP timeout in seconds

  • (Integer)

    total operation timeout in seconds



15
16
17
# File 'lib/gem_changelog_diff/configuration.rb', line 15

def default_format
  @default_format
end

#github_tokenString, ...

Returns:

  • (String, nil)

    GitHub personal access token

  • (Boolean)

    whether disk caching is enabled

  • (Integer)

    cache time-to-live in seconds

  • (String)

    default output format ("text", "json", "markdown")

  • (Integer)

    number of concurrent fetch threads

  • (Array<String>)

    gem names to skip

  • (Boolean)

    whether to disable colored output

  • (Integer)

    per-request HTTP timeout in seconds

  • (Integer)

    total operation timeout in seconds



15
16
17
# File 'lib/gem_changelog_diff/configuration.rb', line 15

def github_token
  @github_token
end

#ignore_gemsString, ...

Returns:

  • (String, nil)

    GitHub personal access token

  • (Boolean)

    whether disk caching is enabled

  • (Integer)

    cache time-to-live in seconds

  • (String)

    default output format ("text", "json", "markdown")

  • (Integer)

    number of concurrent fetch threads

  • (Array<String>)

    gem names to skip

  • (Boolean)

    whether to disable colored output

  • (Integer)

    per-request HTTP timeout in seconds

  • (Integer)

    total operation timeout in seconds



15
16
17
# File 'lib/gem_changelog_diff/configuration.rb', line 15

def ignore_gems
  @ignore_gems
end

#no_colorString, ...

Returns:

  • (String, nil)

    GitHub personal access token

  • (Boolean)

    whether disk caching is enabled

  • (Integer)

    cache time-to-live in seconds

  • (String)

    default output format ("text", "json", "markdown")

  • (Integer)

    number of concurrent fetch threads

  • (Array<String>)

    gem names to skip

  • (Boolean)

    whether to disable colored output

  • (Integer)

    per-request HTTP timeout in seconds

  • (Integer)

    total operation timeout in seconds



15
16
17
# File 'lib/gem_changelog_diff/configuration.rb', line 15

def no_color
  @no_color
end

#request_timeoutString, ...

Returns:

  • (String, nil)

    GitHub personal access token

  • (Boolean)

    whether disk caching is enabled

  • (Integer)

    cache time-to-live in seconds

  • (String)

    default output format ("text", "json", "markdown")

  • (Integer)

    number of concurrent fetch threads

  • (Array<String>)

    gem names to skip

  • (Boolean)

    whether to disable colored output

  • (Integer)

    per-request HTTP timeout in seconds

  • (Integer)

    total operation timeout in seconds



15
16
17
# File 'lib/gem_changelog_diff/configuration.rb', line 15

def request_timeout
  @request_timeout
end

#total_timeoutString, ...

Returns:

  • (String, nil)

    GitHub personal access token

  • (Boolean)

    whether disk caching is enabled

  • (Integer)

    cache time-to-live in seconds

  • (String)

    default output format ("text", "json", "markdown")

  • (Integer)

    number of concurrent fetch threads

  • (Array<String>)

    gem names to skip

  • (Boolean)

    whether to disable colored output

  • (Integer)

    per-request HTTP timeout in seconds

  • (Integer)

    total operation timeout in seconds



15
16
17
# File 'lib/gem_changelog_diff/configuration.rb', line 15

def total_timeout
  @total_timeout
end

Instance Method Details

#apply(hash) ⇒ void

This method returns an undefined value.

Applies a hash of settings, ignoring unknown keys and nil values.

Parameters:

  • hash (Hash<Symbol, Object>)

    configuration key-value pairs



36
37
38
39
40
# File 'lib/gem_changelog_diff/configuration.rb', line 36

def apply(hash)
  hash.each do |key, value|
    public_send(:"#{key}=", value) if VALID_KEYS.include?(key) && !value.nil?
  end
end