Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion lib/packs/specification/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ class Configuration < T::Struct
'packs/*',
'packs/*/*'
], T::Array[String])
DEFAULT_README_TEMPLATE_PATHNAME = T.let(Pathname.new('README_TEMPLATE.md'), Pathname)

prop :pack_paths, T::Array[String]
prop :readme_template_pathname, Pathname

sig { returns(Configuration) }
def self.fetch
config_hash = CONFIGURATION_PATHNAME.exist? ? YAML.load_file(CONFIGURATION_PATHNAME) : {}

new(
pack_paths: pack_paths(config_hash)
pack_paths: pack_paths(config_hash),
readme_template_pathname: readme_template_pathname(config_hash)
)
end

Expand All @@ -31,6 +34,16 @@ def self.pack_paths(config_hash)
Array(specified_pack_paths)
end
end

sig { params(config_hash: T::Hash[T.untyped, T.untyped]).returns(Pathname) }
def self.readme_template_pathname(config_hash)
specified_readme_template_path = config_hash['readme_template_path']
if specified_readme_template_path.nil?
DEFAULT_README_TEMPLATE_PATHNAME
else
Pathname.new(specified_readme_template_path)
end
end
end
end
end
Loading