bundler 1.10.6 → 1.11.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bundler might be problematic. Click here for more details.

Files changed (126) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +105 -0
  3. data/.rubocop_todo.yml +120 -0
  4. data/.travis.yml +8 -23
  5. data/CHANGELOG.md +69 -0
  6. data/CODE_OF_CONDUCT.md +6 -4
  7. data/DEVELOPMENT.md +4 -5
  8. data/README.md +2 -2
  9. data/Rakefile +70 -87
  10. data/bin/rake +14 -0
  11. data/bin/rspec +10 -0
  12. data/bin/rubocop +11 -0
  13. data/bundler.gemspec +17 -15
  14. data/exe/bundle +20 -0
  15. data/{bin → exe}/bundle_ruby +6 -4
  16. data/exe/bundler +20 -0
  17. data/lib/bundler.rb +98 -119
  18. data/lib/bundler/capistrano.rb +2 -2
  19. data/lib/bundler/cli.rb +85 -74
  20. data/lib/bundler/cli/binstubs.rb +1 -2
  21. data/lib/bundler/cli/cache.rb +0 -1
  22. data/lib/bundler/cli/check.rb +7 -5
  23. data/lib/bundler/cli/clean.rb +0 -1
  24. data/lib/bundler/cli/common.rb +6 -7
  25. data/lib/bundler/cli/config.rb +69 -56
  26. data/lib/bundler/cli/console.rb +8 -8
  27. data/lib/bundler/cli/exec.rb +4 -3
  28. data/lib/bundler/cli/gem.rb +50 -39
  29. data/lib/bundler/cli/init.rb +5 -6
  30. data/lib/bundler/cli/inject.rb +1 -2
  31. data/lib/bundler/cli/install.rb +18 -21
  32. data/lib/bundler/cli/lock.rb +8 -3
  33. data/lib/bundler/cli/open.rb +4 -5
  34. data/lib/bundler/cli/outdated.rb +7 -8
  35. data/lib/bundler/cli/package.rb +1 -1
  36. data/lib/bundler/cli/platform.rb +2 -3
  37. data/lib/bundler/cli/show.rb +9 -9
  38. data/lib/bundler/cli/update.rb +2 -3
  39. data/lib/bundler/cli/viz.rb +1 -2
  40. data/lib/bundler/constants.rb +1 -1
  41. data/lib/bundler/current_ruby.rb +38 -3
  42. data/lib/bundler/definition.rb +83 -88
  43. data/lib/bundler/dep_proxy.rb +11 -9
  44. data/lib/bundler/dependency.rb +26 -11
  45. data/lib/bundler/deployment.rb +2 -2
  46. data/lib/bundler/deprecate.rb +3 -3
  47. data/lib/bundler/dsl.rb +63 -44
  48. data/lib/bundler/env.rb +19 -12
  49. data/lib/bundler/environment.rb +1 -2
  50. data/lib/bundler/errors.rb +82 -0
  51. data/lib/bundler/fetcher.rb +45 -39
  52. data/lib/bundler/fetcher/base.rb +20 -7
  53. data/lib/bundler/fetcher/dependency.rb +5 -5
  54. data/lib/bundler/fetcher/downloader.rb +1 -2
  55. data/lib/bundler/fetcher/index.rb +4 -7
  56. data/lib/bundler/friendly_errors.rb +15 -8
  57. data/lib/bundler/gem_helper.rb +44 -35
  58. data/lib/bundler/gem_helpers.rb +7 -8
  59. data/lib/bundler/gem_remote_fetcher.rb +41 -0
  60. data/lib/bundler/gem_tasks.rb +4 -1
  61. data/lib/bundler/graph.rb +25 -24
  62. data/lib/bundler/index.rb +21 -18
  63. data/lib/bundler/injector.rb +2 -4
  64. data/lib/bundler/inline.rb +3 -3
  65. data/lib/bundler/installer.rb +57 -144
  66. data/lib/bundler/installer/gem_installer.rb +76 -0
  67. data/lib/bundler/installer/parallel_installer.rb +22 -13
  68. data/lib/bundler/installer/standalone.rb +48 -0
  69. data/lib/bundler/lazy_specification.rb +3 -4
  70. data/lib/bundler/lockfile_parser.rb +21 -19
  71. data/lib/bundler/match_platform.rb +4 -4
  72. data/lib/bundler/psyched_yaml.rb +3 -3
  73. data/lib/bundler/remote_specification.rb +1 -1
  74. data/lib/bundler/resolver.rb +93 -88
  75. data/lib/bundler/retry.rb +9 -10
  76. data/lib/bundler/ruby_dsl.rb +1 -1
  77. data/lib/bundler/ruby_version.rb +7 -10
  78. data/lib/bundler/rubygems_ext.rb +32 -27
  79. data/lib/bundler/{gem_installer.rb → rubygems_gem_installer.rb} +2 -2
  80. data/lib/bundler/rubygems_integration.rb +85 -70
  81. data/lib/bundler/runtime.rb +57 -61
  82. data/lib/bundler/settings.rb +27 -26
  83. data/lib/bundler/setup.rb +3 -3
  84. data/lib/bundler/shared_helpers.rb +45 -20
  85. data/lib/bundler/similarity_detector.rb +19 -21
  86. data/lib/bundler/source.rb +4 -5
  87. data/lib/bundler/source/git.rb +29 -31
  88. data/lib/bundler/source/git/git_proxy.rb +52 -26
  89. data/lib/bundler/source/path.rb +25 -28
  90. data/lib/bundler/source/path/installer.rb +4 -4
  91. data/lib/bundler/source/rubygems.rb +62 -48
  92. data/lib/bundler/source/rubygems/remote.rb +3 -3
  93. data/lib/bundler/source_list.rb +4 -4
  94. data/lib/bundler/spec_set.rb +17 -15
  95. data/lib/bundler/ssl_certs/certificate_manager.rb +5 -6
  96. data/lib/bundler/stub_specification.rb +2 -2
  97. data/lib/bundler/templates/Executable +5 -5
  98. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +42 -6
  99. data/lib/bundler/templates/newgem/README.md.tt +1 -1
  100. data/lib/bundler/templates/newgem/Rakefile.tt +4 -2
  101. data/lib/bundler/templates/newgem/bin/setup.tt +2 -1
  102. data/lib/bundler/templates/newgem/newgem.gemspec.tt +2 -2
  103. data/lib/bundler/ui.rb +3 -3
  104. data/lib/bundler/ui/rg_proxy.rb +2 -2
  105. data/lib/bundler/ui/shell.rb +10 -6
  106. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +82 -71
  107. data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +1 -1
  108. data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +9 -0
  109. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +40 -21
  110. data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +8 -0
  111. data/lib/bundler/vendored_molinillo.rb +1 -1
  112. data/lib/bundler/vendored_persistent.rb +3 -3
  113. data/lib/bundler/vendored_thor.rb +2 -2
  114. data/lib/bundler/version.rb +1 -1
  115. data/lib/bundler/vlad.rb +1 -1
  116. data/lib/bundler/worker.rb +4 -5
  117. data/man/bundle-config.ronn +4 -2
  118. data/man/bundle-gem.ronn +77 -0
  119. data/man/bundle-install.ronn +13 -6
  120. data/man/bundle-lock.ronn +47 -0
  121. data/man/bundle.ronn +1 -1
  122. data/man/gemfile.5.ronn +8 -0
  123. data/man/index.txt +1 -0
  124. metadata +37 -8
  125. data/bin/bundle +0 -21
  126. data/bin/bundler +0 -21
