Module: Nextgen::Actions::Bundler
- Included in:
- Nextgen::Actions
- Defined in:
- lib/nextgen/actions/bundler.rb
Instance Method Summary collapse
- #binstubs(*gems) ⇒ Object (also: #binstub)
-
#bundle_command!(cmd, verbose: true, capture: false) ⇒ Object
Similar to from Rails::Generators::AppBase#bundle_command, but raises if the command fails.
- #bundler_ruby_file_supported? ⇒ Boolean
- #bundler_version_satisifed?(spec) ⇒ Boolean
- #install_gems(*names, version: nil, group: nil, require: nil) ⇒ Object (also: #install_gem)
- #noisy_bundler_version? ⇒ Boolean
- #remove_gem(name) ⇒ Object
Instance Method Details
#binstubs(*gems) ⇒ Object Also known as: binstub
5 6 7 |
# File 'lib/nextgen/actions/bundler.rb', line 5 def binstubs(*gems) bundle_command! "binstubs #{gems.join(" ")} --force" end |
#bundle_command!(cmd, verbose: true, capture: false) ⇒ Object
Similar to from Rails::Generators::AppBase#bundle_command, but raises if the command fails
43 44 45 46 47 48 49 50 51 |
# File 'lib/nextgen/actions/bundler.rb', line 43 def bundle_command!(cmd, verbose: true, capture: false) bundler = Gem.bin_path("bundler", "bundle") full_command = %("#{Gem.ruby}" "#{bundler}" #{cmd}) Bundler.with_original_env do say_status :bundle, cmd, :green if verbose run! full_command, env: {"BUNDLE_IGNORE_MESSAGES" => "1"}, verbose: false, capture: end end |
#bundler_ruby_file_supported? ⇒ Boolean
60 61 62 |
# File 'lib/nextgen/actions/bundler.rb', line 60 def bundler_ruby_file_supported? bundler_version_satisifed?(">= 2.4.20") end |
#bundler_version_satisifed?(spec) ⇒ Boolean
53 54 55 56 57 58 |
# File 'lib/nextgen/actions/bundler.rb', line 53 def bundler_version_satisifed?(spec) require "bundler" Gem::Requirement.new(spec).satisfied_by?(Gem::Version.new(Bundler::VERSION)) rescue LoadError false end |
#install_gems(*names, version: nil, group: nil, require: nil) ⇒ Object Also known as: install_gem
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/nextgen/actions/bundler.rb', line 10 def install_gems(*names, version: nil, group: nil, require: nil) gemfile = TidyGemfile.new inserted = names.filter do |name| if gemfile.include?(name) say_status :exist, name, :blue false else say_status :gemfile, [name, version].compact.join(", ") gemfile.add(name, version:, group:, require:) true end end return if inserted.empty? gemfile.save cmd = "install" cmd += " --quiet" if noisy_bundler_version? bundle_command! cmd end |
#noisy_bundler_version? ⇒ Boolean
64 65 66 |
# File 'lib/nextgen/actions/bundler.rb', line 64 def noisy_bundler_version? bundler_version_satisifed?("< 2.4.17") end |
#remove_gem(name) ⇒ Object
31 32 33 34 35 36 37 38 39 40 |
# File 'lib/nextgen/actions/bundler.rb', line 31 def remove_gem(name) gemfile = TidyGemfile.new return unless gemfile.include?(name) say_status :gemfile, "remove #{name}" gemfile.remove(name) gemfile.save bundle_command! "install", capture: true, verbose: false end |