bundler 1.7.15 → 1.8.0.pre

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 (191) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +5 -14
  3. data/.rspec +1 -0
  4. data/.travis.yml +22 -15
  5. data/CHANGELOG.md +43 -13
  6. data/CODE_OF_CONDUCT.md +40 -0
  7. data/CONTRIBUTING.md +14 -12
  8. data/DEVELOPMENT.md +4 -2
  9. data/ISSUES.md +1 -1
  10. data/README.md +10 -14
  11. data/Rakefile +10 -10
  12. data/bin/bundle +1 -1
  13. data/bundler.gemspec +5 -4
  14. data/lib/bundler.rb +22 -3
  15. data/lib/bundler/anonymizable_uri.rb +24 -8
  16. data/lib/bundler/cli.rb +103 -66
  17. data/lib/bundler/cli/cache.rb +1 -0
  18. data/lib/bundler/cli/clean.rb +11 -4
  19. data/lib/bundler/cli/common.rb +2 -0
  20. data/lib/bundler/cli/console.rb +22 -26
  21. data/lib/bundler/cli/exec.rb +29 -22
  22. data/lib/bundler/cli/gem.rb +125 -37
  23. data/lib/bundler/cli/install.rb +22 -9
  24. data/lib/bundler/cli/outdated.rb +1 -1
  25. data/lib/bundler/cli/package.rb +8 -1
  26. data/lib/bundler/cli/show.rb +29 -3
  27. data/lib/bundler/cli/update.rb +2 -2
  28. data/lib/bundler/cli/viz.rb +1 -1
  29. data/lib/bundler/definition.rb +14 -22
  30. data/lib/bundler/dependency.rb +8 -1
  31. data/lib/bundler/dsl.rb +17 -4
  32. data/lib/bundler/endpoint_specification.rb +1 -1
  33. data/lib/bundler/env.rb +44 -25
  34. data/lib/bundler/fetcher.rb +33 -25
  35. data/lib/bundler/friendly_errors.rb +38 -5
  36. data/lib/bundler/gem_helper.rb +16 -10
  37. data/lib/bundler/gem_helpers.rb +1 -0
  38. data/lib/bundler/graph.rb +4 -1
  39. data/lib/bundler/index.rb +15 -25
  40. data/lib/bundler/installer.rb +6 -6
  41. data/lib/bundler/lockfile_parser.rb +7 -7
  42. data/lib/bundler/resolver.rb +2 -1
  43. data/lib/bundler/ruby_version.rb +1 -1
  44. data/lib/bundler/rubygems_ext.rb +1 -0
  45. data/lib/bundler/rubygems_integration.rb +1 -1
  46. data/lib/bundler/runtime.rb +22 -40
  47. data/lib/bundler/settings.rb +14 -5
  48. data/lib/bundler/setup.rb +2 -1
  49. data/lib/bundler/shared_helpers.rb +56 -4
  50. data/lib/bundler/source.rb +8 -9
  51. data/lib/bundler/source/git.rb +5 -1
  52. data/lib/bundler/source/git/git_proxy.rb +4 -0
  53. data/lib/bundler/source/path.rb +8 -11
  54. data/lib/bundler/source/path/installer.rb +0 -2
  55. data/lib/bundler/source/rubygems.rb +58 -72
  56. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +13 -0
  57. data/lib/bundler/templates/newgem/LICENSE.txt.tt +17 -18
  58. data/lib/bundler/templates/newgem/README.md.tt +9 -1
  59. data/lib/bundler/templates/newgem/Rakefile.tt +2 -0
  60. data/lib/bundler/templates/newgem/bin/console.tt +14 -0
  61. data/lib/bundler/templates/newgem/bin/setup.tt +7 -0
  62. data/lib/bundler/templates/newgem/exe/newgem.tt +3 -0
  63. data/lib/bundler/templates/newgem/gitignore.tt +2 -0
  64. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +1 -1
  65. data/lib/bundler/templates/newgem/newgem.gemspec.tt +17 -13
  66. data/lib/bundler/templates/newgem/test/test_newgem.rb.tt +1 -1
  67. data/lib/bundler/ui/shell.rb +1 -1
  68. data/lib/bundler/version.rb +1 -1
  69. data/lib/bundler/worker.rb +73 -0
  70. data/man/bundle-config.ronn +17 -15
  71. data/man/bundle-install.ronn +102 -93
  72. data/man/bundle-update.ronn +39 -30
  73. data/man/bundle.ronn +6 -0
  74. data/man/gemfile.5.ronn +74 -13
  75. metadata +10 -231
  76. data/lib/bundler/parallel_workers.rb +0 -18
  77. data/lib/bundler/parallel_workers/thread_worker.rb +0 -30
  78. data/lib/bundler/parallel_workers/unix_worker.rb +0 -101
  79. data/lib/bundler/parallel_workers/worker.rb +0 -69
  80. data/lib/bundler/templates/newgem/bin/newgem.tt +0 -3
  81. data/spec/bundler/anonymizable_uri_spec.rb +0 -32
  82. data/spec/bundler/bundler_spec.rb +0 -72
  83. data/spec/bundler/cli_spec.rb +0 -16
  84. data/spec/bundler/definition_spec.rb +0 -22
  85. data/spec/bundler/dsl_spec.rb +0 -82
  86. data/spec/bundler/friendly_errors_spec.rb +0 -13
  87. data/spec/bundler/gem_helper_spec.rb +0 -226
  88. data/spec/bundler/psyched_yaml_spec.rb +0 -8
  89. data/spec/bundler/retry_spec.rb +0 -59
  90. data/spec/bundler/settings_spec.rb +0 -13
  91. data/spec/bundler/source/rubygems_spec.rb +0 -25
  92. data/spec/bundler/source_list_spec.rb +0 -361
  93. data/spec/cache/gems_spec.rb +0 -284
  94. data/spec/cache/git_spec.rb +0 -188
  95. data/spec/cache/path_spec.rb +0 -121
  96. data/spec/cache/platform_spec.rb +0 -57
  97. data/spec/commands/binstubs_spec.rb +0 -219
  98. data/spec/commands/check_spec.rb +0 -278
  99. data/spec/commands/clean_spec.rb +0 -592
  100. data/spec/commands/config_spec.rb +0 -263
  101. data/spec/commands/console_spec.rb +0 -76
  102. data/spec/commands/exec_spec.rb +0 -309
  103. data/spec/commands/help_spec.rb +0 -39
  104. data/spec/commands/init_spec.rb +0 -39
  105. data/spec/commands/inject_spec.rb +0 -78
  106. data/spec/commands/licenses_spec.rb +0 -18
  107. data/spec/commands/newgem_spec.rb +0 -428
  108. data/spec/commands/open_spec.rb +0 -68
  109. data/spec/commands/outdated_spec.rb +0 -156
  110. data/spec/commands/package_spec.rb +0 -114
  111. data/spec/commands/show_spec.rb +0 -125
  112. data/spec/install/binstubs_spec.rb +0 -24
  113. data/spec/install/bundler_spec.rb +0 -146
  114. data/spec/install/deploy_spec.rb +0 -250
  115. data/spec/install/gemfile/gemspec_spec.rb +0 -170
  116. data/spec/install/gemfile/git_spec.rb +0 -967
  117. data/spec/install/gemfile/path_spec.rb +0 -500
  118. data/spec/install/gemfile_spec.rb +0 -44
  119. data/spec/install/gems/c_ext_spec.rb +0 -48
  120. data/spec/install/gems/dependency_api_spec.rb +0 -652
  121. data/spec/install/gems/env_spec.rb +0 -107
  122. data/spec/install/gems/flex_spec.rb +0 -314
  123. data/spec/install/gems/groups_spec.rb +0 -308
  124. data/spec/install/gems/mirror_spec.rb +0 -39
  125. data/spec/install/gems/platform_spec.rb +0 -195
  126. data/spec/install/gems/post_install_spec.rb +0 -121
  127. data/spec/install/gems/resolving_spec.rb +0 -124
  128. data/spec/install/gems/simple_case_spec.rb +0 -377
  129. data/spec/install/gems/sources_spec.rb +0 -386
  130. data/spec/install/gems/standalone_spec.rb +0 -260
  131. data/spec/install/gems/sudo_spec.rb +0 -136
  132. data/spec/install/gems/win32_spec.rb +0 -26
  133. data/spec/install/gemspecs_spec.rb +0 -50
  134. data/spec/install/path_spec.rb +0 -150
  135. data/spec/install/post_bundle_message_spec.rb +0 -142
  136. data/spec/install/prereleases_spec.rb +0 -43
  137. data/spec/install/security_policy_spec.rb +0 -77
  138. data/spec/install/upgrade_spec.rb +0 -26
  139. data/spec/lock/git_spec.rb +0 -34
  140. data/spec/lock/lockfile_spec.rb +0 -924
  141. data/spec/other/bundle_ruby_spec.rb +0 -142
  142. data/spec/other/cli_dispatch_spec.rb +0 -21
  143. data/spec/other/ext_spec.rb +0 -60
  144. data/spec/other/platform_spec.rb +0 -1285
  145. data/spec/other/ssl_cert_spec.rb +0 -23
  146. data/spec/quality_spec.rb +0 -88
  147. data/spec/realworld/dependency_api_spec.rb +0 -60
  148. data/spec/realworld/edgecases_spec.rb +0 -212
  149. data/spec/realworld/parallel_spec.rb +0 -71
  150. data/spec/resolver/basic_spec.rb +0 -66
  151. data/spec/resolver/platform_spec.rb +0 -88
  152. data/spec/runtime/executable_spec.rb +0 -149
  153. data/spec/runtime/load_spec.rb +0 -107
  154. data/spec/runtime/platform_spec.rb +0 -90
  155. data/spec/runtime/require_spec.rb +0 -332
  156. data/spec/runtime/setup_spec.rb +0 -853
  157. data/spec/runtime/with_clean_env_spec.rb +0 -91
  158. data/spec/spec_helper.rb +0 -123
  159. data/spec/support/artifice/endopint_marshal_fail_basic_authentication.rb +0 -13
  160. data/spec/support/artifice/endpoint.rb +0 -71
  161. data/spec/support/artifice/endpoint_500.rb +0 -37
  162. data/spec/support/artifice/endpoint_api_forbidden.rb +0 -11
  163. data/spec/support/artifice/endpoint_api_missing.rb +0 -16
  164. data/spec/support/artifice/endpoint_basic_authentication.rb +0 -13
  165. data/spec/support/artifice/endpoint_creds_diff_host.rb +0 -38
  166. data/spec/support/artifice/endpoint_extra.rb +0 -31
  167. data/spec/support/artifice/endpoint_extra_api.rb +0 -32
  168. data/spec/support/artifice/endpoint_extra_missing.rb +0 -15
  169. data/spec/support/artifice/endpoint_fallback.rb +0 -17
  170. data/spec/support/artifice/endpoint_host_redirect.rb +0 -15
  171. data/spec/support/artifice/endpoint_marshal_fail.rb +0 -11
  172. data/spec/support/artifice/endpoint_redirect.rb +0 -15
  173. data/spec/support/artifice/endpoint_strict_basic_authentication.rb +0 -18
  174. data/spec/support/artifice/endpoint_timeout.rb +0 -13
  175. data/spec/support/builders.rb +0 -693
  176. data/spec/support/fakeweb/rack-1.0.0.marshal +0 -2
  177. data/spec/support/fakeweb/windows.rb +0 -23
  178. data/spec/support/hax.rb +0 -22
  179. data/spec/support/helpers.rb +0 -361
  180. data/spec/support/indexes.rb +0 -280
  181. data/spec/support/matchers.rb +0 -77
  182. data/spec/support/path.rb +0 -85
  183. data/spec/support/permissions.rb +0 -10
  184. data/spec/support/platforms.rb +0 -94
  185. data/spec/support/ruby_ext.rb +0 -20
  186. data/spec/support/rubygems_ext.rb +0 -39
  187. data/spec/support/streams.rb +0 -13
  188. data/spec/support/sudo.rb +0 -16
  189. data/spec/update/gems_spec.rb +0 -201
  190. data/spec/update/git_spec.rb +0 -283
  191. data/spec/update/path_spec.rb +0 -18
