Sha256: 59be37fef0405d9d48f068e62c4e9117b6084a170707916bc26064dd37955c39

Contents?: true

Size: 1.3 KB

Versions: 1

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

module NeetoCompliance
  class BundlerVersionVerifier < Base
    def commons_bundler_version
      File.read(NeetoCompliance::NeetoCommons.path.join "common_files/.bundler-version").strip
    end

    def current_bundler_version
      `tail -n 1 ./Gemfile.lock`.strip
    end

    def is_same_version_being_used?
      commons_bundler_version == current_bundler_version
    end

    def valid?
      unless is_same_version_being_used?
        @error = %{
            Please update the bundler version on your machine to #{commons_bundler_version}
            You can follow the following steps:

            1. Install the latest bundler version:
              - gem install bundler
            2. Open Gemfile.lock of the project:
              - vim ./Gemfile.lock
            3. Delete the last line that contains the bundler version.
            4. Run:
              - bundle install

            You can also watch the following video that contains the same steps:
              - https://youtu.be/vqAUIQehbKw
          }
        return false
      end

      true
    end

    def autofix_suggestion
      @error.yellow
    end

    def autofix_command
      "gem install bundler; perl -p -i -e 's/#{current_bundler_version}(\n*)\\Z/#{commons_bundler_version}\n/m' Gemfile.lock"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
neeto-compliance-1.0.58 lib/neeto_compliance/verifiers/bundler_version_verifier.rb