From bec0f33b273c841ea4b92da93fe627f3bf4618f6 Mon Sep 17 00:00:00 2001 From: Richard Michael Date: Fri, 30 Apr 2021 12:52:15 +0200 Subject: [PATCH] Add and use a singular finder, `find_doc()` --- lib/tasks/docs.thor | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lib/tasks/docs.thor b/lib/tasks/docs.thor index 0ecd7bdb..786d9ef6 100644 --- a/lib/tasks/docs.thor +++ b/lib/tasks/docs.thor @@ -267,17 +267,19 @@ class DocsCLI < Thor private - def find_docs(names) - names.flat_map do |name| - name, version = name.split(/@|~/) - if version == 'all' - Docs.find(name, false).versions - else - Docs.find(name, version) - end + def find_doc(name) + name, version = name.split(/@|~/) + if version == 'all' + Docs.find(name, false).versions + else + Docs.find(name, version) end end + def find_docs(names) + names.flat_map {|name| find_doc(name)} + end + def find_docs_by_slugs(slugs) slugs.flat_map do |slug| slug, version = slug.split(/~/)