@@ -20,7 +20,7 @@ module Bundler
20
20
  end
21
21
 
22
22
  gems.each do |gem_name|
23
- spec = installer.specs.find{|s| s.name == gem_name }
23
+ spec = installer.specs.find {|s| s.name == gem_name }
24
24
  unless spec
25
25
  raise GemNotFound, Bundler::CLI::Common.gem_not_found_message(
26
26
  gem_name, Bundler.definition.specs)
@@ -33,6 +33,5 @@ module Bundler
33
33
  end
34
34
  end
35
35
  end
36
-
37
36
  end
38
37
  end
@@ -30,6 +30,5 @@ module Bundler
30
30
  "on Bundler 2.0."
31
31
  end
32
32
  end
33
-
34
33
  end
35
34
  end
@@ -6,30 +6,32 @@ module Bundler
6
6
  end
7
7
 
8
8
  def run
9
- Bundler.settings[:path] = File.expand_path(options[:path]) if options[:path]
9
+ if options[:path]
10
+ Bundler.settings[:path] = File.expand_path(options[:path])
11
+ Bundler.settings[:disable_shared_gems] = "1"
12
+ end
10
13
  begin
11
14
  definition = Bundler.definition
12
15
  definition.validate_ruby!
13
16
  not_installed = definition.missing_specs
