From 245e7b12835013984a02406a44b2e9bce40dc2a8 Mon Sep 17 00:00:00 2001 From: Alexandre Podlewski Date: Wed, 23 Aug 2023 13:59:11 +0200 Subject: [PATCH] Fix linter error: "Method has too many lines." --- lib/ad_localize/option_handler.rb | 49 +++++++++++++++++++------------ 1 file changed, 30 insertions(+), 19 deletions(-) diff --git a/lib/ad_localize/option_handler.rb b/lib/ad_localize/option_handler.rb index 45d2989..37c9c6e 100644 --- a/lib/ad_localize/option_handler.rb +++ b/lib/ad_localize/option_handler.rb @@ -17,26 +17,10 @@ class OptionHandler def self.parse!(options) args = DEFAULT_OPTIONS - export_all_option = <<~DOC - Export all sheets from spreadsheet specified by --drive-key option. - \tBy default, generates one export directory per sheet (see -m|--merge-sheets option to merge them). - \tAn GCLOUD_CLIENT_SECRET environment variable containing the client_secret.json content is needed. - DOC - merge_policy_option = <<~DOC - Merge specified csv (or sheets from --export-all) instead of exporting each csv. - \treplace: if a key is already defined, replace its value. - \tkeep: if a key is already defined, keep the previous value. - DOC - platforms_option = <<~DOC - PLATFORMS is a comma separated list. - \tOnly generate localisation files for the specified platforms. - \tSupported platforms : #{Entities::Platform::SUPPORTED_PLATFORMS.to_sentence} - DOC - OptionParser.new do |parser| parser.banner = 'Usage: exe/ad_localize [options] file(s)' parser.on("-d", "--debug", TrueClass, 'Run in debug mode') - parser.on("-e", "--export-all-sheets", TrueClass, export_all_option) + export_all_option(parser) parser.on("-h", "--help", 'Prints help') do puts parser exit @@ -44,8 +28,8 @@ def self.parse!(options) parser.on("-k", "--drive-key SPREADSHEET_ID", String, 'Use google drive spreadsheets') parser.on("-l", "--locales LOCALES", Array, 'LOCALES is a comma separated list. Only generate localisation files for the specified locales') - parser.on("-m", "--merge-policy POLICY", Interactors::MergeWordings::MERGE_POLICIES, merge_policy_option) - parser.on("-o", "--only PLATFORMS", Array, platforms_option) + merge_policy_option(parser) + platforms_option(parser) parser.on("-s", "--sheets SHEET_IDS", Array, 'SHEET_IDS is a comma separated list. Use a specific sheet id for Google Drive spreadsheets with several sheets') parser.on("-t", "--target-dir PATH", String, 'Path to the target directory') @@ -60,5 +44,32 @@ def self.parse!(options) args[:csv_paths] = options return args end + + def self.export_all_option(parser) + export_all_option = <<~DOC + Export all sheets from spreadsheet specified by --drive-key option. + \tBy default, generates one export directory per sheet (see -m|--merge-sheets option to merge them). + \tAn GCLOUD_CLIENT_SECRET environment variable containing the client_secret.json content is needed. + DOC + parser.on("-e", "--export-all-sheets", TrueClass, export_all_option) + end + + def self.merge_policy_option(parser) + merge_policy_option = <<~DOC + Merge specified csv (or sheets from --export-all) instead of exporting each csv. + \treplace: if a key is already defined, replace its value. + \tkeep: if a key is already defined, keep the previous value. + DOC + parser.on("-m", "--merge-policy POLICY", Interactors::MergeWordings::MERGE_POLICIES, merge_policy_option) + end + + def self.platforms_option(parser) + platforms_option = <<~DOC + PLATFORMS is a comma separated list. + \tOnly generate localisation files for the specified platforms. + \tSupported platforms : #{Entities::Platform::SUPPORTED_PLATFORMS.to_sentence} + DOC + parser.on("-o", "--only PLATFORMS", Array, platforms_option) + end end end