From c31f30f24080a854572c77d862718243a715e093 Mon Sep 17 00:00:00 2001 From: SupeChicken666 Date: Fri, 20 Jun 2025 15:15:07 +0800 Subject: [PATCH] crew: Remove `activesupport` gem, implement `.blank?` logic in `lib/convenience_functions` (#12081) * crew: Remove `activesupport` gem Signed-off-by: SupeChicken666 * Remove activesupport require lines Signed-off-by: SupeChicken666 * Make rubocop happy Signed-off-by: SupeChicken666 * Add a comment for `.blank?` methods Signed-off-by: SupeChicken666 --------- Signed-off-by: SupeChicken666 --- bin/crew | 1 - lib/buildsystems/ruby.rb | 2 -- lib/convenience_functions.rb | 8 ++++++++ lib/downloader.rb | 1 - lib/fixup.rb | 1 - packages/core.rb | 1 - tools/core_packages.txt | 1 - tools/json.rb | 1 - tools/update_ruby_gem_packages.rb | 1 - 9 files changed, 8 insertions(+), 9 deletions(-) diff --git a/bin/crew b/bin/crew index 6c7ae9899..e6ae83aec 100755 --- a/bin/crew +++ b/bin/crew @@ -4,7 +4,6 @@ require_relative '../lib/color' # Disallow sudo. abort 'Chromebrew should not be run as root.'.lightred if Process.uid.zero? require_relative '../lib/require_gem' -require_gem('activesupport', 'active_support/core_ext/object/blank') require_gem('highline') # The json gem can break when upgrading from a much older version of ruby. require_gem('json') diff --git a/lib/buildsystems/ruby.rb b/lib/buildsystems/ruby.rb index 4aca17a06..a0395dc99 100644 --- a/lib/buildsystems/ruby.rb +++ b/lib/buildsystems/ruby.rb @@ -5,8 +5,6 @@ require_relative '../package_utils' require_relative '../report_buildsystem_methods' require_relative '../require_gem' -require_gem('activesupport', 'active_support/core_ext/object/blank') - def check_gem_binary_build_needed(ruby_gem_name = nil, ruby_gem_version = nil) puts "Checking to see if gem compile for #{ruby_gem_name} is needed..." @extract_dir = "#{ruby_gem_name}.#{Time.now.utc.strftime('%Y%m%d%H%M%S')}.dir" diff --git a/lib/convenience_functions.rb b/lib/convenience_functions.rb index 9e88bd2d1..c4ecac6f9 100644 --- a/lib/convenience_functions.rb +++ b/lib/convenience_functions.rb @@ -6,6 +6,14 @@ require_relative 'const' require_relative 'crewlog' require_relative 'downloader' +# Reimplementation of .blank? method from ActiveSupport +class NilClass; def blank? = true; end +class Numeric; def blank? = false; end +class Array; def blank? = empty?; end +class Hash; def blank? = empty?; end +class Symbol; def blank? = empty?; end +class String; def blank? = strip.empty?; end + class ConvenienceFunctions def self.determine_conflicts(pkg_name, filelist = File.join(CREW_META_PATH, "#{pkg_name}.filelist"), exclude_suffix = nil, verbose: false) conflicts = {} diff --git a/lib/downloader.rb b/lib/downloader.rb index 507b37236..a5b935593 100644 --- a/lib/downloader.rb +++ b/lib/downloader.rb @@ -6,7 +6,6 @@ require_relative 'color' require_relative 'progress_bar' require_relative 'require_gem' -require_gem('activesupport', 'active_support/core_ext/object/blank') require_gem('ptools') begin diff --git a/lib/fixup.rb b/lib/fixup.rb index 8accf403b..3eb2bd3f3 100644 --- a/lib/fixup.rb +++ b/lib/fixup.rb @@ -7,7 +7,6 @@ require_relative 'color' require_relative 'package' require_relative 'require_gem' -require_gem('activesupport', 'active_support/core_ext/object/blank') require_gem('highline') # All needed constants & variables should be defined here in case they diff --git a/packages/core.rb b/packages/core.rb index 43acba5f3..d1f90d3d4 100644 --- a/packages/core.rb +++ b/packages/core.rb @@ -89,7 +89,6 @@ class Core < Package depends_on 'readline' depends_on 'rtmpdump' depends_on 'ruby' - depends_on 'ruby_activesupport' depends_on 'ruby_concurrent_ruby' # Allows for building binary gems if necessary. depends_on 'ruby_gem_compiler' diff --git a/tools/core_packages.txt b/tools/core_packages.txt index a36aa19ac..c64250c1b 100644 --- a/tools/core_packages.txt +++ b/tools/core_packages.txt @@ -145,7 +145,6 @@ readline rtmpdump ruby ruby_abbrev -ruby_activesupport ruby_base64 ruby_benchmark ruby_bigdecimal diff --git a/tools/json.rb b/tools/json.rb index 90f139b0e..dc3ea0462 100644 --- a/tools/json.rb +++ b/tools/json.rb @@ -8,7 +8,6 @@ require_relative '../lib/package' require_relative '../lib/package_utils' require_relative '../lib/require_gem' -require_gem('activesupport', 'active_support/core_ext/object/blank') require_gem('ptools') output = [] diff --git a/tools/update_ruby_gem_packages.rb b/tools/update_ruby_gem_packages.rb index 3a8559ef8..85f6339f6 100755 --- a/tools/update_ruby_gem_packages.rb +++ b/tools/update_ruby_gem_packages.rb @@ -10,7 +10,6 @@ require_relative '../lib/color' require_relative '../lib/const' require_relative '../lib/gem_compact_index_client' require_relative '../lib/require_gem' -require_gem('activesupport', 'active_support/core_ext/object/blank') require_gem 'concurrent-ruby' def check_for_updated_ruby_packages