ruby-changes:39732
From: usa <ko1@a...>
Date: Wed, 9 Sep 2015 16:57:52 +0900 (JST)
Subject: [ruby-changes:39732] usa:r51813 (trunk): * ruby.c (usage, enable_option, disable_option, process_options): new
usa 2015-09-09 16:57:31 +0900 (Wed, 09 Sep 2015) New Revision: 51813 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=51813 Log: * ruby.c (usage, enable_option, disable_option, process_options): new option `--disable_did_you_mean`. * gem_prelude.rb: now requires did_you_mean gem by default if available. Modified files: trunk/ChangeLog trunk/gem_prelude.rb trunk/ruby.c Index: ChangeLog =================================================================== --- ChangeLog (revision 51812) +++ ChangeLog (revision 51813) @@ -1,3 +1,10 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Wed Sep 9 16:55:45 2015 NAKAMURA Usaku <usa@r...> + + * ruby.c (usage, enable_option, disable_option, process_options): new + option `--disable_did_you_mean`. + + * gem_prelude.rb: now requires did_you_mean gem by default if available. + Wed Sep 9 13:38:56 2015 Nobuyoshi Nakada <nobu@r...> * tool/extlibs.rb (do_patch): let "patch" command change the Index: gem_prelude.rb =================================================================== --- gem_prelude.rb (revision 51812) +++ gem_prelude.rb (revision 51813) @@ -1 +1,7 @@ -require 'rubygems.rb' if defined?(Gem) +if defined?(Gem) + require 'rubygems.rb' + begin + require 'did_you_mean' + rescue LoadError + end if defined?(DidYouMean) +end Index: ruby.c =================================================================== --- ruby.c (revision 51812) +++ ruby.c (revision 51813) @@ -62,6 +62,7 @@ char *getenv(); https://github.com/ruby/ruby/blob/trunk/ruby.c#L62 #define DISABLE_BIT(bit) (1U << disable_##bit) enum disable_flag_bits { disable_gems, + disable_did_you_mean, disable_rubyopt, disable_flag_count }; @@ -192,6 +193,7 @@ usage(const char *name, int help) https://github.com/ruby/ruby/blob/trunk/ruby.c#L193 }; static const struct message features[] = { M("gems", "", "rubygems (default: "DEFAULT_RUBYGEMS_ENABLED")"), + M("did_you_mean", "", "did_you_mean (default: "DEFAULT_RUBYGEMS_ENABLED")"), M("rubyopt", "", "RUBYOPT environment variable (default: enabled)"), }; int i; @@ -710,6 +712,7 @@ enable_option(const char *str, int len, https://github.com/ruby/ruby/blob/trunk/ruby.c#L712 { #define UNSET_WHEN_DISABLE(bit) UNSET_WHEN(#bit, DISABLE_BIT(bit), str, len) UNSET_WHEN_DISABLE(gems); + UNSET_WHEN_DISABLE(did_you_mean); UNSET_WHEN_DISABLE(rubyopt); if (NAME_MATCH_P("all", str, len)) { *(unsigned int *)arg = 0U; @@ -723,6 +726,7 @@ disable_option(const char *str, int len, https://github.com/ruby/ruby/blob/trunk/ruby.c#L726 { #define SET_WHEN_DISABLE(bit) SET_WHEN(#bit, DISABLE_BIT(bit), str, len) SET_WHEN_DISABLE(gems); + SET_WHEN_DISABLE(did_you_mean); SET_WHEN_DISABLE(rubyopt); if (NAME_MATCH_P("all", str, len)) { *(unsigned int *)arg = ~0U; @@ -1435,6 +1439,9 @@ process_options(int argc, char **argv, s https://github.com/ruby/ruby/blob/trunk/ruby.c#L1439 if (!(opt->disable & DISABLE_BIT(gems))) { rb_define_module("Gem"); } + if (!(opt->disable & DISABLE_BIT(did_you_mean))) { + rb_define_module("DidYouMean"); + } ruby_init_prelude(); #if UTF8_PATH opt->script_name = str_conv_enc(opt->script_name, rb_utf8_encoding(), lenc); -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/