14
17
  rescue GemNotFound, VersionConflict
15
18
  Bundler.ui.error "Bundler can't satisfy your Gemfile's dependencies."
16
- Bundler.ui.warn "Install missing gems with `bundle install`."
19
+ Bundler.ui.warn "Install missing gems with `bundle install`."
17
20
  exit 1
18
21
  end
19
22
 
20
23
  if not_installed.any?
21
24
  Bundler.ui.error "The following gems are missing"
22
- not_installed.each { |s| Bundler.ui.error " * #{s.name} (#{s.version})" }
25
+ not_installed.each {|s| Bundler.ui.error " * #{s.name} (#{s.version})" }
23
26
  Bundler.ui.warn "Install missing gems with `bundle install`"
24
27
  exit 1
25
28
  elsif !Bundler.default_lockfile.exist? && Bundler.settings[:frozen]
26
- Bundler.ui.error "This bundle has been frozen, but there is no Gemfile.lock present"
29
+ Bundler.ui.error "This bundle has been frozen, but there is no #{Bundler.default_lockfile.relative_path_from(SharedHelpers.pwd)} present"
27
30
  exit 1
28
31
  else
29
32
  Bundler.load.lock(:preserve_bundled_with => true) unless options[:"dry-run"]
30
33
  Bundler.ui.info "The Gemfile's dependencies are satisfied"
31
34
  end
32
35
  end
33
-
34
36
  end
35
37
  end
@@ -21,6 +21,5 @@ module Bundler
21
21
  exit 1
22
22
  end
23
23
  end
24
-
25
24
  end
26
25
  end
@@ -3,7 +3,7 @@ module Bundler
3
3
  def self.without_groups_message
4
4
  groups = Bundler.settings.without
5
5
  group_list = [groups[0...-1].join(", "), groups[-1..-1]].
6
- reject{|s| s.to_s.empty? }.join(" and ")
6
+ reject {|s| s.to_s.empty? }.join(" and ")
7
7
  group_str = (groups.size == 1) ? "group" : "groups"
8
8
  "Gems in the #{group_str} #{group_list} were not installed."
9
9
  end
@@ -30,27 +30,26 @@ module Bundler
30
30
  end
31
31
 
32
32
  def self.ask_for_spec_from(specs)
33
- if !$stdout.tty? && ENV['BUNDLE_SPEC_RUN'].nil?
33
+ if !$stdout.tty? && ENV["BUNDLE_SPEC_RUN"].nil?
34
34
  raise GemNotFound, gem_not_found_message(name, Bundler.definition.dependencies)
35
35
  end
36
36
 
37
37
  specs.each_with_index do |spec, index|
38
38
  Bundler.ui.info "#{index.succ} : #{spec.name}", true
39
39
  end
40
- Bundler.ui.info '0 : - exit -', true
40
+ Bundler.ui.info "0 : - exit -", true
41
41
 
42
- num = Bundler.ui.ask('> ').to_i
42
+ num = Bundler.ui.ask("> ").to_i
43
43
  num > 0 ? specs[num - 1] : nil
44
44
  end
45
45
 
46
46
  def self.gem_not_found_message(missing_gem_name, alternatives)
47
- require 'bundler/similarity_detector'
47
+ require "bundler/similarity_detector"
48
48
  message = "Could not find gem '#{missing_gem_name}'."
49
- alternate_names = alternatives.map { |a| a.respond_to?(:name) ? a.name : a }
49
+ alternate_names = alternatives.map {|a| a.respond_to?(:name) ? a.name : a }
50
50
  suggestions = SimilarityDetector.new(alternate_names).similar_word_list(missing_gem_name)
51
51
  message += "\nDid you mean #{suggestions}?" if suggestions
52
52
  message
53
53
  end
54
-
55
54
  end
56
55
  end
@@ -1,87 +1,100 @@
1
1
  module Bundler
2
2
  class CLI::Config
3
- attr_reader :options, :thor
3
+ attr_reader :name, :options, :scope, :thor
4
4
  attr_accessor :args
