From 7073aa78c5ffe8b7292ad8ae4c93b504ec234d09 Mon Sep 17 00:00:00 2001 From: markuszilch Date: Tue, 16 Jan 2024 14:59:57 +0100 Subject: [PATCH 1/3] add table formatting --- bin/outdated_modules_and_their_version | 28 +++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git a/bin/outdated_modules_and_their_version b/bin/outdated_modules_and_their_version index 41a529c0..1f6a0993 100755 --- a/bin/outdated_modules_and_their_version +++ b/bin/outdated_modules_and_their_version @@ -6,12 +6,30 @@ require 'erb' # the current version in modulesync_config version = YAML.load(ERB.new(File.read('moduleroot/.msync.yml.erb')).result)['modulesync_config_version'] -puts "current version: #{version}" -puts '---------------------------------------------' -puts "| Module\t| modulesync_config version |" -puts '---------------------------------------------' +mod_ary = Array.new +# min width is with of Sting "Module" +width_modules = 6 +# min width is width of String "modulesync_config version" +width_version = 25 Dir.glob('modules/voxpupuli/puppet-*/.msync.yml').each do|f| version_module = YAML.load_file(f)['modulesync_config_version'] mod = f.split('/')[2] - puts "| #{mod}\t| #{version_module}\t|" if version != version_module + if version != version_module + mod_ary.push([mod,version_module]) + width_modules = [width_modules,mod.length].max + width_version = [width_version,version_module.length].max + end +end + +total_width = width_modules + width_version + 7 + +puts '-' * total_width +puts "current version: #{version}" +puts '-' * total_width +puts '| Module' + ' '* (width_modules - 6) + ' | modulesync_config version' + ' '*(width_version-25) + ' |' +puts '-' * total_width +mod_ary.each do |m| + mod = m[0] + version_module = m[1] + puts "| #{mod}" + ' '*(width_modules-mod.length) +" | #{version_module}" + ' '*(width_version-version_module.length) +' |' end From e43f57a0ac1e98ddfefd25907df93fa82fd2aa7b Mon Sep 17 00:00:00 2001 From: markuszilch Date: Tue, 16 Jan 2024 16:00:36 +0100 Subject: [PATCH 2/3] fix suggested changes, ljust and rubystyles --- bin/outdated_modules_and_their_version | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/bin/outdated_modules_and_their_version b/bin/outdated_modules_and_their_version index 1f6a0993..e2fde0c0 100755 --- a/bin/outdated_modules_and_their_version +++ b/bin/outdated_modules_and_their_version @@ -6,8 +6,8 @@ require 'erb' # the current version in modulesync_config version = YAML.load(ERB.new(File.read('moduleroot/.msync.yml.erb')).result)['modulesync_config_version'] -mod_ary = Array.new -# min width is with of Sting "Module" +mod_ary = [] +# min width is with of String "Module" width_modules = 6 # min width is width of String "modulesync_config version" width_version = 25 @@ -16,8 +16,8 @@ Dir.glob('modules/voxpupuli/puppet-*/.msync.yml').each do|f| mod = f.split('/')[2] if version != version_module mod_ary.push([mod,version_module]) - width_modules = [width_modules,mod.length].max - width_version = [width_version,version_module.length].max + width_modules = [width_modules, mod.length].max + width_version = [width_version, version_module.length].max end end @@ -26,10 +26,7 @@ total_width = width_modules + width_version + 7 puts '-' * total_width puts "current version: #{version}" puts '-' * total_width -puts '| Module' + ' '* (width_modules - 6) + ' | modulesync_config version' + ' '*(width_version-25) + ' |' -puts '-' * total_width -mod_ary.each do |m| - mod = m[0] - version_module = m[1] - puts "| #{mod}" + ' '*(width_modules-mod.length) +" | #{version_module}" + ' '*(width_version-version_module.length) +' |' +puts "| #{'Module'.ljust(width_modules)} | #{'modulesync_config version'.ljust(width_version)} |" +mod_ary.each do |mod, version_module| + puts "| #{mod.ljust(width_modules)} | #{version_module.ljust(width_version)} |" end From 23f6ec8d0c1efb005d2498e0e4ca1c63a6eaa3b9 Mon Sep 17 00:00:00 2001 From: markuszilch Date: Tue, 16 Jan 2024 16:20:29 +0100 Subject: [PATCH 3/3] type and style fix --- bin/outdated_modules_and_their_version | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/outdated_modules_and_their_version b/bin/outdated_modules_and_their_version index e2fde0c0..55b6ecd1 100755 --- a/bin/outdated_modules_and_their_version +++ b/bin/outdated_modules_and_their_version @@ -7,7 +7,7 @@ require 'erb' version = YAML.load(ERB.new(File.read('moduleroot/.msync.yml.erb')).result)['modulesync_config_version'] mod_ary = [] -# min width is with of String "Module" +# min width is width of String "Module" width_modules = 6 # min width is width of String "modulesync_config version" width_version = 25 @@ -15,7 +15,7 @@ Dir.glob('modules/voxpupuli/puppet-*/.msync.yml').each do|f| version_module = YAML.load_file(f)['modulesync_config_version'] mod = f.split('/')[2] if version != version_module - mod_ary.push([mod,version_module]) + mod_ary.push([mod, version_module]) width_modules = [width_modules, mod.length].max width_version = [width_version, version_module.length].max end