To measure a gap you put the ring in its cylinder, then push it down with the piston so it's square to the bore. If it's so long that there's no gap and it won't fit, remove material from the ends until it just fits. If it does fit in, measure the end gap with feeler gauges.
The right way to do "filing" is with a ring end grinding tool, a manual one is around $100.00. Don't try to do it on a bench grinder!!! The usual "shade tree mechanic" method is to use a thin double sided dead smooth file and take it slow and easy. Set the ring on a flat surface with the gap hanging off the side. File both ends simultaneously with the file moving up and down in the gap. Keep the file straight up and radial to the ring. Take a very few strokes and measure the amount the gap changed to get an idea of how fast it's cutting before you go too far. It's easy to file open the gap, impossible to close it.
So you measure, remove some material, measure again... repeat until you have the spec gap for your bore size.
You should push the ring down a couple of inches to get out of the high wear area of the cylinder where it might be slightly oversize. The end gap is to avoid seizing so you want it set at the smallest cylinder diameter. Freshly bored cylinders should be the same size all the way, I set the end gaps slightly tight on these to allow for the ring seating and cylinder honing smoothing during break-in..