5
5
 
6
6
  def initialize(options, args, thor)
7
7
  @options = options
8
8
  @args = args
9
9
  @thor = thor
10
+ @name = peek = args.shift
11
+ @scope = "global"
12
+ if peek && peek =~ /^\-\-/
13
+ @name = args.shift
14
+ @scope = $'
15
+ end
10
16
  end
11
17
 
12
18
  def run
13
- peek = args.shift
19
+ unless name
20
+ confirm_all
21
+ return
22
+ end
14
23
 
15
- if peek && peek =~ /^\-\-/
16
- name, scope = args.shift, $'
17
- else
18
- name, scope = peek, "global"
24
+ unless valid_scope?(scope)
25
+ Bundler.ui.error "Invalid scope --#{scope} given. Please use --local or --global."
26
+ exit 1
19
27
  end
20
28
 
21
- unless name
22
- Bundler.ui.confirm "Settings are listed in order of priority. The top value will be used.\n"
29
+ if scope == "delete"
30
+ Bundler.settings.set_local(name, nil)
31
+ Bundler.settings.set_global(name, nil)
32
+ return
33
+ end
23
34
 
24
- Bundler.settings.all.each do |setting|
25
- Bundler.ui.confirm "#{setting}"
26
- thor.with_padding do
27
- Bundler.settings.pretty_values_for(setting).each do |line|
28
- Bundler.ui.info line
29
- end
30
- end
31
- Bundler.ui.confirm ""
32
- end
35
+ if args.empty?
36
+ confirm(name)
33
37
  return
34
38
  end
35
39
 
36
- case scope
37
- when "delete"
38
- Bundler.settings.set_local(name, nil)
39
- Bundler.settings.set_global(name, nil)
40
- when "local", "global"
41
- if args.empty?
42
- Bundler.ui.confirm "Settings for `#{name}` in order of priority. The top value will be used"
43
- thor.with_padding do
44
- Bundler.settings.pretty_values_for(name).each { |line| Bundler.ui.info line }
45
- end
46
- return
47
- end
40
+ Bundler.ui.info(message) if message
41
+ Bundler.settings.send("set_#{scope}", name, new_value)
42
+ end
48
43
 
49
- new_value = args.join(" ")
50
- locations = Bundler.settings.locations(name)
44
+ private
51
45
 
52
- if scope == "global"
53
- if locations[:local]
54
- Bundler.ui.info "Your application has set #{name} to #{locations[:local].inspect}. " \
55
- "This will override the global value you are currently setting"
56
- end
46
+ def confirm_all
47
+ Bundler.ui.confirm "Settings are listed in order of priority. The top value will be used.\n"
48
+ Bundler.settings.all.each do |setting|
49
+ Bundler.ui.confirm "#{setting}"
50
+ show_pretty_values_for(setting)
51
+ Bundler.ui.confirm ""
52
+ end
53
+ end
57
54
 
58
- if locations[:env]
59
- Bundler.ui.info "You have a bundler environment variable for #{name} set to " \
60
- "#{locations[:env].inspect}. This will take precedence over the global value you are setting"
61
- end
55
+ def confirm(name)
56
+ Bundler.ui.confirm "Settings for `#{name}` in order of priority. The top value will be used"
57
+ show_pretty_values_for(name)
58
+ end
62
59
 
63
- if locations[:global] && locations[:global] != new_value
64
- Bundler.ui.info "You are replacing the current global value of #{name}, which is currently " \
65
- "#{locations[:global].inspect}"
66
- end
67
- end
60
+ def new_value
61
+ pathname = Pathname.new(args.join(" "))
62
+ if name.match(/\Alocal\./) && pathname.directory?
63
+ pathname.expand_path.to_s
64
+ else
65
+ args.join(" ")
66
+ end
67
+ end
68
68
 
69
- if scope == "local" && locations[:local] != new_value
70
- Bundler.ui.info "You are replacing the current local value of #{name}, which is currently " \
71
- "#{locations[:local].inspect}"
69
+ def message
70
+ locations = Bundler.settings.locations(name)
71
+ if scope == "global"
72
+ if locations[:local]
73
+ "Your application has set #{name} to #{locations[:local].inspect}. " \
74
+ "This will override the global value you are currently setting"
75
+ elsif locations[:env]
76
+ "You have a bundler environment variable for #{name} set to " \
77
+ "#{locations[:env].inspect}. This will take precedence over the global value you are setting"
78
+ elsif locations[:global] && locations[:global] != args.join(" ")
79
+ "You are replacing the current global value of #{name}, which is currently " \
80
+ "#{locations[:global].inspect}"
72
81
  end