@@ -7,10 +7,17 @@ module Bundler
7
7
  end
8
8
 
9
9
  def run
10
- if Bundler.settings[:path] || options[:force]
11
- Bundler.load.clean(options[:"dry-run"])
12
- else
13
- Bundler.ui.error "Can only use bundle clean when --path is set or --force is set"
10
+ require_path_or_force
11
+ Bundler.load.clean(options[:"dry-run"])
12
+ end
13
+
14
+ protected
15
+
16
+ def require_path_or_force
17
+ if !Bundler.settings[:path] && !options[:force]
18
+ Bundler.ui.error "Cleaning all the gems on your system is dangerous! " \
19
+ "If you're sure you want to remove every system gem not in this " \
20
+ "bundle, run `bundle clean --force`."
14
21
  exit 1
15
22
  end
16
23
  end
@@ -25,6 +25,8 @@ module Bundler
25
25
  else
26
26
  ask_for_spec_from(specs)
27
27
  end
28
+ rescue RegexpError
29
+ raise GemNotFound, gem_not_found_message(name, Bundler.definition.dependencies)
28
30
  end
29
31
 
30
32
  def self.ask_for_spec_from(specs)
@@ -1,41 +1,37 @@
1
1
  module Bundler
2
2
  class CLI::Console
3
- attr_reader :options, :group, :consoles
4
- def initialize(options, group, consoles)
3
+ attr_reader :options, :group
4
+ def initialize(options, group)
5
5
  @options = options
