Class: GitStore::User
- Inherits:
-
Struct
- Object
- Struct
- GitStore::User
- Defined in:
- lib/git_store/user.rb
Instance Attribute Summary collapse
-
#email ⇒ Object
Returns the value of attribute email.
-
#name ⇒ Object
Returns the value of attribute name.
-
#time ⇒ Object
Returns the value of attribute time.
Class Method Summary collapse
Instance Method Summary collapse
- #dump ⇒ Object (also: #to_s)
- #inspect ⇒ Object
Instance Attribute Details
#email ⇒ Object
Returns the value of attribute email
2 3 4 |
# File 'lib/git_store/user.rb', line 2 def email @email end |
#name ⇒ Object
Returns the value of attribute name
2 3 4 |
# File 'lib/git_store/user.rb', line 2 def name @name end |
#time ⇒ Object
Returns the value of attribute time
2 3 4 |
# File 'lib/git_store/user.rb', line 2 def time @time end |
Class Method Details
.config_get(key) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/git_store/user.rb', line 17 def self.config_get(key) value = `git config #{key}`.chomp if $?.exitstatus == 0 return value unless value.empty? raise RuntimError, "#{key} is empty" else raise RuntimError, "No #{key} found in git config" end end |
.config_user_email ⇒ Object
28 29 30 |
# File 'lib/git_store/user.rb', line 28 def self.config_user_email email = `git config user.email`.chomp end |
.from_config ⇒ Object
12 13 14 15 |
# File 'lib/git_store/user.rb', line 12 def self.from_config name, email = config_get('user.name'), config_get('user.email') new name, email, Time.now end |
.parse(user) ⇒ Object
32 33 34 35 36 |
# File 'lib/git_store/user.rb', line 32 def self.parse(user) if match = user.match(/(.*)<(.*)> (\d+) ([+-]\d+)/) new match[1].strip, match[2].strip, Time.at(match[3].to_i + match[4].to_i * 3600) end end |
Instance Method Details
#dump ⇒ Object Also known as: to_s
3 4 5 |
# File 'lib/git_store/user.rb', line 3 def dump "#{ name } <#{email}> #{ time.to_i } #{ time.strftime('%z') }" end |
#inspect ⇒ Object
8 9 10 |
# File 'lib/git_store/user.rb', line 8 def inspect "#<GitStore::User name=%p email=%p time=%p>" % [name, email, time] end |