Class: TripAdvisor::BuildInfo
- Inherits:
-
Object
- Object
- TripAdvisor::BuildInfo
- Defined in:
- lib/trip_advisor/build.rb
Instance Attribute Summary collapse
-
#author ⇒ Object
Returns the value of attribute author.
-
#branch ⇒ Object
Returns the value of attribute branch.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#sha1 ⇒ Object
Returns the value of attribute sha1.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
-
#initialize(repo) ⇒ BuildInfo
constructor
A new instance of BuildInfo.
- #timestamp ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(repo) ⇒ BuildInfo
Returns a new instance of BuildInfo.
10 11 12 13 14 15 16 17 |
# File 'lib/trip_advisor/build.rb', line 10 def initialize(repo) @date = Time.now @branch = repo.branches.detect { |b| b.canonical_name == repo.head.name }.name name = repo.config['user.name'] email = repo.config['user.email'] @author = "#{name} <#{email}>" @sha1 = repo.head.target end |
Instance Attribute Details
#author ⇒ Object
Returns the value of attribute author.
7 8 9 |
# File 'lib/trip_advisor/build.rb', line 7 def @author end |
#branch ⇒ Object
Returns the value of attribute branch.
7 8 9 |
# File 'lib/trip_advisor/build.rb', line 7 def branch @branch end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
8 9 10 |
# File 'lib/trip_advisor/build.rb', line 8 def date @date end |
#sha1 ⇒ Object
Returns the value of attribute sha1.
7 8 9 |
# File 'lib/trip_advisor/build.rb', line 7 def sha1 @sha1 end |
#version ⇒ Object
Returns the value of attribute version.
7 8 9 |
# File 'lib/trip_advisor/build.rb', line 7 def version @version end |
Instance Method Details
#timestamp ⇒ Object
19 20 21 |
# File 'lib/trip_advisor/build.rb', line 19 def date.utc.strftime("%Y%m%d%H%M%S") end |
#to_hash ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/trip_advisor/build.rb', line 23 def to_hash Hash.new.tap do |info| info['version'] = self.version info['branch'] = self.branch info['sha1'] = self.sha1 info['author'] = self. info['date'] = self.date.utc.iso8601 end end |