Class: TripAdvisor::BuildInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/trip_advisor/build.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#authorObject

Returns the value of attribute author.



7
8
9
# File 'lib/trip_advisor/build.rb', line 7

def author
  @author
end

#branchObject

Returns the value of attribute branch.



7
8
9
# File 'lib/trip_advisor/build.rb', line 7

def branch
  @branch
end

#dateObject (readonly)

Returns the value of attribute date.



8
9
10
# File 'lib/trip_advisor/build.rb', line 8

def date
  @date
end

#sha1Object

Returns the value of attribute sha1.



7
8
9
# File 'lib/trip_advisor/build.rb', line 7

def sha1
  @sha1
end

#versionObject

Returns the value of attribute version.



7
8
9
# File 'lib/trip_advisor/build.rb', line 7

def version
  @version
end

Instance Method Details

#timestampObject



19
20
21
# File 'lib/trip_advisor/build.rb', line 19

def timestamp
  date.utc.strftime("%Y%m%d%H%M%S")
end

#to_hashObject



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.author
    info['date'] = self.date.utc.iso8601
  end
end