Class: NeetoCompliance::BundlerVersionVerifier

Inherits:
Base
  • Object
show all
Defined in:
lib/neeto_compliance/verifiers/bundler_version_verifier.rb

Instance Method Summary collapse

Methods inherited from Base

#app_is_exception?, #app_name, #apps_exception_list, #audit, #auto_correct!, #error_message, #print_description, #process, #verifier_name

Instance Method Details

#autofix_commandObject



44
45
46
# File 'lib/neeto_compliance/verifiers/bundler_version_verifier.rb', line 44

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

#autofix_suggestionObject



40
41
42
# File 'lib/neeto_compliance/verifiers/bundler_version_verifier.rb', line 40

def autofix_suggestion
  @error.yellow
end

#commons_bundler_versionObject



5
6
7
# File 'lib/neeto_compliance/verifiers/bundler_version_verifier.rb', line 5

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

#current_bundler_versionObject



9
10
11
# File 'lib/neeto_compliance/verifiers/bundler_version_verifier.rb', line 9

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

#is_same_version_being_used?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/neeto_compliance/verifiers/bundler_version_verifier.rb', line 13

def is_same_version_being_used?
  commons_bundler_version == current_bundler_version
end

#valid?Boolean

Returns:

  • (Boolean)


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/neeto_compliance/verifiers/bundler_version_verifier.rb', line 17

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