diff --git a/src/gen-config.cr b/src/gen-config.cr index 5cc597c..1b7a42d 100644 --- a/src/gen-config.cr +++ b/src/gen-config.cr @@ -7,6 +7,18 @@ def sanitize_path(path) path.gsub /\/\/+/, "/" end +class Service + def to_genconfig + Hash(String, String?).new.tap do |entry| + entry["name"] = name + entry["id"] = full_id + entry["environment"] = environment.name + entry["root"] = root + entry["domain"] = domain + end + end +end + module GenConfig # FIXME: The fuck has this become. alias Variables = @@ -96,14 +108,7 @@ class GenConfig::Context next unless provider - # FIXME: deduplicate - providers[token] = Hash(String, String?).new.tap do |entry| - entry["name"] = provider.name - entry["id"] = provider.full_id - entry["environment"] = provider.environment.name - entry["root"] = provider.root - entry["domain"] = provider.domain - end + providers[token] = provider.to_genconfig end options["providers"] = providers @@ -118,15 +123,7 @@ class GenConfig::Context t == token && service.is_id?(provider) end .size.>(0)) - .map do |consumer| - Hash(String, String?).new.tap do |entry| - entry["name"] = consumer.name - entry["id"] = consumer.id - entry["environment"] = consumer.environment.name - entry["root"] = consumer.root - entry["domain"] = consumer.domain - end - end + .map &.to_genconfig end options["consumers"] = consumers end