Sha256: 6bd61bafee77e555088a03d842938616eacabf819971f0dfdd08cc2ee895efd0

Contents?: true

Size: 1.33 KB

Versions: 7

Compression:

Stored size: 1.33 KB

Contents

# frozen_string_literal: true

module Jekyll
  module Utils
    module Platforms
      extend self

      def jruby?
        RUBY_ENGINE == "jruby"
      end

      def mri?
        RUBY_ENGINE == "ruby"
      end

      def windows?
        vanilla_windows? || bash_on_windows?
      end

      # Not a Windows Subsystem for Linux (WSL)
      def vanilla_windows?
        rbconfig_host.match?(%r!mswin|mingw|cygwin!) && proc_version.empty?
      end
      alias_method :really_windows?, :vanilla_windows?

      # Determine if Windows Subsystem for Linux (WSL)
      def bash_on_windows?
        linux_os? && microsoft_proc_version?
      end

      def linux?
        linux_os? && !microsoft_proc_version?
      end

      def osx?
        rbconfig_host.match?(%r!darwin|mac os!)
      end

      def unix?
        rbconfig_host.match?(%r!solaris|bsd!)
      end

      private

      def proc_version
        @proc_version ||= \
          begin
            File.read("/proc/version").downcase
          rescue Errno::ENOENT, Errno::EACCES
            ""
          end
      end

      def rbconfig_host
        @rbconfig_host ||= RbConfig::CONFIG["host_os"].downcase
      end

      def linux_os?
        rbconfig_host.include?("linux")
      end

      def microsoft_proc_version?
        proc_version.include?("microsoft")
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
jekyll-4.3.4 lib/jekyll/utils/platforms.rb
jekyll-4.3.3 lib/jekyll/utils/platforms.rb
jekyll-4.3.2 lib/jekyll/utils/platforms.rb
jekyll-4.3.1 lib/jekyll/utils/platforms.rb
jekyll-4.3.0 lib/jekyll/utils/platforms.rb
jekyll-4.2.2 lib/jekyll/utils/platforms.rb
jekyll-4.2.0 lib/jekyll/utils/platforms.rb