6
6
  @group = group
7
- @consoles = consoles
8
7
  end
9
8
 
10
9
  def run
11
10
  group ? Bundler.require(:default, *(group.split.map! {|g| g.to_sym })) : Bundler.require
12
11
  ARGV.clear
13
12
 
14
- preferred = Bundler.settings[:console] || 'irb'
15
-
16
- # See if console is available
17
- begin
18
- require preferred || true
19
- rescue LoadError
20
- # Is it in Gemfile?
21
- Bundler.ui.error "Could not load the #{preferred} console"
22
- Bundler.ui.info "Falling back on IRB..."
23
-
24
- require 'irb'
25
- preferred = 'irb'
26
- end
27
-
28
- constant = consoles[preferred]
13
+ console = get_console(Bundler.settings[:console] || 'irb')
14
+ console.start
15
+ end
29
16
 
30
- console = begin
31
- Object.const_get(constant)
32
- rescue NameError => e
33
- Bundler.ui.error e.inspect
34
- Bundler.ui.error "Could not load the #{constant} console"
35
- return
36
- end
17
+ def get_console(name)
18
+ require name
19
+ get_constant(name)
20
+ rescue LoadError
21
+ Bundler.ui.error "Couldn't load console #{name}"
22
+ get_constant('irb')
23
+ end
37
24
 
