Sha256: c58838d24bb58510005612a1eabaac09dbfe7c2971e0f2e509440b7f83fe5497
Contents?: true
Size: 1.01 KB
Versions: 2
Compression:
Stored size: 1.01 KB
Contents
# typed: strict # frozen_string_literal: true module Bhook class Config extend T::Sig BHOOK_CONFIG_FILE = T.let('.bhook', String) WEBSITE_KEY = T.let('website', String) sig { params(root_dir_path: Pathname, additional_options: T::Hash[String, String]).void } def initialize(root_dir_path, additional_options = {}) config_file_path = root_dir_path.join(BHOOK_CONFIG_FILE) config = if File.exist?(config_file_path) YAML.load(File.read(config_file_path)) else {}.merge(additional_options) end @root_dir_path = root_dir_path @website_url = T.let(config[WEBSITE_KEY], T.nilable(String)) end sig { params(src_file_path: Pathname, src_file_sha: T.nilable(String)).returns(T.nilable(String)) } def website_url_for(src_file_path, src_file_sha) if @website_url && src_file_sha relative_file_path = src_file_path.relative_path_from(@root_dir_path) File.join(@website_url, src_file_sha, relative_file_path) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bhook-0.1.6 | lib/bhook/config.rb |
bhook-0.1.5 | lib/bhook/config.rb |