Module: TaxonworksNet

Defined in:
lib/taxonworks_net.rb

Overview

net/http helpers

Class Method Summary (collapse)

Class Method Details

+ (String) commit_date

Returns the commit date of the current commit based on the Capistrano provided 'REVISION' as supplied by githubs API

Returns:

  • (String)

    the commit date of the current commit based on the Capistrano provided 'REVISION' as supplied by githubs API



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/taxonworks_net.rb', line 8

def self.commit_date
  revision = commit_sha
  if revision
    uri = URI("https://api.github.com/repos/SpeciesFileGroup/taxonworks/commits/#{revision}")
    begin
      response = Net::HTTP.get( uri )
      JSON.parse(response)['commit']['author']['date']
    rescue
      return 'UNKNOWN (failed to contact Github or response not parsable)'
    end
  else
    'UNKNOWN (no REVISION available)'
  end
end

+ (Object) commit_sha



23
24
25
26
27
28
29
30
# File 'lib/taxonworks_net.rb', line 23

def self.commit_sha
  file = Rails.root + 'REVISION'
  if File.exists?(file)
    File.read(file).strip
  else
    nil 
  end
end