82
+ elsif scope == "local" && locations[:local] != args.join(" ")
83
+ "You are replacing the current local value of #{name}, which is currently " \
84
+ "#{locations[:local].inspect}"
85
+ end
86
+ end
73
87
 
74
- if name.match(/\Alocal\./)
75
- pathname = Pathname.new(args.join(" "))
76
- new_value = pathname.expand_path.to_s if pathname.directory?
88
+ def show_pretty_values_for(setting)
89
+ thor.with_padding do
90
+ Bundler.settings.pretty_values_for(setting).each do |line|
91
+ Bundler.ui.info line
77
92
  end
78
-
79
- Bundler.settings.send("set_#{scope}", name, new_value)
80
- else
81
- Bundler.ui.error "Invalid scope --#{scope} given. Please use --local or --global."
82
- exit 1
83
93
  end
84
94
  end
85
95
 
96
+ def valid_scope?(scope)
97
+ %w(delete local global).include?(scope)
98
+ end
86
99
  end
87
100
  end
@@ -7,10 +7,10 @@ module Bundler
7
7
  end
8
8
 
9
9
  def run
10
- group ? Bundler.require(:default, *(group.split.map! {|g| g.to_sym })) : Bundler.require
10
+ group ? Bundler.require(:default, *(group.split.map!(&:to_sym))) : Bundler.require
11
11
  ARGV.clear
12
12
 
13
- console = get_console(Bundler.settings[:console] || 'irb')
13
+ console = get_console(Bundler.settings[:console] || "irb")
14
14
  console.start
15
15
  end
16
16
 
@@ -18,21 +18,21 @@ module Bundler
18
18
  require name
19
19
  get_constant(name)
20
20
  rescue LoadError
21
- Bundler.ui.error "Couldn't load console #{name}"
22
- get_constant('irb')
21
+ Bundler.ui.error "Couldn't load console #{name}, falling back to irb"
22
+ require "irb"
23
+ get_constant("irb")
23
24
  end
24
25
 
25
26
  def get_constant(name)
26
27
  const_name = {
27
- 'pry' => :Pry,
28
- 'ripl' => :Ripl,
29
- 'irb' => :IRB,
28
+ "pry" => :Pry,
29
+ "ripl" => :Ripl,
30
+ "irb" => :IRB,
30
31
  }[name]
31
32
  Object.const_get(const_name)
32
33
  rescue NameError
33
34
  Bundler.ui.error "Could not find constant #{const_name}"
34
35
  exit 1
35
36
  end
36
-
37
37
  end
38
38
  end
@@ -1,3 +1,5 @@
1
+ require "bundler/current_ruby"
2
+
1
3
  module Bundler
2
4
  class CLI::Exec
3
5
  attr_reader :options, :args, :cmd
@@ -7,7 +9,7 @@ module Bundler
7
9
  @cmd = args.shift
8
10
  @args = args
9
11
 
10
- if RUBY_VERSION >= "2.0"
12
+ if Bundler.current_ruby.ruby_2? && !Bundler.current_ruby.jruby?
11
13
  @args << { :close_others => !options.keep_file_descriptors? }
12
14
  elsif options.keep_file_descriptors?
13
15
  Bundler.ui.warn "Ruby version #{RUBY_VERSION} defaults to keeping non-standard file descriptors on Kernel#exec."
@@ -38,13 +40,12 @@ module Bundler
38
40
  rescue Errno::ENOENT
39
41
  Bundler.ui = ui
40
42
  Bundler.ui.error "bundler: command not found: #{cmd}"
41
- Bundler.ui.warn "Install missing gem executables with `bundle install`"
43
+ Bundler.ui.warn "Install missing gem executables with `bundle install`"
42
44
  exit 127
43
45
  rescue ArgumentError
44
46
  Bundler.ui = ui
45
47
  Bundler.ui.error "bundler: exec needs a command to run"
46
48
  exit 128
47
49
  end
