Sha256: 7f662e8c82747ece3ca932c618913377b1143ad6e5e01834d0978b7cb9e0f374
Contents?: true
Size: 1.42 KB
Versions: 3
Compression:
Stored size: 1.42 KB
Contents
module LicenseFinder module Logger def self.new options={} klass = if options[:quiet] Quiet elsif options[:debug] Verbose else Progress end klass.new end class Base def active package_manager, is_active log package_manager, sprintf("%s active", (is_active ? "is" : "not")) end def package package_manager, package dependencies = package.children if dependencies.empty? log package_manager, sprintf("package '%s' has no dependencies", package.name) else log package_manager, sprintf("package '%s' has dependencies:", package.name) dependencies.each do |dep| log package_manager, sprintf("- %s", dep) end end end def license package, package_name, license, how log package, sprintf("package %s: found license '%s' %s", package_name, license, how) end def log prefix, string raise NotImplementedError, "#log must be implemented" end end class Quiet < Base def log prefix, string end end class Progress < Base def log prefix, string STDOUT.print(".") && STDOUT.flush end end class Verbose < Base def log prefix, string STDOUT.printf("%s: %s\n", prefix, string) end end Default = Quiet end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
license_finder-2.0.0.rc2 | lib/license_finder/logger.rb |
license_finder-1.2 | lib/license_finder/logger.rb |
license_finder-1.2-java | lib/license_finder/logger.rb |