38
- console.start
25
+ def get_constant(name)
26
+ const_name = {
27
+ 'pry' => :Pry,
28
+ 'ripl' => :Ripl,
29
+ 'irb' => :IRB,
30
+ }[name]
31
+ Object.const_get(const_name)
32
+ rescue NameError
33
+ Bundler.ui.error "Could not find constant #{const_name}"
34
+ exit 1
39
35
  end
40
36
 
41
37
  end
@@ -1,36 +1,43 @@
1
1
  module Bundler
2
2
  class CLI::Exec
3
- attr_reader :options, :args
3
+ attr_reader :options, :args, :cmd
4
4
 
5
5
  def initialize(options, args)
6
6
  @options = options
7
+ @cmd = args.shift
7
8
  @args = args
9
+
10
+ if RUBY_VERSION >= "2.0"
11
+ @args << { :close_others => !options.keep_file_descriptors? }
12
+ elsif options.keep_file_descriptors?
13
+ Bundler.ui.warn "Ruby version #{RUBY_VERSION} defaults to keeping non-standard file descriptors on Kernel#exec."
14
+ end
8
15
  end
9
16
 
10
17
  def run
11
- Bundler.definition.validate_ruby!
12
- Bundler.load.setup_environment
18
+ raise ArgumentError if cmd.nil?
13
19
 