48
-
49
50
  end
50
51
  end
@@ -1,7 +1,12 @@
1
- require 'pathname'
1
+ require "pathname"
2
2
 
3
3
  module Bundler
4
4
  class CLI::Gem
5
+ TEST_FRAMEWORK_VERSIONS = {
6
+ "rspec" => "3.0",
7
+ "minitest" => "5.0"
8
+ }
9
+
5
10
  attr_reader :options, :gem_name, :thor, :name, :target
6
11
 
7
12
  def initialize(options, gem_name, thor)
@@ -10,7 +15,7 @@ module Bundler
10
15
  @thor = thor
11
16
 
12
17
  @name = @gem_name
13
- @target = Pathname.pwd.join(gem_name)
18
+ @target = SharedHelpers.pwd.join(gem_name)
14
19
 
15
20
  validate_ext_name if options[:ext]
16
21
  end
@@ -18,10 +23,11 @@ module Bundler
18
23
  def run
19
24
  Bundler.ui.confirm "Creating gem '#{name}'..."
20
25
 
21
- underscored_name = name.tr('-', '_')
22
- namespaced_path = name.tr('-', '/')
23
- constant_name = name.gsub(/-[_-]*(?![_-]|$)/){ '::' }.gsub(/([_-]+|(::)|^)(.|$)/){ $2.to_s + $3.upcase }
24
- constant_array = constant_name.split('::')
26
+ underscored_name = name.tr("-", "_")
27
+ namespaced_path = name.tr("-", "/")
28
+ constant_name = name.gsub(/-[_-]*(?![_-]|$)/) { "::" }.gsub(/([_-]+|(::)|^)(.|$)/) { $2.to_s + $3.upcase }
29
+ constant_array = constant_name.split("::")
30
+ test_task = options[:test] == "minitest" ? "test" : "spec"
25
31
 
26
32
  git_user_name = `git config user.name`.chomp
27
33
  git_user_email = `git config user.email`.chomp
@@ -36,6 +42,7 @@ module Bundler
36
42
  :author => git_user_name.empty? ? "TODO: Write your name" : git_user_name,
37
43
  :email => git_user_email.empty? ? "TODO: Write your email address" : git_user_email,
38
44
  :test => options[:test],
45
+ :test_task => test_task,
39
46
  :ext => options[:ext],
40
47
  :bin => options[:bin],
41
48
  :bundler_version => bundler_dependency_version
@@ -54,45 +61,25 @@ module Bundler
54
61
  "bin/setup.tt" => "bin/setup"
55
62
  }
56
63
 
57
- executables = %w[
64
+ executables = %w(
58
65
  bin/console
59
66
  bin/setup
60
- ]
61
-
62
- if ask_and_set(:coc, "Do you want to include a code of conduct in gems you generate?",
63
- "Codes of conduct can increase contributions to your project by contributors who " \
64
- "prefer collaborative, safe spaces. You can read more about the code of conduct at " \
65
- "contributor-covenant.org. Having a code of conduct means agreeing to the responsibility " \
66
- "of enforcing it, so be sure that you are prepared to do that. For suggestions about " \
67
- "how to enforce codes of conduct, see bit.ly/coc-enforcement."
68
- )
69
- config[:coc] = true
70
- Bundler.ui.info "Code of conduct enabled in config"
71
- templates.merge!("CODE_OF_CONDUCT.md.tt" => "CODE_OF_CONDUCT.md")
72
- end
73
-
74
- if ask_and_set(:mit, "Do you want to license your code permissively under the MIT license?",
75
- "This means that any other developer or company will be legally allowed to use your code " \
76
- "for free as long as they admit you created it. You can read more about the MIT license " \
77
- "at choosealicense.com/licenses/mit."
78
- )
79
- config[:mit] = true
80
- Bundler.ui.info "MIT License enabled in config"
81
- templates.merge!("LICENSE.txt.tt" => "LICENSE.txt")
82
- end
67
+ )
83
68
 
84
69
  if test_framework = ask_and_set_test_framework
85
70
  config[:test] = test_framework
71
+ config[:test_framework_version] = TEST_FRAMEWORK_VERSIONS[test_framework]
72
+
86
73
  templates.merge!(".travis.yml.tt" => ".travis.yml")
87
74
 
88
75
  case test_framework
