Sha256: 2dc4d15c5906aabb821da5401240ee5b371ea075a8d2e19c6af734f90bc91032

Contents?: true

Size: 1.45 KB

Versions: 1

Compression:

Stored size: 1.45 KB

Contents

module Bundler
  module Dependencies
    class CLI < ::Thor
      class Command < ::Thor
        RAILS_GEMS = %w(
          rails actioncable actionmailbox actionmailer actionpack actiontext actionview
          activejob activemodel activerecord activestorage activesupport railties
        ).freeze

        def initialize(options)
          @options = options
        end

        no_commands do
          def output
            to_s
          rescue Bundler::GemfileNotFound
            error("Could not locate Gemfile at #{SharedHelpers.pwd}.")
          end
        end

      private

        attr_reader :options

        def scanner
          @scanner ||= Scanner.new(path)
        end

        def graph
          @graph ||= scanner.graph
        end

        def path
          return options.path if valid_gemfile?(options.path)

          SharedHelpers.chdir(File.dirname(options.path)) if options.path
          SharedHelpers.default_lockfile
        end

        def valid_gemfile?(path)
          return false unless path && File.exist?(path)

          %w(Gemfile.lock gems.locked).include?(File.basename(path))
        end

        def without
          (options.without || []).tap do |gems|
            gems.concat(RAILS_GEMS) if options.without_rails?
          end
        end

        def warn(message)
          say(message, %i(bold yellow))
        end

        def error(message)
          say(message, %i(bold red))
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
bundler-dependencies-0.5.1 lib/bundler/dependencies/cli/command.rb