Sha256: 32d3a23b67cca43677d084e999f1c98047399188850c896a3f08aa3934cd9538

Contents?: true

Size: 1.41 KB

Versions: 2

Compression:

Stored size: 1.41 KB

Contents

# frozen_string_literal: true

require 'rails'

module SaferRailsConsole
  module RailsVersion
    RAILS_VERSION = Gem::Version.new(::Rails.version)

    class << self
      def supported?
        five_zero? || five_one? || five_two? || six_or_above?
      end

      def five_zero?
        @is_five_zero = Gem::Requirement.new('~> 5.0.0').satisfied_by?(SaferRailsConsole::RailsVersion::RAILS_VERSION) if @is_five_zero.nil?
        @is_five_zero
      end

      def five_one?
        @is_five_one = Gem::Requirement.new('~> 5.1.0').satisfied_by?(SaferRailsConsole::RailsVersion::RAILS_VERSION) if @is_five_one.nil?
        @is_five_one
      end

      def five_one_or_above?
        @is_five_one_or_above = SaferRailsConsole::RailsVersion::RAILS_VERSION >= ::Gem::Version.new('5.1.0') if @is_five_one_or_above.nil?
        @is_five_one_or_above
      end

      def five_two?
        @is_five_two = Gem::Requirement.new('~> 5.2.0').satisfied_by?(SaferRailsConsole::RailsVersion::RAILS_VERSION) if @is_five_two.nil?
        @is_five_two
      end

      def six_zero?
        @is_six_zero = Gem::Requirement.new('~> 6.0.0').satisfied_by?(SaferRailsConsole::RailsVersion::RAILS_VERSION) if @is_six_zero.nil?
        @is_six_zero
      end

      def six_or_above?
        @is_six_or_above = SaferRailsConsole::RailsVersion::RAILS_VERSION >= ::Gem::Version.new('6.0.0') if @is_six_or_above.nil?
        @is_six_or_above
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
safer_rails_console-0.5.1 lib/safer_rails_console/rails_version.rb
safer_rails_console-0.5.0 lib/safer_rails_console/rails_version.rb