> I was just burned by this when tests/code started failing when god was > rolled out -- god redefines kilobytes, megabytes, and gigabytes in lib/ > sugar.rb. This is a problem for calculations involving diskspace for > us -- file_size > 1.megabyte behavior changes pretty significantly for > example :) > > So my question is what to do about it -- in my perfect world the tests > below would pass :) But god's not rails-specific so I totally get how > one library's sugar isn't really relevant to another library's sugar > -- in this case, Rails counts bytes and God counts kb for the same > methods and both make sense (personally I prefer god's base of kb, but > I digress)
You are correct about the differences. The reason for the discrepancy comes from god originally gathering all of the info from the output of "ps", which reports in kb. This made it natural to use that as the base number for the sugar. As to the question of how to deal with it in your code, there isn't really going to be a way that you can use that sugar across code that would be used for both. Your solution of specifically using a constant is the best I can come up with. In general, I don't believe many people are mixing their rails code with their god recipes. I haven't found any cases where I did. -- You received this message because you are subscribed to the Google Groups "god.rb" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/god-rb?hl=en.
