class RJGit::Actor
Attributes
email[R]
name[R]
person_ident[R]
to_s[R]
Public Class Methods
from_string(str)
click to toggle source
Create an Actor
from a string.
str - The String in this format: ‘John Doe <jdoe@example.com>’
Returns Git::Actor.
# File lib/actor.rb, line 33 def self.from_string(str) if str =~ /<.+>/ m, name, email = *str.match(/(.*) <(.+?)>/) return self.new(name, email) end end
new(name, email, time = nil)
click to toggle source
# File lib/actor.rb, line 21 def initialize(name, email, time = nil) @name = name @email = email @time = time @person_ident = @time ? PersonIdent.new(name, email, time.to_java, TimeZone.getTimeZone(time.zone)) : PersonIdent.new(name, email) end
new_from_person_ident(person_ident)
click to toggle source
# File lib/actor.rb, line 15 def self.new_from_person_ident(person_ident) name = person_ident.get_name email = person_ident.get_email_address return self.new(name, email) end
Public Instance Methods
output(time = nil)
click to toggle source
Outputs an actor string for Git commits.
actor = Actor.new
(‘bob’, ‘bob@email.com’) actor.output(time) # => “bob <bob@email.com> UNIX_TIME +0700”
time - The Time the commit was authored or committed.
Returns a String.
# File lib/actor.rb, line 48 def output(time = nil) time = time || self.time offset = time.utc_offset / 60 "%s <%s> %d %+.2d%.2d" % [ @name, @email || "null", time.to_i, offset / 60, offset.abs % 60] end
time()
click to toggle source
# File lib/actor.rb, line 59 def time Time.at(@person_ident.getWhen.getTime/1000) end