Sha256: 7801abd60a0f43480f672fb4fab463dcbea6ff0a785397f305a69130bed31df0

Contents?: true

Size: 1.03 KB

Versions: 16

Compression:

Stored size: 1.03 KB

Contents

# frozen_string_literal: true

module Bridgetown
  module Utils
    module RequireGems
      class << self
        #
        # Require a gem or gems. If it's not present, show a very nice error
        # message that explains everything and is much more helpful than the
        # normal LoadError.
        #
        # names - a string gem name or array of gem names
        #
        def require_with_graceful_fail(names)
          Array(names).each do |name|
            Bridgetown.logger.debug "Requiring:", name.to_s
            require name.to_s
          rescue LoadError => _e
            Bridgetown.logger.error(
              "Dependency Error:",
              "Hmm, it looks like you don't have `#{name}' or one of its dependencies " \
              "installed. Please double-check you've added it to your Gemfile."
            )
            Bridgetown.logger.error(
              "", "You can also find help at https://www.bridgetownrb.com/community"
            )
            exit(1)
          end
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
bridgetown-core-2.0.0.beta2 lib/bridgetown-core/utils/require_gems.rb
bridgetown-core-2.0.0.beta1 lib/bridgetown-core/utils/require_gems.rb
bridgetown-core-1.3.4 lib/bridgetown-core/utils/require_gems.rb
bridgetown-core-1.3.3 lib/bridgetown-core/utils/require_gems.rb
bridgetown-core-1.3.2 lib/bridgetown-core/utils/require_gems.rb
bridgetown-core-1.3.1 lib/bridgetown-core/utils/require_gems.rb
bridgetown-core-1.3.0 lib/bridgetown-core/utils/require_gems.rb
bridgetown-core-1.3.0.beta3 lib/bridgetown-core/utils/require_gems.rb
bridgetown-core-1.3.0.beta2 lib/bridgetown-core/utils/require_gems.rb
bridgetown-core-1.3.0.beta1 lib/bridgetown-core/utils/require_gems.rb
bridgetown-core-1.2.0 lib/bridgetown-core/utils/require_gems.rb
bridgetown-core-1.2.0.beta5 lib/bridgetown-core/utils/require_gems.rb
bridgetown-core-1.2.0.beta4 lib/bridgetown-core/utils/require_gems.rb
bridgetown-core-1.2.0.beta3 lib/bridgetown-core/utils/require_gems.rb
bridgetown-core-1.2.0.beta2 lib/bridgetown-core/utils/require_gems.rb
bridgetown-core-1.2.0.beta1 lib/bridgetown-core/utils/require_gems.rb