class Giteaucrat::Author
Attributes
ignored[RW]
@return [Boolean]
Public Class Methods
all()
click to toggle source
# File lib/giteaucrat/author.rb, line 29 def self.all @all ||= Set.new end
check_multiple_emails!()
click to toggle source
# File lib/giteaucrat/author.rb, line 39 def self.check_multiple_emails! all.each do |_, author| author && author.check_multiple_emails! end end
find_by_git_person(grit_author)
click to toggle source
@param [Grit::Actor] grit_author @return [Author]
# File lib/giteaucrat/author.rb, line 18 def self.find_by_git_person(grit_author) name = grit_author.name.force_encoding('utf-8') email = grit_author.email.force_encoding('utf-8') author = all.find do |author| author.has_name?(name) || author.has_email?(email) end || new(name: name, email: email) author.names << name author.emails << email author end
new(attributes = {})
click to toggle source
Calls superclass method
Giteaucrat::Common::new
# File lib/giteaucrat/author.rb, line 33 def self.new(attributes = {}) author = super(attributes) all << author author end
to_yaml()
click to toggle source
# File lib/giteaucrat/author.rb, line 45 def self.to_yaml all.map(&:to_hash).sort { |a, b| a[:name] <=> b[:name] }.to_yaml end
Public Instance Methods
check_multiple_emails!()
click to toggle source
# File lib/giteaucrat/author.rb, line 57 def check_multiple_emails! if emails.count > 1 && !instance_variable_defined?(:@email) STDERR.puts "#{name} has multiple emails:\n#{emails.map { |e| "* #{e}" }.join("\n")}\nPlease set right one in your giteaucrat.yml\n" end end
email()
click to toggle source
@return [String]
# File lib/giteaucrat/author.rb, line 106 def email @email || emails.first end
email=(email)
click to toggle source
@param [String] email @return [String]
# File lib/giteaucrat/author.rb, line 112 def email=(email) email = email.force_encoding('utf-8') emails << email @email = email end
emails()
click to toggle source
@return [Set<String>]
# File lib/giteaucrat/author.rb, line 94 def emails @emails ||= Set.new end
emails=(emails)
click to toggle source
@param [<String>] emails @return [Set<String>]
# File lib/giteaucrat/author.rb, line 100 def emails=(emails) emails.each { |email| self.emails << email.force_encoding('utf-8') } self.emails end
has_email?(email)
click to toggle source
@return [Boolean] @param [String] email
# File lib/giteaucrat/author.rb, line 120 def has_email?(email) emails.include?(email.force_encoding('utf-8')) end
has_name?(name)
click to toggle source
@return [Boolean] @param [String] name
# File lib/giteaucrat/author.rb, line 89 def has_name?(name) names.include?(name.force_encoding('utf-8')) end
identifier()
click to toggle source
@return [String]
# File lib/giteaucrat/author.rb, line 125 def identifier %(#{name} <#{email}>).force_encoding('utf-8') end
ignored?()
click to toggle source
@return [Boolean]
# File lib/giteaucrat/author.rb, line 53 def ignored? !!@ignored end
name()
click to toggle source
@return [String]
# File lib/giteaucrat/author.rb, line 76 def name @name || names.first end
name=(name)
click to toggle source
@param [String] name
# File lib/giteaucrat/author.rb, line 81 def name=(name) name = name.force_encoding('utf-8') names << name @name = name end
names()
click to toggle source
@return [Set<String>]
# File lib/giteaucrat/author.rb, line 64 def names @names ||= Set.new end
names=(names)
click to toggle source
@param [<String>] names @return [Set<String>]
# File lib/giteaucrat/author.rb, line 70 def names=(names) names.each { |name| self.names << name.force_encoding('utf-8') } self.names end
to_hash()
click to toggle source
@return [Hash]
# File lib/giteaucrat/author.rb, line 130 def to_hash hash = { 'name' => name.to_s, 'email' => email.to_s } hash['names'] = names.to_a - [name] if names.size > 1 hash['emails'] = emails.to_a - [email] if emails.size > 1 hash['ignored'] = true if ignored? hash end
to_s()
click to toggle source
@return [String]
# File lib/giteaucrat/author.rb, line 139 def to_s identifier end