14
- begin
15
- if RUBY_VERSION >= "2.0"
16
- @args << { :close_others => !options.keep_file_descriptors? }
17
- elsif options.keep_file_descriptors?
18
- Bundler.ui.warn "Ruby version #{RUBY_VERSION} defaults to keeping non-standard file descriptors on Kernel#exec."
19
- end
20
-
21
- # Run
22
- Kernel.exec(*args)
23
- rescue Errno::EACCES
24
- Bundler.ui.error "bundler: not executable: #{args.first}"
25
- exit 126
26
- rescue Errno::ENOENT
27
- Bundler.ui.error "bundler: command not found: #{args.first}"
28
- Bundler.ui.warn "Install missing gem executables with `bundle install`"
29
- exit 127
30
- rescue ArgumentError
31
- Bundler.ui.error "bundler: exec needs a command to run"
32
- exit 128
20
+ # First, try to exec directly to something in PATH
21
+ SharedHelpers.set_bundle_environment
22
+ bin_path = Bundler.which(@cmd)
23
+ if bin_path
24
+ Kernel.exec(bin_path, *args)
33
25
  end
26
+
27
+ # If that didn't work, set up the whole bundle
28
+ Bundler.definition.validate_ruby!
29
+ Bundler.load.setup_environment
30
+ Kernel.exec(@cmd, *args)
31
+ rescue Errno::EACCES
32
+ Bundler.ui.error "bundler: not executable: #{cmd}"
33
+ exit 126
34
+ rescue Errno::ENOENT
35
+ Bundler.ui.error "bundler: command not found: #{cmd}"
36
+ Bundler.ui.warn "Install missing gem executables with `bundle install`"
37
+ exit 127
38
+ rescue ArgumentError
39
+ Bundler.ui.error "bundler: exec needs a command to run"
40
+ exit 128
34
41
  end
35
42
 
36
43
  end
@@ -1,30 +1,31 @@
1
+ require 'pathname'
2
+
1
3
  module Bundler
2
4
  class CLI::Gem
3
- attr_reader :options, :gem_name, :thor
5
+ attr_reader :options, :gem_name, :thor, :name, :target
6
+
4
7
  def initialize(options, gem_name, thor)
5
8
  @options = options
6
- @gem_name = gem_name
9
+ @gem_name = resolve_name(gem_name)
7
10
  @thor = thor
11
+
12
+ @name = @gem_name
13
+ @target = Pathname.pwd.join(gem_name)
14
+
15
+ validate_ext_name if options[:ext]
8
16
  end
9
17
 
10
18
  def run
11
- if options[:ext] && gem_name.index('-')
12
- Bundler.ui.error "You have specified a gem name which does not conform to the \n" \
13
- "naming guidelines for C extensions. For more information, \n" \
14
- "see the 'Extension Naming' section at the following URL:\n" \
15
- "http://guides.rubygems.org/gems-with-extensions/\n"
16
- exit 1
17
- end
19
+ Bundler.ui.confirm "Creating gem '#{name}'..."
18
20
 
19
- name = gem_name.chomp("/") # remove trailing slash if present
20
21
  underscored_name = name.tr('-', '_')
21
22
  namespaced_path = name.tr('-', '/')
22
- target = File.join(Dir.pwd, name)
23
23
  constant_name = name.split('_').map{|p| p[0..0].upcase + p[1..-1] }.join
24
24
  constant_name = constant_name.split('-').map{|q| q[0..0].upcase + q[1..-1] }.join('::') if constant_name =~ /-/
25
25
  constant_array = constant_name.split('::')
26
26
  git_user_name = `git config user.name`.chomp
27
27
  git_user_email = `git config user.email`.chomp
28
+
28
29
  opts = {
29
30
  :name => name,
30
31
  :underscored_name => underscored_name,
@@ -35,44 +36,131 @@ module Bundler
35
36
  :author => git_user_name.empty? ? "TODO: Write your name" : git_user_name,
36
37
  :email => git_user_email.empty? ? "TODO: Write your email address" : git_user_email,
37
38
  :test => options[:test],
38
- :ext => options[:ext]
39
+ :ext => options[:ext],
40
+ :bin => options[:bin]
41
+ }
42
+
43
+ templates = {
44
+ "Gemfile.tt" => "Gemfile",
45
+ "gitignore.tt" => ".gitignore",
46
+ "lib/newgem.rb.tt" => "lib/#{namespaced_path}.rb",
47
+ "lib/newgem/version.rb.tt" => "lib/#{namespaced_path}/version.rb",
48
+ "newgem.gemspec.tt" => "#{name}.gemspec",
49
+ "Rakefile.tt" => "Rakefile",
50
+ "README.md.tt" => "README.md",
51
+ "bin/console.tt" => "bin/console",
52
+ "bin/setup.tt" => "bin/setup"
39
53
  }
