Managing loaner chromebooks for students and teachers in the HUUSD school district.
at main 40 lines 800 B view raw
1module Util 2 3 def self.unixtime(unixtime) 4 DateTime.strptime(unixtime.to_s, "%s") 5 end 6 7 # provided by https://github.com/jaspermayone/heroku-buildpack-sourceversion 8 def self.source_version 9 file = File.open(".source_version") 10 result = file.read.strip 11 file.close 12 13 result 14 rescue Errno::ENOENT 15 return nil 16 end 17 18 # also in ApplicationHelper for frontend use 19 def self.commit_hash 20 @commit_hash ||= begin 21 result = ENV["HEROKU_SLUG_COMMIT"] 22 result ||= source_version 23 result ||= `git show --pretty=%H -q`&.chomp 24 end 25 26 @commit_hash 27 end 28 29 def self.commit_dirty? 30 @commit_dirty ||= begin 31 `git diff --shortstat 2> /dev/null | tail -n1`&.chomp.present? 32 end 33 @commit_dirty 34 end 35 36 def self.current_year 37 Time.now.year 38 end 39 40end