lib/pdd.rb in pdd-0.20.6 vs lib/pdd.rb in pdd-0.20.7

- old
+ new

@@ -1,6 +1,6 @@ -# Copyright (c) 2014-2020 Yegor Bugayenko +# Copyright (c) 2014-2021 Yegor Bugayenko # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the 'Software'), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell @@ -28,11 +28,11 @@ require_relative 'pdd/rule/duplicates' require_relative 'pdd/rule/roles' # PDD main module. # Author:: Yegor Bugayenko (yegor256@gmail.com) -# Copyright:: Copyright (c) 2014-2020 Yegor Bugayenko +# Copyright:: Copyright (c) 2014-2021 Yegor Bugayenko # License:: MIT module PDD # If it breaks. class Error < StandardError end @@ -54,29 +54,33 @@ unless defined?(@logger) @logger = Logger.new(STDOUT) @logger.formatter = proc { |severity, _, _, msg| if severity == 'ERROR' "#{Rainbow(severity).red}: #{msg}\n" + elsif severity == 'WARN' + "#{Rainbow(severity).orange}: #{msg}\n" else "#{msg}\n" end } - @logger.level = Logger::ERROR + @logger.level = Logger::WARN end @logger end class << self attr_writer :logger + attr_accessor :opts end # Code base abstraction class Base # Ctor. # +opts+:: Options def initialize(opts) @opts = opts + PDD.opts = opts PDD.log.level = Logger::INFO if @opts[:verbose] PDD.log.level = Logger::ERROR if @opts[:quiet] PDD.log.info "My version is #{PDD::VERSION}" PDD.log.info "Ruby version is #{RUBY_VERSION} at #{RUBY_PLATFORM}" end @@ -85,9 +89,12 @@ def xml dir = @opts[:source] ? @opts[:source] : Dir.pwd PDD.log.info "Reading #{dir}" require_relative 'pdd/sources' sources = Sources.new(dir) + @opts[:include]&.each do |p| + sources = sources.include(p) + end @opts[:exclude]&.each do |p| sources = sources.exclude(p) PDD.log.info "Excluding #{p}" end sanitize(