Module: BerkeleyLibrary::TIND::Config

Extended by:
Util::URIs
Defined in:
lib/berkeley_library/tind/config.rb

Constant Summary collapse

ENV_TIND_API_KEY =

The environment variable from which to read the TIND API key.

'LIT_TIND_API_KEY'.freeze
ENV_TIND_BASE_URL =

The root URL for the TIND installation

'LIT_TIND_BASE_URL'.freeze
DEFAULT_TZID =
'America/Los_Angeles'.freeze
DEFAULT_USER_AGENT =
"#{ModuleInfo::NAME} #{ModuleInfo::VERSION} (#{ModuleInfo::HOMEPAGE})".freeze

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.api_keyString?

Gets the TIND API key.

Returns:

  • (String, nil)

    the TIND API key, or nil if not set.



28
29
30
# File 'lib/berkeley_library/tind/config.rb', line 28

def api_key
  @api_key ||= default_tind_api_key
end

Class Method Details

.base_uriObject



32
33
34
# File 'lib/berkeley_library/tind/config.rb', line 32

def base_uri
  @base_uri ||= default_tind_base_uri
end

.base_uri=(value) ⇒ Object



36
37
38
# File 'lib/berkeley_library/tind/config.rb', line 36

def base_uri=(value)
  @base_uri = uri_or_nil(value)
end

.blank?(v) ⇒ Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/berkeley_library/tind/config.rb', line 60

def blank?(v)
  v.nil? || v.to_s.strip.empty?
end

.timezoneObject



40
41
42
# File 'lib/berkeley_library/tind/config.rb', line 40

def timezone
  @timezone ||= default_timezone
end

.timezone=(value) ⇒ Object

Raises:

  • (ArgumentError)


44
45
46
47
48
# File 'lib/berkeley_library/tind/config.rb', line 44

def timezone=(value)
  raise ArgumentError, "Not a #{TZInfo::Timezone}" unless value.respond_to?(:utc_to_local)

  @timezone = value
end

.user_agentObject



50
51
52
# File 'lib/berkeley_library/tind/config.rb', line 50

def user_agent
  @user_agent || DEFAULT_USER_AGENT
end

.user_agent=(value) ⇒ Object

Raises:

  • (ArgumentError)


54
55
56
57
58
# File 'lib/berkeley_library/tind/config.rb', line 54

def user_agent=(value)
  raise ArgumentError, 'TIND firewall rules require a user agent' if blank?(value)

  @user_agent = value
end