lib/gtfs_reader/source_updater.rb
def fetch_data_set_identifier
      if @source.url =~ /\A#{URI::DEFAULT_PARSER.make_regexp}\z/
        uri = URI(@source.url)
        Net::HTTP.start(uri.host) do |http|
          head_request = http.request_head(uri.path)
          if head_request.key?('etag')
            head_request['etag']
          else
            Log.warn("No ETag supplied with: #{uri.path}")
            fetch_http_fallback_identifier(head_request)
          end
        end
      else # it's not a url, it may be a file => last modified
        begin
          File.mtime(@source.url)
        rescue StandardError => e
          Log.error(e)
          raise e
        end
      end
    end
def fetch_data_set_identifier
      if @source.url =~ /\A#{URI::DEFAULT_PARSER.make_regexp}\z/
        uri = URI(@source.url)
        Net::HTTP.start(uri.host) do |http|
          head_request = http.request_head(uri.path)
          if head_request.key?('etag')
            head_request['etag']
          else
            Log.warn("No ETag supplied with: #{uri.path}")
            fetch_http_fallback_identifier(head_request)
          end
        end
      else # it's not a url, it may be a file => last modified
        begin
          File.mtime(@source.url)
        rescue StandardError => e
          Log.error(e)
          raise e
        end
      end
    end
Perform a HEAD request against the source's URL, looking for a unique
 identifier for the remote data set. It will choose a header from the
 result in the given order of preference:
 - ETag
 - Last-Modified
 - Content-Length (may result in different data sets being considered
   the same if they happen to have the same size)
 - The current date/time (this will always result in a fresh download)