class Autoproj::Stats::Sanitizer
Class passed to the stats generators to sanitize names and compute copyright
Attributes
aliases[R]
licenses[R]
simple_copyrights[R]
timeline_affiliations[R]
Public Class Methods
new(aliases: Hash.new)
click to toggle source
# File lib/autoproj/stats/sanitizer.rb, line 11 def initialize(aliases: Hash.new) @simple_copyrights = Hash.new @timeline_affiliations = Hash.new @aliases = aliases end
Public Instance Methods
compute_copyright_of(author_name, date)
click to toggle source
# File lib/autoproj/stats/sanitizer.rb, line 40 def compute_copyright_of(author_name, date) if affiliation = simple_copyrights[author_name] affiliation elsif timeline = timeline_affiliations[author_name] timeline.inject("Unknown (#{author_name})") do |aff, (new_aff, start_date)| if date < start_date return aff else new_aff end end else "Unknown (#{author_name})" end end
license_of(pkg)
click to toggle source
# File lib/autoproj/stats/sanitizer.rb, line 32 def license_of(pkg) licenses[pkg.name] end
load(path)
click to toggle source
# File lib/autoproj/stats/sanitizer.rb, line 17 def load(path) config = YAML.load(File.read(path)) @aliases = config['aliases'] @licenses = config['licenses'] || Hash.new if affiliations = config['affiliations'] affiliations.each do |name, entry| if entry.respond_to?(:to_str) simple_copyrights[name] = entry else timeline_affiliations[name] = entry.sort_by(&:last) end end end end