Sha256: e9cdd9e712b723f1a463d65d591ca7337886a6ec1e9c603488e52300f5fa53f2

Contents?: true

Size: 870 Bytes

Versions: 1

Compression:

Stored size: 870 Bytes

Contents

require 'yaml'

module Danger
  class DangerLockDependencyVersions < Plugin
    attr_accessor :lock_list_file

    def lock_list_file
      @lock_list_file || '.lock_list.yml'
    end


    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) && !(files.include?(lock_list[file]))
          comment(warning_mode, file)
        end
      end
    end

    private

    def comment(warning_mode, file)
      if warning_mode
        warn(error_message(file))
      else
        fail(error_message(file))
      end
    end

    def error_message(file)
      "`#{file}` has changed. `#{lock_list[file]}` should be committed."
    end

    def lock_list
      YAML.load_file(lock_list_file)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
danger-lock_dependency_versions-0.0.3 lib/lock_dependency_versions/plugin.rb