Class: PolishGeeks::DevTools::Commands::Gemfile

Inherits:
Base
  • Object
show all
Defined in:
lib/polish_geeks/dev_tools/commands/gemfile.rb

Overview

Checks if Gemfile contains local gems

Constant Summary collapse

CHECKED_REGEXP =

Regex which check if Gemfile has local gem ex:

gem 'example_gem', path: '/Users/Projects/gems/example_gem'
gem 'example_gem', :path => '/Users/Projects/gems/example_gem'
/^[^#]*((\bpath:)|(:path[ \t]*=>))/

Constants inherited from Base

Base::TYPES

Instance Attribute Summary

Attributes inherited from Base

#output, #stored_output

Instance Method Summary collapse

Methods inherited from Base

#ensure_executable!

Instance Method Details

#error_messageString

Returns message with local gems.

Returns:

  • (String)

    message with local gems



28
29
30
# File 'lib/polish_geeks/dev_tools/commands/gemfile.rb', line 28

def error_message
  "Gemfile contains gems from local path: \n#{output.join('')}"
end

#executeObject

Executes this command



15
16
17
18
19
20
# File 'lib/polish_geeks/dev_tools/commands/gemfile.rb', line 15

def execute
  @output = []
  gemfile = File.join(::PolishGeeks::DevTools.app_root, 'Gemfile')
  return unless File.exist?(gemfile)
  @output = IO.readlines(gemfile).select { |l| l.match(CHECKED_REGEXP) }
end

#labelString

Returns label with this validator description.

Returns:

  • (String)

    label with this validator description



23
24
25
# File 'lib/polish_geeks/dev_tools/commands/gemfile.rb', line 23

def label
  'Gemfile checking'
end

#valid?Boolean

Returns true if output doesn’t contain any local gems.

Returns:

  • (Boolean)

    true if output doesn’t contain any local gems



33
34
35
# File 'lib/polish_geeks/dev_tools/commands/gemfile.rb', line 33

def valid?
  @output.empty?
end