89
- when 'rspec'
76
+ when "rspec"
90
77
  templates.merge!(
91
78
  "rspec.tt" => ".rspec",
92
79
  "spec/spec_helper.rb.tt" => "spec/spec_helper.rb",
93
80
  "spec/newgem_spec.rb.tt" => "spec/#{namespaced_path}_spec.rb"
94
81
  )
95
- when 'minitest'
82
+ when "minitest"
96
83
  templates.merge!(
97
84
  "test/test_helper.rb.tt" => "test/test_helper.rb",
98
85
  "test/newgem_test.rb.tt" => "test/#{namespaced_path}_test.rb"
@@ -100,6 +87,28 @@ module Bundler
100
87
  end
101
88
  end
102
89
 
90
+ if ask_and_set(:mit, "Do you want to license your code permissively under the MIT license?",
91
+ "This means that any other developer or company will be legally allowed to use your code " \
92
+ "for free as long as they admit you created it. You can read more about the MIT license " \
93
+ "at http://choosealicense.com/licenses/mit.")
94
+ config[:mit] = true
95
+ Bundler.ui.info "MIT License enabled in config"
96
+ templates.merge!("LICENSE.txt.tt" => "LICENSE.txt")
97
+ end
98
+
99
+ if ask_and_set(:coc, "Do you want to include a code of conduct in gems you generate?",
100
+ "Codes of conduct can increase contributions to your project by contributors who " \
101
+ "prefer collaborative, safe spaces. You can read more about the code of conduct at " \
102
+ "contributor-covenant.org. Having a code of conduct means agreeing to the responsibility " \
103
+ "of enforcing it, so be sure that you are prepared to do that. Be sure that your email " \
104
+ "address is specified as a contact in the generated code of conduct so that people know " \
105
+ "who to contact in case of a violation. For suggestions about " \
106
+ "how to enforce codes of conduct, see http://bit.ly/coc-enforcement.")
107
+ config[:coc] = true
108
+ Bundler.ui.info "Code of conduct enabled in config"
109
+ templates.merge!("CODE_OF_CONDUCT.md.tt" => "CODE_OF_CONDUCT.md")
110
+ end
111
+
103
112
  templates.merge!("exe/newgem.tt" => "exe/#{name}") if options[:bin]
104
113
 
105
114
  if options[:ext]
@@ -121,7 +130,10 @@ module Bundler
121
130
  end
122
131
 
123
132
  Bundler.ui.info "Initializing git repo in #{target}"
124
- Dir.chdir(target) { `git init`; `git add .` }
133
+ Dir.chdir(target) do
134
+ `git init`
135
+ `git add .`
136
+ end
125
137
 
126
138
  if options[:edit]
127
139
  # Open gemspec in editor
@@ -129,10 +141,10 @@ module Bundler
129
141
  end
130
142
  end
131
143
 
132
- private
144
+ private
133
145
 
134
146
  def resolve_name(name)
135
- Pathname.pwd.join(name).basename.to_s
147
+ SharedHelpers.pwd.join(name).basename.to_s
136
148
  end
137
149
 
138
150
  def ask_and_set(key, header, message)
@@ -148,7 +160,7 @@ module Bundler
148
160
  end
149
161
 
150
162
  def validate_ext_name
151
- return unless gem_name.index('-')
163
+ return unless gem_name.index("-")
152
164
 
153
165
  Bundler.ui.error "You have specified a gem name which does not conform to the \n" \
154
166
  "naming guidelines for C extensions. For more information, \n" \
@@ -181,11 +193,11 @@ module Bundler
181
193
  def bundler_dependency_version
182
194
  v = Gem::Version.new(Bundler::VERSION)
183
195
  req = v.segments[0..1]
184
- req << 'a' if v.prerelease?
196
+ req << "a" if v.prerelease?
185
197
  req.join(".")
186
198
  end
187
199
 
188
- def ensure_safe_gem_name name, constant_array
200
+ def ensure_safe_gem_name(name, constant_array)
189
201
  if name =~ /^\d/
190
202
  Bundler.ui.error "Invalid gem name #{name} Please give a name which does not start with numbers."
191
203
  exit 1
@@ -194,6 +206,5 @@ module Bundler
194
206
  exit 1
195
207
  end
196
208
  end
197
-
198
209
  end
199
210
  end