diff options
author | Andre Arko <andre@arko.net> | 2015-01-25 18:59:31 -0800 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2015-01-25 23:30:18 -0800 |
commit | 30903263a4ff69275f4075742dc2ab928de31167 (patch) | |
tree | 5dbf792f5b7cd9d9b534785147dd8a0aa66c23cb /lib | |
parent | 25f55d96e79f34575fb45da27379091666d48f61 (diff) | |
download | bundler-30903263a4ff69275f4075742dc2ab928de31167.tar.gz |
clean up and reword a bit asking about gem files
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bundler/cli.rb | 18 | ||||
-rw-r--r-- | lib/bundler/cli/gem.rb | 31 | ||||
-rw-r--r-- | lib/bundler/templates/newgem/README.md.tt | 4 |
3 files changed, 35 insertions, 18 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 5e2f9682..b3f72ae5 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -331,7 +331,6 @@ module Bundler method_option :requirements, :type => :boolean, :default => false, :aliases => '-r', :banner => "Set to show the version of each required dependency." method_option :version, :type => :boolean, :default => false, :aliases => '-v', :banner => "Set to show each gem version." method_option :without, :type => :array, :default => [], :banner => "Exclude gems that are part of the specified named group." - def viz require 'bundler/cli/viz' Viz.new(options).run @@ -339,17 +338,14 @@ module Bundler desc "gem GEM [OPTIONS]", "Creates a skeleton for creating a rubygem" method_option :bin, :type => :boolean, :default => false, :aliases => '-b', :banner => "Generate a binary for your library." - method_option :edit, :type => :string, :aliases => "-e", - :lazy_default => [ENV['BUNDLER_EDITOR'], ENV['VISUAL'], ENV['EDITOR']].find{|e| !e.nil? && !e.empty? }, - :required => false, :banner => "/path/to/your/editor", - :desc => "Open generated gemspec in the specified editor (defaults to $EDITOR or $BUNDLER_EDITOR)" + method_option :coc, :type => :boolean, :banner => "Generate a code of conduct file" + method_option :edit, :type => :string, :aliases => "-e", :required => false, :banner => "/path/to/your/editor", + :lazy_default => [ENV['BUNDLER_EDITOR'], ENV['VISUAL'], ENV['EDITOR']].find{|e| !e.nil? && !e.empty? }, + :desc => "Open generated gemspec in the specified editor (defaults to $EDITOR or $BUNDLER_EDITOR)" method_option :ext, :type => :boolean, :default => false, :banner => "Generate the boilerplate for C extension code" - method_option :test, :type => :string, :lazy_default => 'rspec', :aliases => '-t', :banner => - "Generate a test directory for your library: 'rspec' is the default, but 'minitest' is also supported." - - method_option :mit, :type => :boolean, :banner => "Use MIT license" - method_option :coc, :type => :boolean, :banner => "Use Code Of Conduct" - + method_option :mit, :type => :boolean, :banner => "Generate an MIT license file" + method_option :test, :type => :string, :lazy_default => 'rspec', :aliases => '-t', + :banner => "Generate a test directory for your library: 'rspec' is the default, but 'minitest' is also supported." def gem(name) require 'bundler/cli/gem' Gem.new(options, name, self).run diff --git a/lib/bundler/cli/gem.rb b/lib/bundler/cli/gem.rb index e99a13b1..2bb0b53a 100644 --- a/lib/bundler/cli/gem.rb +++ b/lib/bundler/cli/gem.rb @@ -16,6 +16,8 @@ module Bundler end def run + Bundler.ui.confirm "Creating gem '#{name}'..." + underscored_name = name.tr('-', '_') namespaced_path = name.tr('-', '/') constant_name = name.split('_').map{|p| p[0..0].upcase + p[1..-1] }.join @@ -47,11 +49,21 @@ module Bundler "README.md.tt" => "README.md" } - if ask_and_set(:coc, "Do you want to include Code Of Conduct?") + if ask_and_set(:coc, "Do you want to include a code of conduct in gems you generate?", + "Codes of conduct can increase contributions to your project by contributors who " \ + "prefer collaborative, safe spaces. You can read more about the code of conduct at " \ + "contributor-covenant.org. Having a code of conduct means agreeing to the responsibility " \ + "of enforcing it, so be sure that you are prepared to do that. For suggestions about " \ + "how to enforce codes of conduct, see bit.ly/coc-enforcement." + ) templates.merge!("CODE_OF_CONDUCT.md.tt" => "CODE_OF_CONDUCT.md") end - if ask_and_set(:mit, "Do you want to license your code permissively under the MIT license (http://choosealicense.com/licenses/mit/)?") + if ask_and_set(:mit, "Do you want to license your code permissively under the MIT license?", + "This means that any other developer or company will be legally allowed to use your code " \ + "for free as long as they admit you created it. You can read more about the MIT license " \ + "at choosealicense.com/licenses/mit." + ) templates.merge!("LICENSE.txt.tt" => "LICENSE.txt") end @@ -102,11 +114,12 @@ module Bundler Pathname.pwd.join(name).basename.to_s end - def ask_and_set(key, message) + def ask_and_set(key, header, message) result = options[key] if !Bundler.settings.all.include?("gem.#{key}") if result.nil? - result = Bundler.ui.ask("#{message} (y/n):") == "y" + Bundler.ui.confirm header + result = Bundler.ui.ask("#{message} y/(n):") == "y" end Bundler.settings.set_global("gem.#{key}", result) @@ -128,8 +141,14 @@ module Bundler def ask_and_set_test_framework test_framework = options[:test] || Bundler.settings["gem.test"] if test_framework.nil? - result = Bundler.ui.ask("Would like to generate tests along with their gems? (rspec/minitest/false):") - test_framework = result == "false" ? false : result + Bundler.ui.confirm "Do you want to generate tests with your gem?" + result = Bundler.ui.ask "Type 'rspec' or 'minitest' to generate those test files now and " \ + "in the future. rspec/minitest/(none):" + if result =~ /rspec|minitest/ + test_framework = result + else + test_framework = "false" + end end if Bundler.settings["gem.test"].nil? diff --git a/lib/bundler/templates/newgem/README.md.tt b/lib/bundler/templates/newgem/README.md.tt index 8a65988c..1a8737eb 100644 --- a/lib/bundler/templates/newgem/README.md.tt +++ b/lib/bundler/templates/newgem/README.md.tt @@ -1,6 +1,8 @@ # <%=config[:constant_name]%> -TODO: Write a gem description +Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/<%=config[:namespaced_path]%>`. To experiment with that code, run `bin/console` for an interactive prompt. + +TODO: Delete this and the text above, and describe your gem ## Installation |