Module: TaxonworksNet

Defined in:
lib/taxonworks_net.rb

Overview

net/http helpers

Class Method Summary collapse

Class Method Details

.commit_dateString

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

.commit_shaObject



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.exist?(file)
    File.read(file).strip
  else
    nil
  end
end