40
- gemspec_dest = File.join(target, "#{name}.gemspec")
41
- thor.template(File.join("newgem/Gemfile.tt"), File.join(target, "Gemfile"), opts)
42
- thor.template(File.join("newgem/Rakefile.tt"), File.join(target, "Rakefile"), opts)
43
- thor.template(File.join("newgem/LICENSE.txt.tt"), File.join(target, "LICENSE.txt"), opts)
44
- thor.template(File.join("newgem/README.md.tt"), File.join(target, "README.md"), opts)
45
- thor.template(File.join("newgem/gitignore.tt"), File.join(target, ".gitignore"), opts)
46
- thor.template(File.join("newgem/newgem.gemspec.tt"), gemspec_dest, opts)
47
- thor.template(File.join("newgem/lib/newgem.rb.tt"), File.join(target, "lib/#{namespaced_path}.rb"), opts)
48
- thor.template(File.join("newgem/lib/newgem/version.rb.tt"), File.join(target, "lib/#{namespaced_path}/version.rb"), opts)
49
- if options[:bin]
50
- thor.template(File.join("newgem/bin/newgem.tt"), File.join(target, 'bin', name), opts)
54
+
55
+ if ask_and_set(:coc, "Do you want to include a code of conduct in gems you generate?",
56
+ "Codes of conduct can increase contributions to your project by contributors who " \
57
+ "prefer collaborative, safe spaces. You can read more about the code of conduct at " \
58
+ "contributor-covenant.org. Having a code of conduct means agreeing to the responsibility " \
59
+ "of enforcing it, so be sure that you are prepared to do that. For suggestions about " \
60
+ "how to enforce codes of conduct, see bit.ly/coc-enforcement."
61
+ )
62
+ templates.merge!("CODE_OF_CONDUCT.md.tt" => "CODE_OF_CONDUCT.md")
51
63
  end
52
- case options[:test]
53
- when 'rspec'
54
- thor.template(File.join("newgem/rspec.tt"), File.join(target, ".rspec"), opts)
55
- thor.template(File.join("newgem/spec/spec_helper.rb.tt"), File.join(target, "spec/spec_helper.rb"), opts)
56
- thor.template(File.join("newgem/spec/newgem_spec.rb.tt"), File.join(target, "spec/#{namespaced_path}_spec.rb"), opts)
57
- when 'minitest'
58
- thor.template(File.join("newgem/test/minitest_helper.rb.tt"), File.join(target, "test/minitest_helper.rb"), opts)
59
- thor.template(File.join("newgem/test/test_newgem.rb.tt"), File.join(target, "test/test_#{namespaced_path}.rb"), opts)
64
+
65
+ if ask_and_set(:mit, "Do you want to license your code permissively under the MIT license?",
66
+ "This means that any other developer or company will be legally allowed to use your code " \
67
+ "for free as long as they admit you created it. You can read more about the MIT license " \
68
+ "at choosealicense.com/licenses/mit."
69
+ )
70
+ templates.merge!("LICENSE.txt.tt" => "LICENSE.txt")
60
71
  end
61
- if options[:test]
62
- thor.template(File.join("newgem/.travis.yml.tt"), File.join(target, ".travis.yml"), opts)
72
+
73
+ if test_framework = ask_and_set_test_framework
74
+ templates.merge!(".travis.yml.tt" => ".travis.yml")
75
+
76
+ case test_framework
77
+ when 'rspec'
78
+ templates.merge!(
79
+ "rspec.tt" => ".rspec",
80
+ "spec/spec_helper.rb.tt" => "spec/spec_helper.rb",
81
+ "spec/newgem_spec.rb.tt" => "spec/#{namespaced_path}_spec.rb"
82
+ )
83
+ when 'minitest'
84
+ templates.merge!(
85
+ "test/minitest_helper.rb.tt" => "test/minitest_helper.rb",
86
+ "test/test_newgem.rb.tt" => "test/test_#{namespaced_path}.rb"
87
+ )
88
+ end
63
89
  end
