Large anomalous Hall effect induced by gapped nodal lines in GdZn and GdCd