Attraction and repulsion of spiral waves by localized inhomogeneities in excitable media