Skip to content

Commit

Permalink
Use ruby file: Gemfile syntax if Bundler supports it (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattbrictson committed Apr 10, 2024
1 parent f5b6c74 commit 10b788f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/nextgen/actions/bundler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ def bundler_version_satisifed?(spec)
false
end

def bundler_ruby_file_supported?
bundler_version_satisifed?(">= 2.4.20")
end

def noisy_bundler_version?
bundler_version_satisifed?("< 2.4.17")
end
Expand Down
6 changes: 5 additions & 1 deletion lib/nextgen/generators/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@

if File.exist?(".ruby-version") && File.read(".ruby-version").match?(/\A\d+\.\d+.\d+.\s*\z/m)
say_git "DRY up Gemfile and .ruby-version file"
replacement = 'ruby Pathname.new(__dir__).join(".ruby-version").read.strip'
replacement = if bundler_ruby_file_supported?
'ruby file: ".ruby-version"'
else
'ruby Pathname.new(__dir__).join(".ruby-version").read.strip'
end
gsub_file "Gemfile", /^ruby "\d.*"$/, replacement
end

Expand Down

0 comments on commit 10b788f

Please sign in to comment.