From 067d2775dca7465c69ab583aff1320c100c5dee0 Mon Sep 17 00:00:00 2001 From: Lars Kanis Date: Mon, 5 Aug 2024 13:09:08 +0200 Subject: [PATCH] Remove conditions from gem declarations in Gemfile Both gems 'wdm' and 'rb-kqueue' can be installed on any platform. They fail when require 'wdm' or 'rb-kqueue' is called. So the conditions in the Gemfile can be removed and should not be recommended. Having conditions in the Gemfile is generally bad practice, since this leads to changed Gemfile.lock, whenever the bundler is executed on a different platform. Also "bundle package --all-platforms" doesn't work properly, when gems are declared conditionally. --- Gemfile | 10 ++-------- README.md | 8 ++------ lib/listen/adapter/bsd.rb | 5 +---- lib/listen/adapter/windows.rb | 2 +- 4 files changed, 6 insertions(+), 19 deletions(-) diff --git a/Gemfile b/Gemfile index ee8bfedb..fcca6e84 100644 --- a/Gemfile +++ b/Gemfile @@ -11,14 +11,8 @@ else gemspec development_group: :gem_build_tools end -require 'rbconfig' - -case RbConfig::CONFIG['target_os'] -when /mswin|mingw|cygwin/i - gem 'wdm', '>= 0.1.0' -when /bsd|dragonfly/i - gem 'rb-kqueue', '>= 0.2' -end +gem 'rb-kqueue', '>= 0.2' +gem 'wdm', '>= 0.1.0' group :test do gem 'coveralls' diff --git a/README.md b/README.md index cc59e02f..4d16e9f3 100644 --- a/README.md +++ b/README.md @@ -265,7 +265,7 @@ If you are on Windows, it's recommended to use the [`wdm`](https://github.com/Ma Please add the following to your Gemfile: ```ruby -gem 'wdm', '>= 0.1.0', platforms: [:mingw, :mswin, :x64_mingw, :jruby] +gem 'wdm', '>= 0.1.0' ``` ### On \*BSD @@ -275,11 +275,7 @@ If you are on \*BSD you can try to use the [`rb-kqueue`](https://github.com/mat8 Please add the following to your Gemfile: ```ruby -require 'rbconfig' -if RbConfig::CONFIG['target_os'] =~ /bsd|dragonfly/i - gem 'rb-kqueue', '>= 0.2' -end - +gem 'rb-kqueue', '>= 0.2' ``` ### Getting the [polling fallback message](#options)? diff --git a/lib/listen/adapter/bsd.rb b/lib/listen/adapter/bsd.rb index 84266232..186ded37 100644 --- a/lib/listen/adapter/bsd.rb +++ b/lib/listen/adapter/bsd.rb @@ -22,10 +22,7 @@ class BSD < Base BUNDLER_DECLARE_GEM = <<-EOS.gsub(/^ {6}/, '') Please add the following to your Gemfile to avoid polling for changes: - require 'rbconfig' - if RbConfig::CONFIG['target_os'] =~ /#{OS_REGEXP}/ - gem 'rb-kqueue', '>= 0.2' - end + gem 'rb-kqueue', '>= 0.2' EOS def self.usable? diff --git a/lib/listen/adapter/windows.rb b/lib/listen/adapter/windows.rb index 3b3a1854..799d4587 100644 --- a/lib/listen/adapter/windows.rb +++ b/lib/listen/adapter/windows.rb @@ -9,7 +9,7 @@ class Windows < Base BUNDLER_DECLARE_GEM = <<-EOS.gsub(/^ {6}/, '') Please add the following to your Gemfile to avoid polling for changes: - gem 'wdm', '>= 0.1.0' if Gem.win_platform? + gem 'wdm', '>= 0.1.0' EOS def self.usable?