Debian Codegraph @

lib/bundler/cli/platform.rb

raw
1 # frozen_string_literal: true
2
3 module Bundler
4 class CLI::Platform
5 attr_reader :options
6 def initialize(options)
7 @options = options
8 end
9
10 def run
11 ruby_version = if Bundler.locked_gems
12 Bundler.locked_gems.ruby_version&.gsub(/p\d+\Z/, "")
13 else
14 Bundler.definition.ruby_version&.single_version_string
15 end
16
17 output = []
18
19 if options[:ruby]
20 if ruby_version
21 output << ruby_version
22 else
23 output << "No ruby version specified"
24 end
25 else
26 platforms = Bundler.definition.platforms.map {|p| "* #{p}" }
27
28 output << "Your platform is: #{Gem::Platform.local}"
29 output << "Your app has gems that work on these platforms:\n#{platforms.join("\n")}"
30
31 if ruby_version
32 output << "Your Gemfile specifies a Ruby version requirement:\n* #{ruby_version}"
33
34 begin
35 Bundler.definition.validate_runtime!
36 output << "Your current platform satisfies the Ruby version requirement."
37 rescue RubyVersionMismatch => e
38 output << e.message
39 end
40 else
41 output << "Your Gemfile does not specify a Ruby version requirement."
42 end
43 end
44
45 Bundler.ui.info output.join("\n\n")
46 end
47 end
48 end