Yea, you're probably right. FWIW, here's the offending block of code
in lib/puppet/interface/option_builder.rb:19:
Puppet::Interface::Option.instance_methods.grep(/=$/).each do |
setter|
next if setter =~ /^=/
dsl = setter.sub(/=$/, '')
unless private_instance_methods.include? dsl
define_method(dsl) do |value| @option.send(setter, value) end
end
end
So basically we're just defining reader methods for all writers that
don't have them on the Puppet::Interface::Option class. Maybe
something like the following would be better?
Puppet::Interface::Option.instance_methods.grep(/=$/).each do |
setter|
next if setter =~ /^=/
dsl = setter.to_s.sub(/=$/, '')
unless private_instance_methods.include? dsl.to_sym
define_method(dsl) do |value| @option.send(setter, value) end
end
end
On May 10, 10:35 am, Daniel Pittman <[email protected]> wrote:
> I am torn: I like the idea of getting my embarrassing bug out of the
> way, but I would rather get the right solution in place (or, at least,
> know what it is) before we go ahead and write or commit them.
>
> Daniel
>
>
>
>
>
>
>
>
>
> On Tue, May 10, 2011 at 10:19, ajsharp <[email protected]> wrote:
> > Cool. If I stick with the monkey patch approach, I'll stick it in
> > monkey_patches.rb. I agree, a monkey patch here is definitely not the
> > most desirable solution, but maybe it's an acceptable approach at
> > least to get the specs running. After the specs run under 1.9, I'd be
> > in favor of finding a more robust solution.
>
> > Alex
> > @ajsharp
>
> > On May 9, 5:34 pm, Daniel Pittman <[email protected]> wrote:
> >> On Mon, May 9, 2011 at 16:11, Alex Sharp <[email protected]> wrote:
> >> > Ruby 1.9 removed Symbol#sub, and it's used in various places
> >> > in the puppet codebase.
>
> >> > This is a very simple patch that converts the symbol to a
> >> > string, performs the #sub on the string and then reconverts
> >> > the string back to a symbol. Crude, but it should work.
>
> >> We have `lib/puppet/monkey_patches.rb` to hold this sort of thing;
> >> this would be better added there. As an aside, it isn't entirely
> >> clear that this is desirable behaviour, and patches to change the use
> >> of sub on a symbol would also be accepted. I don't have a
> >> super-strong opinion either way, though, so if you wanted to merge
> >> this to our monkey patch file that should be good enough to commit.
>
> >> Daniel
> >> --
> >> ⎋ Puppet Labs Developer –http://puppetlabs.com
> >> ✉ Daniel Pittman <[email protected]>
> >> ✆ Contact me via gtalk, email, or phone: +1 (877) 575-9775
> >> ♲ Made with 100 percent post-consumer electrons
>
> > --
> > 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
> > athttp://groups.google.com/group/puppet-dev?hl=en.
>
> --
> ⎋ Puppet Labs Developer –http://puppetlabs.com
> ✉ Daniel Pittman <[email protected]>
> ✆ Contact me via gtalk, email, or phone: +1 (877) 575-9775
> ♲ Made with 100 percent post-consumer electrons
--
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.