90
+
91
+ templates.merge!("exe/newgem.tt" => "exe/#{name}") if options[:bin]
92
+
64
93
  if options[:ext]
65
- thor.template(File.join("newgem/ext/newgem/extconf.rb.tt"), File.join(target, "ext/#{name}/extconf.rb"), opts)
66
- thor.template(File.join("newgem/ext/newgem/newgem.h.tt"), File.join(target, "ext/#{name}/#{underscored_name}.h"), opts)
67
- thor.template(File.join("newgem/ext/newgem/newgem.c.tt"), File.join(target, "ext/#{name}/#{underscored_name}.c"), opts)
94
+ templates.merge!(
95
+ "ext/newgem/extconf.rb.tt" => "ext/#{name}/extconf.rb",
96
+ "ext/newgem/newgem.h.tt" => "ext/#{name}/#{underscored_name}.h",
97
+ "ext/newgem/newgem.c.tt" => "ext/#{name}/#{underscored_name}.c"
98
+ )
99
+ end
100
+
101
+ templates.each do |src, dst|
102
+ thor.template("newgem/#{src}", target.join(dst), opts)
68
103
  end
104
+
69
105
  Bundler.ui.info "Initializing git repo in #{target}"
70
106
  Dir.chdir(target) { `git init`; `git add .` }
71
107
 
72
108
  if options[:edit]
