As to Ruth, the Torah passage that can be construed as denying David's right to be an Israelite is at Deuteronomy 23:3. Of course, that is not the only possible construction, but I think it is one that was fresh in the mind of the author of the Book of Ruth.
Haruo