Orphan is pretty much spot on. Rarity does indeed not matter when it comes to shrine selection, shrine spawn chances are hardcoded. You are also correct on the method which the game uses to select a shrine, that is it first seelects an effectlass then randomly selects a shrine with the chosen class. Although you use th term shrine type, which I guess you take from the first column in shrines.txt, but the game doesn't actually use that (but it is ofcourse a description of the shrine type, for reference only). There are 4 shrine classes (not counting the '0' class):
1 = Magic type shrines
Shrine of Enirhs (not used)
Portal Shrine
Gem Upgrade
Fire Shrine (listed as Storm shrine in shrines.txt)
Warping Shrine
Exploding Shrine
Poison Shrine
2 = Recharge type shrines
Health Boost
Health Exchange (not used)
3 = Recharge type shrines
Mana Boost
Mana Exchange (not used)
4 = Boost type shrines
Refill (shrine type = recharge, irrelevant)
Armor Boost
Combat Boost
Resist Fire Boost
Resist Cold Boost
Resist Lightning Boost
Resist Poison Boost
Skill Boost
Recharge Boost
Stamina Boost
Experience Boost
Note that some names might differ a bit from actual in game names. The check for unused shrines is hardcoded to their id and is performed after a shrine is chosen. If an unused shrine is selected, the game will make the following changes:
Mana Exchange (id = 5) will be replaced with Mana boost (id = 3)
Health Exchange (id = 4) will be replaced with Health boost (id = 2)
Shrine of Enirhs (id = 16) will be replaced with Gem Upgrade (id = 18)
I'm not entirely sure how exactly specific objects are placed on the map, be it through the map files themselves (.ds1 or something similar), levels.txt or other ways, but this will obviously be the first step in shrine spawning - the game deciding that it should actually spawn a shrine (a shrine is considered an object). Perhaps someone more knowledgeable on the subject can shed some light on this process. Anyway. Once the game decides to spawn a shrine, it will check the 'Parm0' column in objects.txt to see which effectclass to choose:
0: some specific process, I have not checked how this is done (I think it simply selects a random shrine, with no regards to effectlass). Currently, no shrines have parm0 value of 0.
1: effectclass = 2
2: effectclass = 3
3: 10% chance of class = 1, 90% chance of 4.
Majority of shrine objects have a parm0 value of 3, or 34. The rest, 26, are split evenly between 1 and 2.
Now, what actually prevents a shrine from spawning is the level id of the current area. This has no relation to the area level or difficulty. The level id needs to be equal or greater than 'LevelMin' from shrines.txt for the shrien to spawn. The following shrines have a LevelMin greater than 1:
Health Exchange: 2
Mana Exchange: 2
Portal to unknown: 3
Warping Shrine: 3
Gem Upgrade: 4
Armor Boost: 5
Resist Fire Boost: 5
Combat Boost: 8
Resist Poison Boost: 21
Resist Cold Boost: 26
Resist Lightning Boost: 32
For reference, the level Id rises as the game progresses, with the Rogue Encapment having Id = 1 and Baals Throne room id = 131 (Outer cloister has id of 32). Again, difficulty has no relation to the level Id so the Blood Moor always has Id = 2, in normal/nightmare/hell). So a Gem Shrine should not be able to spawn until The Stony Field (id = 4) in ANY difficulty.. a rather strange design I must say. However, as Orphan pointed out, if the game fails to find a shrine that meets the Id vs. Levelmin criteria EIGHT times, it will select the last shrine it checked anyway (similar to the staffmod selecetion as noted by Orphan).
I'm not sure if I managed to cover everything, but this along with Orpans post (and others in this thread) should provide some detail into shrine spawning.