I fully agree - the main reason I've done this conversion is because I want to show nice graphs in foreman :) and that was not an option to change everyones facter.
Ohad On Wed, Mar 10, 2010 at 11:41 PM, Michael DeHaan <mich...@reductivelabs.com>wrote: > On Wed, Mar 10, 2010 at 1:24 AM, Ohad Levy <ohadl...@gmail.com> wrote: > > another option that I use is to extend the string class in ruby, that > would > > allow you to do something like: > > Facter.memorysize.to_gb > > in order to do that add somewhere (e.g. before your custom fact) > > class String > > def to_gb > > begin > > value,unit=self.match(/(\d+|.+) ([KMG]B)$/i)[1..2] > > case unit.to_sym > > when nil, :B, :byte then (value.to_f / 1000_000_000) > > when :GB, :G, :gigabyte then value.to_f > > when :MB, :M, :megabyte then (value.to_f / 1000) > > when :KB, :K, :kilobyte, :kB then (value.to_f / 1000_000) > > else raise "Unknown unit: #{unit.inspect}!" > > end > > rescue > > raise "Unknown string" > > end > > end > > end > > Ohad > > I'd rather look into fixing the problem than doing code monkeypatching > in everyday environments and require folks to write facts to get this > data. > > Let's look at making things like this available today in facter. > Patch material? > > I generally think facts shouldn't include units anyway, yet we don't > want to break existing things that depend on them. > > --Michael > > -- > You received this message because you are subscribed to the Google Groups > "Puppet Users" group. > To post to this group, send email to puppet-us...@googlegroups.com. > To unsubscribe from this group, send email to > puppet-users+unsubscr...@googlegroups.com<puppet-users%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/puppet-users?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-us...@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.