class Danger::DangerLockLibraryVersions

Public Instance Methods

check(config = nil) click to toggle source
# File lib/lock_library_versions/plugin.rb, line 3
def check(config = nil)
  config = config.is_a?(Hash) ? config : { }
  warning_mode = config[:warning] || false
  files = git.modified_files
  lock_list.keys.each do |file|
    if files.include?(file.to_s) && !(files.include?(lock_list[file]))
      comment(warning_mode, file)
    end
  end
end

Private Instance Methods

comment(warning_mode, file) click to toggle source
# File lib/lock_library_versions/plugin.rb, line 16
def comment(warning_mode, file)
  if warning_mode
    warn(error_message(file))
  else
    fail(error_message(file))
  end
end
error_message(file) click to toggle source
# File lib/lock_library_versions/plugin.rb, line 24
def error_message(file)
  "`#{file.to_s}` has changed. `#{lock_list[file]}` should be committed."
end
lock_list() click to toggle source
# File lib/lock_library_versions/plugin.rb, line 28
def lock_list
  {
    'Gemfile': 'Gemfile.lock',
    'Cartfile': 'Cartfile.resolved',
    'Podfile': 'Podfile.lock'
  }
end