module AuslibConfig
AuslibConfig — Trove API credentials and URL constants for !auslib. Public: api_key, configured?, setup_hint Depends: RabbotDb (via load_db_credentials) Tests: test/lib/auslib_search_test.rb
Constants
- API_BASE
- BROWSE_BASE
- MAX_QUERY_LENGTH
- MAX_RESULTS
- MAX_TITLE_LENGTH
- PLUGIN_NAME
- SEARCH_CATEGORIES
- USER_AGENT
Public Instance Methods
Source
# File lib/auslib_config.rb, line 23 def api_key(key: nil) resolved = key.to_s.strip resolved = ENV.fetch("TROVE_API_KEY", "").to_s.strip if resolved.empty? if resolved.empty? db = load_db_credentials resolved = db[:api_key].to_s end resolved end
Source
# File lib/auslib_config.rb, line 33 def configured?(key: nil) !api_key(key: key).empty? end
Source
# File lib/auslib_config.rb, line 37 def load_db_credentials require_relative "rabbot_db" RabbotDb.get_plugin_json(plugin: PLUGIN_NAME, key: "auslib_credentials", default: {}) .transform_keys(&:to_sym) rescue StandardError { api_key: "" } end
Source
# File lib/auslib_config.rb, line 45 def setup_hint "Trove API key required — set TROVE_API_KEY, or store via RabbotDb plugin_data." end