On Jan 15, 2009, at 9:39 AM, Paul Nasrat wrote:
>
> 2009/1/4 Luke Kanies <[email protected]>:
>>
>> I've made the IPMess stuff a lot less messy, and refactored
>> a lot of the util/ip module, including naming it more sensibly.
>>
>> The biggest changes are that I moved the big case statement into
>> a constant and then used a bit of dispatch-style logic to use it,
>> and I eliminated a bunch of duplicate code in the ipmess.rb file.
>>
>>
>> + # If it's not directly in the map or aliased in the map,
>> then we don't know how to deal with it.
>> + unless map = REGEX_MAP[kernel] or REGEX_MAP.values.find { |
>> tmp| tmp[:aliases] and tmp[:aliases].include?(kernel) }
>> + return []
>> end
>
> This doesn't do what you want as I just discovered adding darwin
> support as just an alias to :bsd and got a lovely traceback
>
>>> x = nil or 42
> => 42
>>> x.nil?
> => true
>
> I'd probably do
>
> map = REGEX_MAP[kernel]
> map ||= REGEX_MAP.values.find { |tmp| tmp[:aliases] and
> tmp[:aliases].include?(kernel) }
> return [] unless map
I've fixed this by using '||' instead of 'or'; I added some tests and
extra test data to verify the fix worked. I've also pushed it, since
this was the only comment on the code.
--
A citizen of America will cross the ocean to fight for democracy, but
won't cross the street to vote in a national election.
--Bill Vaughan
---------------------------------------------------------------------
Luke Kanies | http://reductivelabs.com | http://madstop.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Puppet Developers" 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/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---