73
- thor.run("#{options["edit"]} \"#{gemspec_dest}\"") # Open gemspec in editor
109
+ # Open gemspec in editor
110
+ thor.run("#{options["edit"]} \"#{target.join("#{name}.gemspec")}\"")
74
111
  end
75
112
  end
76
113
 
114
+ private
115
+
116
+ def resolve_name(name)
117
+ Pathname.pwd.join(name).basename.to_s
118
+ end
119
+
120
+ def ask_and_set(key, header, message)
121
+ result = options[key]
122
+ if !Bundler.settings.all.include?("gem.#{key}")
123
+ if result.nil?
124
+ Bundler.ui.confirm header
125
+ result = Bundler.ui.ask("#{message} y/(n):") == "y"
126
+ end
127
+
128
+ Bundler.settings.set_global("gem.#{key}", result)
129
+ end
130
+
131
+ result || Bundler.settings["gem.#{key}"]
132
+ end
133
+
134
+ def validate_ext_name
135
+ return unless gem_name.index('-')
136
+
137
+ Bundler.ui.error "You have specified a gem name which does not conform to the \n" \
138
+ "naming guidelines for C extensions. For more information, \n" \
139
+ "see the 'Extension Naming' section at the following URL:\n" \
140
+ "http://guides.rubygems.org/gems-with-extensions/\n"
141
+ exit 1
142
+ end
143
+
144
+ def ask_and_set_test_framework
145
+ test_framework = options[:test] || Bundler.settings["gem.test"]
146
+ if test_framework.nil?
147
+ Bundler.ui.confirm "Do you want to generate tests with your gem?"
148
+ result = Bundler.ui.ask "Type 'rspec' or 'minitest' to generate those test files now and " \
149
+ "in the future. rspec/minitest/(none):"
150
+ if result =~ /rspec|minitest/
151
+ test_framework = result
152
+ else
153
+ test_framework = "false"
154
+ end
155
+ end
156
+
157
+ if Bundler.settings["gem.test"].nil?
158
+ Bundler.settings.set_global("gem.test", test_framework)
159
+ end
160
+
161
+ return if test_framework == "false"
162
+ test_framework
163
+ end
164
+
77
165
  end
78
166
  end
@@ -44,7 +44,7 @@ module Bundler
44
44
  "before deploying."
45
45
  end
46
46
 
47
- if Bundler.root.join("vendor/cache").exist?
47
+ if Bundler.app_cache.exist?
48
48
  options[:local] = true
49
49
  end
50
50
 
@@ -66,6 +66,7 @@ module Bundler
66
66
  Bundler.settings[:shebang] = options["shebang"] if options["shebang"]
67
67
  Bundler.settings[:jobs] = options["jobs"] if options["jobs"]
68
68
  Bundler.settings[:no_prune] = true if options["no-prune"]
69
+ Bundler.settings[:no_install] = true if options["no-install"]
69
70
  Bundler.settings[:clean] = options["clean"] if options["clean"]
70
71
  Bundler.settings.without = options[:without]
71
72
  Bundler::Fetcher.disable_endpoint = options["full-index"]
@@ -77,23 +78,24 @@ module Bundler
77
78
  definition = Bundler.definition
78
79
  definition.validate_ruby!
79
80
  Installer.install(Bundler.root, definition, options)
80
- Bundler.load.cache if Bundler.root.join("vendor/cache").exist? && !options["no-cache"] && !Bundler.settings[:frozen]
81
+ Bundler.load.cache if Bundler.app_cache.exist? && !options["no-cache"] && !Bundler.settings[:frozen]
82
+
83
+ Bundler.ui.confirm "Bundle complete! #{dependencies_count_for(definition)}, #{gems_installed_for(definition)}."
84
+ confirm_without_groups
81
85
 
82
86
  if Bundler.settings[:path]
83
87
  absolute_path = File.expand_path(Bundler.settings[:path])
84
88
  relative_path = absolute_path.sub(File.expand_path('.'), '.')
85
- Bundler.ui.confirm "Your bundle is complete!"
86
- without_groups_messages
87
- Bundler.ui.confirm "It was installed into #{relative_path}"
89
+ Bundler.ui.confirm "Bundled gems are installed into #{relative_path}."
88
90
  else
89
- Bundler.ui.confirm "Your bundle is complete!"
90
- without_groups_messages
91
91
  Bundler.ui.confirm "Use `bundle show [gemname]` to see where a bundled gem is installed."
92
92
  end
93
+
93
94
  Installer.post_install_messages.to_a.each do |name, msg|
94
95
  Bundler.ui.confirm "Post-install message from #{name}:"
95
96
  Bundler.ui.info msg
96
97
  end
98
+
97
99
  Installer.ambiguous_gems.to_a.each do |name, installed_from_uri, *also_found_in_uris|
98
100
  Bundler.ui.error "Warning: the gem '#{name}' was found in multiple sources."
99
101
  Bundler.ui.error "Installed from: #{installed_from_uri}"
@@ -111,7 +113,7 @@ module Bundler
111
113
  end
112
114
  rescue GemNotFound, VersionConflict => e
113
115
  if options[:local] && Bundler.app_cache.exist?
114
- Bundler.ui.warn "Some gems seem to be missing from your vendor/cache directory."
116
+ Bundler.ui.warn "Some gems seem to be missing from your #{Bundler.settings.app_cache_path} directory."
115
117
  end
116
118
 
117
119
  unless Bundler.definition.has_rubygems_remotes?
@@ -133,11 +135,22 @@ module Bundler
133
135
  "application for all non-root users on this machine.", :wrap => true
134
136
  end
135
137
 
136
- def without_groups_messages
138
+ def confirm_without_groups
137
139
  if Bundler.settings.without.any?
138
140
  require "bundler/cli/common"
139
141
  Bundler.ui.confirm Bundler::CLI::Common.without_groups_message
140
142
  end
141
143
  end
144
+
145
+ def dependencies_count_for(definition)
146
+ count = definition.dependencies.count
147
+ "#{count} Gemfile #{count == 1 ? 'dependency' : 'dependencies'}"
148
+ end
149
+
150
+ def gems_installed_for(definition)
151
+ count = definition.specs.count
152
+ "#{count} #{count == 1 ? 'gem' : 'gems'} now installed"
153
+ end
154
+
142
155
  end
143
156
  end
@@ -70,7 +70,7 @@ module Bundler
70
70
  end
71
71
 
72
72
  if out_count.zero?
73
- Bundler.ui.info "Your bundle is up to date!\n"
73
+ Bundler.ui.info "Bundle up to date!\n"
74
74
  else
75
75
  exit 1
76
76
  end