Class: Ucode::Config
- Inherits:
-
Object
- Object
- Ucode::Config
- Defined in:
- lib/ucode/config.rb
Overview
Single injection point for all ucode runtime configuration.
This is the ONLY place in the codebase that reads ENV directly. Every other class reads configuration through Ucode.configuration.
Tests inject fresh Config instances; production reads ENV once on first access via Ucode.configuration.
Constant Summary collapse
- KNOWN_VERSIONS =
%w[15.0.0 15.1.0 16.0.0 17.0.0].freeze
- DEFAULT_CACHE_ROOT =
nil
Instance Attribute Summary collapse
-
#auxiliary_files ⇒ Object
Returns the value of attribute auxiliary_files.
-
#cache_root ⇒ Object
Returns the value of attribute cache_root.
-
#charts_base_url ⇒ Object
Returns the value of attribute charts_base_url.
-
#default_version ⇒ Object
Returns the value of attribute default_version.
-
#extracted_files ⇒ Object
Returns the value of attribute extracted_files.
-
#http_retries ⇒ Object
Returns the value of attribute http_retries.
-
#http_timeout ⇒ Object
Returns the value of attribute http_timeout.
-
#known_versions ⇒ Object
Returns the value of attribute known_versions.
-
#listing_url ⇒ Object
Returns the value of attribute listing_url.
-
#logger ⇒ Object
Logger shared by every subsystem (Fetch, Coordinator, Writer, …).
-
#output_dir ⇒ Object
Returns the value of attribute output_dir.
-
#parallel_workers ⇒ Object
Returns the value of attribute parallel_workers.
-
#pdf_renderer ⇒ Object
Returns the value of attribute pdf_renderer.
-
#ucd_base_url ⇒ Object
Returns the value of attribute ucd_base_url.
-
#unihan_base_url ⇒ Object
Returns the value of attribute unihan_base_url.
Instance Method Summary collapse
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #known?(version) ⇒ Boolean
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/ucode/config.rb', line 25 def initialize @cache_root = default_cache_root @output_dir = Pathname.new("./output") @default_version = "17.0.0" @known_versions = KNOWN_VERSIONS.dup @http_timeout = env_int("UCODE_HTTP_TIMEOUT", 30) @http_retries = env_int("UCODE_HTTP_RETRIES", 3) @pdf_renderer = :mutool @parallel_workers = env_int("UCODE_PARALLEL_WORKERS", 8) @ucd_base_url = "https://www.unicode.org/Public" @unihan_base_url = "https://www.unicode.org/Public" @charts_base_url = "https://www.unicode.org/charts/PDF" @listing_url = "https://www.unicode.org/Public/" @extracted_files = default_extracted_files @auxiliary_files = default_auxiliary_files @logger = Logger.new($stderr, level: Logger::WARN) end |
Instance Attribute Details
#auxiliary_files ⇒ Object
Returns the value of attribute auxiliary_files.
19 20 21 |
# File 'lib/ucode/config.rb', line 19 def auxiliary_files @auxiliary_files end |
#cache_root ⇒ Object
Returns the value of attribute cache_root.
19 20 21 |
# File 'lib/ucode/config.rb', line 19 def cache_root @cache_root end |
#charts_base_url ⇒ Object
Returns the value of attribute charts_base_url.
19 20 21 |
# File 'lib/ucode/config.rb', line 19 def charts_base_url @charts_base_url end |
#default_version ⇒ Object
Returns the value of attribute default_version.
19 20 21 |
# File 'lib/ucode/config.rb', line 19 def default_version @default_version end |
#extracted_files ⇒ Object
Returns the value of attribute extracted_files.
19 20 21 |
# File 'lib/ucode/config.rb', line 19 def extracted_files @extracted_files end |
#http_retries ⇒ Object
Returns the value of attribute http_retries.
19 20 21 |
# File 'lib/ucode/config.rb', line 19 def http_retries @http_retries end |
#http_timeout ⇒ Object
Returns the value of attribute http_timeout.
19 20 21 |
# File 'lib/ucode/config.rb', line 19 def http_timeout @http_timeout end |
#known_versions ⇒ Object
Returns the value of attribute known_versions.
19 20 21 |
# File 'lib/ucode/config.rb', line 19 def known_versions @known_versions end |
#listing_url ⇒ Object
Returns the value of attribute listing_url.
19 20 21 |
# File 'lib/ucode/config.rb', line 19 def listing_url @listing_url end |
#logger ⇒ Object
Logger shared by every subsystem (Fetch, Coordinator, Writer, …). Tests can swap to a StringIO logger to capture output.
45 46 47 |
# File 'lib/ucode/config.rb', line 45 def logger @logger end |
#output_dir ⇒ Object
Returns the value of attribute output_dir.
19 20 21 |
# File 'lib/ucode/config.rb', line 19 def output_dir @output_dir end |
#parallel_workers ⇒ Object
Returns the value of attribute parallel_workers.
19 20 21 |
# File 'lib/ucode/config.rb', line 19 def parallel_workers @parallel_workers end |
#pdf_renderer ⇒ Object
Returns the value of attribute pdf_renderer.
19 20 21 |
# File 'lib/ucode/config.rb', line 19 def pdf_renderer @pdf_renderer end |
#ucd_base_url ⇒ Object
Returns the value of attribute ucd_base_url.
19 20 21 |
# File 'lib/ucode/config.rb', line 19 def ucd_base_url @ucd_base_url end |
#unihan_base_url ⇒ Object
Returns the value of attribute unihan_base_url.
19 20 21 |
# File 'lib/ucode/config.rb', line 19 def unihan_base_url @unihan_base_url end |
Instance Method Details
#known?(version) ⇒ Boolean
51 52 53 |
# File 'lib/ucode/config.rb', line 51 def known?(version) known_versions.include?(version) end |