bundler 2.0.0.pre.1 → 2.1.0.pre.3

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 (230) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +774 -574
  3. data/LICENSE.md +18 -19
  4. data/README.md +9 -8
  5. data/bundler.gemspec +12 -23
  6. data/exe/bundle +19 -3
  7. data/lib/bundler.rb +203 -87
  8. data/lib/bundler/build_metadata.rb +14 -7
  9. data/lib/bundler/capistrano.rb +5 -5
  10. data/lib/bundler/cli.rb +181 -143
  11. data/lib/bundler/cli/add.rb +28 -16
  12. data/lib/bundler/cli/cache.rb +25 -13
  13. data/lib/bundler/cli/common.rb +11 -12
  14. data/lib/bundler/cli/config.rb +161 -86
  15. data/lib/bundler/cli/console.rb +2 -2
  16. data/lib/bundler/cli/doctor.rb +4 -4
  17. data/lib/bundler/cli/exec.rb +4 -16
  18. data/lib/bundler/cli/gem.rb +5 -5
  19. data/lib/bundler/cli/info.rb +17 -5
  20. data/lib/bundler/cli/init.rb +1 -1
  21. data/lib/bundler/cli/install.rb +12 -11
  22. data/lib/bundler/cli/issue.rb +3 -3
  23. data/lib/bundler/cli/open.rb +10 -6
  24. data/lib/bundler/cli/outdated.rb +85 -81
  25. data/lib/bundler/cli/plugin.rb +9 -2
  26. data/lib/bundler/cli/pristine.rb +1 -1
  27. data/lib/bundler/cli/show.rb +1 -1
  28. data/lib/bundler/cli/update.rb +32 -12
  29. data/lib/bundler/compact_index_client.rb +25 -9
  30. data/lib/bundler/compact_index_client/updater.rb +2 -6
  31. data/lib/bundler/current_ruby.rb +9 -7
  32. data/lib/bundler/definition.rb +36 -27
  33. data/lib/bundler/dependency.rb +16 -4
  34. data/lib/bundler/deployment.rb +2 -2
  35. data/lib/bundler/dsl.rb +18 -42
  36. data/lib/bundler/env.rb +8 -13
  37. data/lib/bundler/environment_preserver.rb +0 -1
  38. data/lib/bundler/feature_flag.rb +1 -11
  39. data/lib/bundler/fetcher.rb +14 -11
  40. data/lib/bundler/fetcher/compact_index.rb +26 -12
  41. data/lib/bundler/fetcher/dependency.rb +1 -1
  42. data/lib/bundler/fetcher/downloader.rb +4 -1
  43. data/lib/bundler/fetcher/index.rb +4 -2
  44. data/lib/bundler/friendly_errors.rb +5 -6
  45. data/lib/bundler/gem_helper.rb +38 -25
  46. data/lib/bundler/gem_helpers.rb +2 -4
  47. data/lib/bundler/gem_tasks.rb +1 -1
  48. data/lib/bundler/gem_version_promoter.rb +3 -3
  49. data/lib/bundler/graph.rb +2 -2
  50. data/lib/bundler/injector.rb +10 -8
  51. data/lib/bundler/inline.rb +25 -20
  52. data/lib/bundler/installer.rb +7 -14
  53. data/lib/bundler/installer/gem_installer.rb +5 -1
  54. data/lib/bundler/installer/parallel_installer.rb +4 -8
  55. data/lib/bundler/installer/standalone.rb +1 -2
  56. data/lib/bundler/lazy_specification.rb +2 -2
  57. data/lib/bundler/lockfile_parser.rb +14 -21
  58. data/lib/bundler/match_platform.rb +1 -1
  59. data/lib/bundler/plugin.rb +42 -29
  60. data/lib/bundler/plugin/api.rb +1 -1
  61. data/lib/bundler/plugin/api/source.rb +2 -2
  62. data/lib/bundler/plugin/index.rb +14 -3
  63. data/lib/bundler/plugin/installer.rb +28 -15
  64. data/lib/bundler/psyched_yaml.rb +1 -1
  65. data/lib/bundler/resolver.rb +72 -24
  66. data/lib/bundler/resolver/spec_group.rb +3 -2
  67. data/lib/bundler/retry.rb +2 -2
  68. data/lib/bundler/ruby_version.rb +4 -19
  69. data/lib/bundler/rubygems_ext.rb +11 -67
  70. data/lib/bundler/rubygems_gem_installer.rb +1 -1
  71. data/lib/bundler/rubygems_integration.rb +143 -395
  72. data/lib/bundler/runtime.rb +2 -9
  73. data/lib/bundler/settings.rb +15 -48
  74. data/lib/bundler/setup.rb +7 -13
  75. data/lib/bundler/shared_helpers.rb +57 -73
  76. data/lib/bundler/similarity_detector.rb +2 -2
  77. data/lib/bundler/source.rb +5 -5
  78. data/lib/bundler/source/git.rb +19 -12
  79. data/lib/bundler/source/git/git_proxy.rb +36 -40
  80. data/lib/bundler/source/metadata.rb +9 -5
  81. data/lib/bundler/source/path.rb +13 -8
  82. data/lib/bundler/source/rubygems.rb +11 -5
  83. data/lib/bundler/source/rubygems/remote.rb +1 -2
  84. data/lib/bundler/source_list.rb +9 -12
  85. data/lib/bundler/spec_set.rb +23 -12
  86. data/lib/bundler/stub_specification.rb +18 -30
  87. data/lib/bundler/templates/Executable.bundler +23 -14
  88. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +3 -3
  89. data/lib/bundler/templates/newgem/Gemfile.tt +8 -2
  90. data/lib/bundler/templates/newgem/README.md.tt +4 -3
  91. data/lib/bundler/templates/newgem/newgem.gemspec.tt +6 -27
  92. data/lib/bundler/templates/newgem/test/test_helper.rb.tt +1 -1
  93. data/lib/bundler/templates/newgem/travis.yml.tt +0 -1
  94. data/lib/bundler/ui.rb +3 -3
  95. data/lib/bundler/ui/rg_proxy.rb +1 -1
  96. data/lib/bundler/ui/shell.rb +4 -8
  97. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +161 -0
  98. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +66 -0
  99. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +176 -0
  100. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +3 -0
  101. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +273 -147
  102. data/lib/bundler/vendor/fileutils/lib/fileutils/version.rb +5 -0
  103. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +6 -6
  104. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +2 -2
  105. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +1 -1
  106. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +1 -1
  107. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +1 -1
  108. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +1 -1
  109. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +6 -6
  110. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +1 -1
  111. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +1 -1
  112. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +30 -8
  113. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +1 -1
  114. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +4 -4
  115. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +2 -2
  116. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +248 -279
  117. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +40 -0
  118. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +53 -0
  119. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +79 -0
  120. data/lib/bundler/vendor/thor/lib/thor.rb +12 -4
  121. data/lib/bundler/vendor/thor/lib/thor/actions.rb +22 -11
  122. data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +1 -1
  123. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +1 -1
  124. data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +7 -17
  125. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +16 -7
  126. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +19 -8
  127. data/lib/bundler/vendor/thor/lib/thor/base.rb +25 -24
  128. data/lib/bundler/vendor/thor/lib/thor/command.rb +21 -14
  129. data/lib/bundler/vendor/thor/lib/thor/error.rb +78 -0
  130. data/lib/bundler/vendor/thor/lib/thor/group.rb +3 -3
  131. data/lib/bundler/vendor/thor/lib/thor/invocation.rb +1 -0
  132. data/lib/bundler/vendor/thor/lib/thor/line_editor.rb +2 -2
  133. data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +1 -1
  134. data/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +6 -6
  135. data/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -4
  136. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +1 -1
  137. data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +8 -6
  138. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +20 -5
  139. data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +1 -0
  140. data/lib/bundler/vendor/thor/lib/thor/runner.rb +8 -6
  141. data/lib/bundler/vendor/thor/lib/thor/shell.rb +4 -4
  142. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +52 -7
  143. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +6 -2
  144. data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +1 -1
  145. data/lib/bundler/vendor/thor/lib/thor/util.rb +1 -1
  146. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  147. data/lib/bundler/vendored_fileutils.rb +1 -6
  148. data/lib/bundler/vendored_molinillo.rb +1 -1
  149. data/lib/bundler/vendored_persistent.rb +7 -5
  150. data/lib/bundler/vendored_thor.rb +2 -2
  151. data/lib/bundler/version.rb +1 -20
  152. data/lib/bundler/version_ranges.rb +51 -5
  153. data/lib/bundler/vlad.rb +3 -3
  154. data/lib/bundler/worker.rb +1 -3
  155. data/lib/bundler/yaml_serializer.rb +2 -3
  156. data/man/bundle-add.1 +10 -2
  157. data/man/bundle-add.1.txt +11 -5
  158. data/man/bundle-add.ronn +7 -1
  159. data/man/bundle-binstubs.1 +2 -2
  160. data/man/bundle-binstubs.1.txt +2 -2
  161. data/man/bundle-binstubs.ronn +1 -1
  162. data/man/bundle-cache.1 +55 -0
  163. data/man/bundle-cache.1.txt +78 -0
  164. data/man/{bundle-package.ronn → bundle-cache.ronn} +15 -15
  165. data/man/bundle-check.1 +1 -1
  166. data/man/bundle-check.1.txt +6 -6
  167. data/man/bundle-clean.1 +1 -1
  168. data/man/bundle-clean.1.txt +1 -1
  169. data/man/bundle-config.1 +36 -36
  170. data/man/bundle-config.1.txt +66 -67
  171. data/man/bundle-config.ronn +42 -40
  172. data/man/bundle-doctor.1 +1 -1
  173. data/man/bundle-doctor.1.txt +1 -1
  174. data/man/bundle-exec.1 +2 -2
  175. data/man/bundle-exec.1.txt +2 -2
  176. data/man/bundle-exec.ronn +1 -1
  177. data/man/bundle-gem.1 +1 -1
  178. data/man/bundle-gem.1.txt +3 -3
  179. data/man/bundle-info.1 +1 -1
  180. data/man/bundle-info.1.txt +1 -1
  181. data/man/bundle-init.1 +2 -2
  182. data/man/bundle-init.1.txt +2 -2
  183. data/man/bundle-init.ronn +1 -1
  184. data/man/bundle-inject.1 +1 -1
  185. data/man/bundle-inject.1.txt +1 -1
  186. data/man/bundle-install.1 +8 -5
  187. data/man/bundle-install.1.txt +56 -51
  188. data/man/bundle-install.ronn +9 -4
  189. data/man/bundle-list.1 +1 -1
  190. data/man/bundle-list.1.txt +1 -1
  191. data/man/bundle-lock.1 +1 -1
  192. data/man/bundle-lock.1.txt +16 -16
  193. data/man/bundle-open.1 +1 -1
  194. data/man/bundle-open.1.txt +1 -1
  195. data/man/bundle-outdated.1 +1 -1
  196. data/man/bundle-outdated.1.txt +1 -1
  197. data/man/bundle-platform.1 +1 -1
  198. data/man/bundle-platform.1.txt +1 -1
  199. data/man/bundle-pristine.1 +1 -1
  200. data/man/bundle-pristine.1.txt +1 -1
  201. data/man/bundle-remove.1 +1 -1
  202. data/man/bundle-remove.1.txt +1 -1
  203. data/man/bundle-show.1 +1 -1
  204. data/man/bundle-show.1.txt +1 -1
  205. data/man/bundle-update.1 +4 -4
  206. data/man/bundle-update.1.txt +64 -65
  207. data/man/bundle-update.ronn +3 -3
  208. data/man/bundle-viz.1 +1 -1
  209. data/man/bundle-viz.1.txt +1 -1
  210. data/man/bundle.1 +7 -3
  211. data/man/bundle.1.txt +11 -8
  212. data/man/bundle.ronn +5 -2
  213. data/man/gemfile.5 +17 -20
  214. data/man/gemfile.5.ronn +14 -18
  215. data/man/gemfile.5.txt +108 -112
  216. data/man/index.txt +1 -1
  217. metadata +19 -107
  218. data/exe/bundle_ruby +0 -60
  219. data/lib/bundler/cli/package.rb +0 -49
  220. data/lib/bundler/compatibility_guard.rb +0 -14
  221. data/lib/bundler/ssl_certs/.document +0 -1
  222. data/lib/bundler/ssl_certs/certificate_manager.rb +0 -66
  223. data/lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +0 -21
  224. data/lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +0 -23
  225. data/lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +0 -25
  226. data/lib/bundler/vendor/net-http-persistent/lib/net/http/faster.rb +0 -27
  227. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse.rb +0 -129
  228. data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +0 -129
  229. data/man/bundle-package.1 +0 -55
  230. data/man/bundle-package.1.txt +0 -79
@@ -1,16 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "tsort"
4
- require "forwardable"
5
4
  require "set"
6
5
 
7
6
  module Bundler
8
7
  class SpecSet
9
- extend Forwardable
10
- include TSort, Enumerable
11
-
12
- def_delegators :@specs, :<<, :length, :add, :remove, :size, :empty?
13
- def_delegators :sorted, :each
8
+ include Enumerable
9
+ include TSort
14
10
 
15
11
  def initialize(specs)
16
12
  @specs = specs
@@ -64,7 +60,6 @@ module Bundler
64
60
  @specs << value
65
61
  @lookup = nil
66
62
  @sorted = nil
67
- value
68
63
  end
69
64
 
70
65
  def sort!
@@ -132,6 +127,26 @@ module Bundler
132
127
  what_required(req) << spec
133
128
  end
134
129
 
130
+ def <<(spec)
131
+ @specs << spec
132
+ end
133
+
134
+ def length
135
+ @specs.length
136
+ end
137
+
138
+ def size
139
+ @specs.size
140
+ end
141
+
142
+ def empty?
143
+ @specs.empty?
144
+ end
145
+
146
+ def each(&b)
147
+ sorted.each(&b)
148
+ end
149
+
135
150
  private
136
151
 
137
152
  def sorted
@@ -147,11 +162,7 @@ module Bundler
147
162
  end
148
163
 
149
164
  def extract_circular_gems(error)
150
- if Bundler.current_ruby.mri? && Bundler.current_ruby.on_19?
151
- error.message.scan(/(\w+) \([^)]/).flatten
152
- else
153
- error.message.scan(/@name="(.*?)"/).flatten
154
- end
165
+ error.message.scan(/@name="(.*?)"/).flatten
155
166
  end
156
167
 
157
168
  def lookup
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/remote_specification"
3
+ require_relative "remote_specification"
4
4
 
5
5
  module Bundler
6
6
  class StubSpecification < RemoteSpecification
@@ -13,17 +13,13 @@ module Bundler
13
13
 
14
14
  attr_accessor :stub, :ignored
15
15
 
16
- # Pre 2.2.0 did not include extension_dir
17
- # https://github.com/rubygems/rubygems/commit/9485ca2d101b82a946d6f327f4bdcdea6d4946ea
18
- if Bundler.rubygems.provides?(">= 2.2.0")
19
- def source=(source)
20
- super
21
- # Stub has no concept of source, which means that extension_dir may be wrong
22
- # This is the case for git-based gems. So, instead manually assign the extension dir
23
- return unless source.respond_to?(:extension_dir_name)
24
- path = File.join(stub.extensions_dir, source.extension_dir_name)
25
- stub.extension_dir = File.expand_path(path)
26
- end
16
+ def source=(source)
17
+ super
18
+ # Stub has no concept of source, which means that extension_dir may be wrong
19
+ # This is the case for git-based gems. So, instead manually assign the extension dir
20
+ return unless source.respond_to?(:extension_dir_name)
21
+ path = File.join(stub.extensions_dir, source.extension_dir_name)
22
+ stub.extension_dir = File.expand_path(path)
27
23
  end
28
24
 
29
25
  def to_yaml
@@ -32,11 +28,9 @@ module Bundler
32
28
 
33
29
  # @!group Stub Delegates
34
30
 
35
- if Bundler.rubygems.provides?(">= 2.3")
36
- # This is defined directly to avoid having to load every installed spec
37
- def missing_extensions?
38
- stub.missing_extensions?
39
- end
31
+ # This is defined directly to avoid having to load every installed spec
32
+ def missing_extensions?
33
+ stub.missing_extensions?
40
34
  end
41
35
 
42
36
  def activated
@@ -57,26 +51,20 @@ module Bundler
57
51
  stub.full_gem_path || method_missing(:full_gem_path)
58
52
  end
59
53
 
60
- if Bundler.rubygems.provides?(">= 2.2.0")
61
- def full_require_paths
62
- stub.full_require_paths
63
- end
54
+ def full_require_paths
55
+ stub.full_require_paths
56
+ end
64
57
 
65
- # This is what we do in bundler/rubygems_ext
66
- # full_require_paths is always implemented in >= 2.2.0
67
- def load_paths
68
- full_require_paths
69
- end
58
+ def load_paths
59
+ full_require_paths
70
60
  end
71
61
 
72
62
  def loaded_from
73
63
  stub.loaded_from
74
64
  end
75
65
 
76
- if Bundler.rubygems.stubs_provide_full_functionality?
77
- def matches_for_glob(glob)
78
- stub.matches_for_glob(glob)
79
- end
66
+ def matches_for_glob(glob)
67
+ stub.matches_for_glob(glob)
80
68
  end
81
69
 
82
70
  def raw_require_paths
@@ -11,7 +11,7 @@
11
11
  require "rubygems"
12
12
 
13
13
  m = Module.new do
14
- module_function
14
+ module_function
15
15
 
16
16
  def invoked_as_script?
17
17
  File.expand_path($0) == File.expand_path(__FILE__)
@@ -31,7 +31,7 @@ m = Module.new do
31
31
  bundler_version = a
32
32
  end
33
33
  next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
34
- bundler_version = $1 || ">= 0.a"
34
+ bundler_version = $1
35
35
  update_index = i
36
36
  end
37
37
  bundler_version
@@ -61,32 +61,41 @@ m = Module.new do
61
61
  end
62
62
 
63
63
  def bundler_version
64
- @bundler_version ||= begin
64
+ @bundler_version ||=
65
65
  env_var_version || cli_arg_version ||
66
- lockfile_version || "#{Gem::Requirement.default}.a"
67
- end
66
+ lockfile_version
67
+ end
68
+
69
+ def bundler_requirement
70
+ return "#{Gem::Requirement.default}.a" unless bundler_version
71
+
72
+ bundler_gem_version = Gem::Version.new(bundler_version)
73
+
74
+ requirement = bundler_gem_version.approximate_recommendation
75
+
76
+ return requirement unless Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.7.0")
77
+
78
+ requirement += ".a" if bundler_gem_version.prerelease?
79
+
80
+ requirement
68
81
  end
69
82
 
70
83
  def load_bundler!
71
84
  ENV["BUNDLE_GEMFILE"] ||= gemfile
72
85
 
73
- # must dup string for RG < 1.8 compatibility
74
- activate_bundler(bundler_version.dup)
86
+ activate_bundler
75
87
  end
76
88
 
77
- def activate_bundler(bundler_version)
78
- if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0")
79
- bundler_version = "< 2"
80
- end
89
+ def activate_bundler
81
90
  gem_error = activation_error_handling do
82
- gem "bundler", bundler_version
91
+ gem "bundler", bundler_requirement
83
92
  end
84
93
  return if gem_error.nil?
85
94
  require_error = activation_error_handling do
86
95
  require "bundler/version"
87
96
  end
88
- return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION))
89
- warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`"
97
+ return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
98
+ warn "Activating bundler (#{bundler_requirement}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_requirement}'`"
90
99
  exit 42
91
100
  end
92
101
 
@@ -68,7 +68,7 @@ members of the project's leadership.
68
68
  ## Attribution
69
69
 
70
70
  This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
- available at [http://contributor-covenant.org/version/1/4][version]
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
72
 
73
- [homepage]: http://contributor-covenant.org
74
- [version]: http://contributor-covenant.org/version/1/4/
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
@@ -1,6 +1,12 @@
1
1
  source "https://rubygems.org"
2
2
 
3
- git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
-
5
3
  # Specify your gem's dependencies in <%= config[:name] %>.gemspec
6
4
  gemspec
5
+
6
+ gem "rake", "~> 12.0"
7
+ <%- if config[:ext] -%>
8
+ gem "rake-compiler"
9
+ <%- end -%>
10
+ <%- if config[:test] -%>
11
+ gem "<%= config[:test] %>", "~> <%= config[:test_framework_version] %>"
12
+ <%- end -%>
@@ -14,7 +14,7 @@ gem '<%= config[:name] %>'
14
14
 
15
15
  And then execute:
16
16
 
17
- $ bundle
17
+ $ bundle install
18
18
 
19
19
  Or install it yourself as:
20
20
 
@@ -32,7 +32,8 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
32
32
 
33
33
  ## Contributing
34
34
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/<%= config[:github_username] %>/<%= config[:name] %>.<% if config[:coc] %> This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.<% end %>
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/<%= config[:github_username] %>/<%= config[:name] %>.<% if config[:coc] %> This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/<%= config[:github_username] %>/<%= config[:name] %>/blob/master/CODE_OF_CONDUCT.md).<% end %>
36
+
36
37
  <% if config[:mit] -%>
37
38
 
38
39
  ## License
@@ -43,5 +44,5 @@ The gem is available as open source under the terms of the [MIT License](https:/
43
44
 
44
45
  ## Code of Conduct
45
46
 
46
- Everyone interacting in the <%= config[:constant_name] %> projects codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/<%= config[:github_username] %>/<%= config[:name] %>/blob/master/CODE_OF_CONDUCT.md).
47
+ Everyone interacting in the <%= config[:constant_name] %> project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/<%= config[:github_username] %>/<%= config[:name] %>/blob/master/CODE_OF_CONDUCT.md).
47
48
  <% end -%>
@@ -1,10 +1,4 @@
1
- <%- if RUBY_VERSION < "2.0.0" -%>
2
- # coding: utf-8
3
- <%- end -%>
4
-
5
- lib = File.expand_path("../lib", __FILE__)
6
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
7
- require "<%= config[:namespaced_path] %>/version"
1
+ require_relative 'lib/<%=config[:namespaced_path]%>/version'
8
2
 
9
3
  Gem::Specification.new do |spec|
10
4
  spec.name = <%= config[:name].inspect %>
@@ -18,19 +12,13 @@ Gem::Specification.new do |spec|
18
12
  <%- if config[:mit] -%>
19
13
  spec.license = "MIT"
20
14
  <%- end -%>
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
21
16
 
22
- # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
23
- # to allow pushing to a single host or delete this section to allow pushing to any host.
24
- if spec.respond_to?(:metadata)
25
- spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
17
+ spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
26
18
 
27
- spec.metadata["homepage_uri"] = spec.homepage
28
- spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
29
- spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
30
- else
31
- raise "RubyGems 2.0 or newer is required to protect against " \
32
- "public gem pushes."
33
- end
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
21
+ spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
34
22
 
35
23
  # Specify which files should be added to the gem when it is released.
36
24
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -43,13 +31,4 @@ Gem::Specification.new do |spec|
43
31
  <%- if config[:ext] -%>
44
32
  spec.extensions = ["ext/<%= config[:underscored_name] %>/extconf.rb"]
45
33
  <%- end -%>
46
-
47
- spec.add_development_dependency "bundler", "~> <%= config[:bundler_version] %>"
48
- spec.add_development_dependency "rake", "~> 10.0"
49
- <%- if config[:ext] -%>
50
- spec.add_development_dependency "rake-compiler"
51
- <%- end -%>
52
- <%- if config[:test] -%>
53
- spec.add_development_dependency "<%= config[:test] %>", "~> <%= config[:test_framework_version] %>"
54
- <%- end -%>
55
34
  end
@@ -1,4 +1,4 @@
1
- $LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
1
+ $LOAD_PATH.unshift File.expand_path("../lib", __dir__)
2
2
  require "<%= config[:namespaced_path] %>"
3
3
 
4
4
  require "minitest/autorun"
@@ -1,5 +1,4 @@
1
1
  ---
2
- sudo: false
3
2
  language: ruby
4
3
  cache: bundler
5
4
  rvm:
@@ -2,8 +2,8 @@
2
2
 
3
3
  module Bundler
4
4
  module UI
5
- autoload :RGProxy, "bundler/ui/rg_proxy"
6
- autoload :Shell, "bundler/ui/shell"
7
- autoload :Silent, "bundler/ui/silent"
5
+ autoload :RGProxy, File.expand_path("ui/rg_proxy", __dir__)
6
+ autoload :Shell, File.expand_path("ui/shell", __dir__)
7
+ autoload :Silent, File.expand_path("ui/silent", __dir__)
8
8
  end
9
9
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/ui"
3
+ require_relative "../ui"
4
4
  require "rubygems/user_interaction"
5
5
 
6
6
  module Bundler
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "bundler/vendored_thor"
3
+ require_relative "../vendored_thor"
4
4
 
5
5
  module Bundler
6
6
  module UI
@@ -10,9 +10,7 @@ module Bundler
10
10
  attr_writer :shell
11
11
 
12
12
  def initialize(options = {})
13
- if options["no-color"] || !$stdout.tty?
14
- Thor::Base.shell = Thor::Shell::Basic
15
- end
13
+ Thor::Base.shell = options["no-color"] ? Thor::Shell::Basic : nil
16
14
  @shell = Thor::Base.shell.new
17
15
  @level = ENV["DEBUG"] ? "debug" : "info"
18
16
  @warning_history = []
@@ -35,14 +33,12 @@ module Bundler
35
33
  return if @warning_history.include? msg
36
34
  @warning_history << msg
37
35
 
38
- return tell_err(msg, :yellow, newline) if Bundler.feature_flag.error_on_stderr?
39
- tell_me(msg, :yellow, newline)
36
+ tell_err(msg, :yellow, newline)
40
37
  end
41
38
 
42
39
  def error(msg, newline = nil)
43
40
  return unless level("error")
44
- return tell_err(msg, :red, newline) if Bundler.feature_flag.error_on_stderr?
45
- tell_me(msg, :red, newline)
41
+ tell_err(msg, :red, newline)
46
42
  end
47
43
 
48
44
  def debug(msg, newline = nil)
@@ -0,0 +1,161 @@
1
+ require_relative 'connection_pool/version'
2
+ require_relative 'connection_pool/timed_stack'
3
+
4
+
5
+ # Generic connection pool class for e.g. sharing a limited number of network connections
6
+ # among many threads. Note: Connections are lazily created.
7
+ #
8
+ # Example usage with block (faster):
9
+ #
10
+ # @pool = Bundler::ConnectionPool.new { Redis.new }
11
+ #
12
+ # @pool.with do |redis|
13
+ # redis.lpop('my-list') if redis.llen('my-list') > 0
14
+ # end
15
+ #
16
+ # Using optional timeout override (for that single invocation)
17
+ #
18
+ # @pool.with(timeout: 2.0) do |redis|
19
+ # redis.lpop('my-list') if redis.llen('my-list') > 0
20
+ # end
21
+ #
22
+ # Example usage replacing an existing connection (slower):
23
+ #
24
+ # $redis = Bundler::ConnectionPool.wrap { Redis.new }
25
+ #
26
+ # def do_work
27
+ # $redis.lpop('my-list') if $redis.llen('my-list') > 0
28
+ # end
29
+ #
30
+ # Accepts the following options:
31
+ # - :size - number of connections to pool, defaults to 5
32
+ # - :timeout - amount of time to wait for a connection if none currently available, defaults to 5 seconds
33
+ #
34
+ class Bundler::ConnectionPool
35
+ DEFAULTS = {size: 5, timeout: 5}
36
+
37
+ class Error < RuntimeError
38
+ end
39
+
40
+ def self.wrap(options, &block)
41
+ Wrapper.new(options, &block)
42
+ end
43
+
44
+ def initialize(options = {}, &block)
45
+ raise ArgumentError, 'Connection pool requires a block' unless block
46
+
47
+ options = DEFAULTS.merge(options)
48
+
49
+ @size = options.fetch(:size)
50
+ @timeout = options.fetch(:timeout)
51
+
52
+ @available = TimedStack.new(@size, &block)
53
+ @key = :"current-#{@available.object_id}"
54
+ @key_count = :"current-#{@available.object_id}-count"
55
+ end
56
+
57
+ if Thread.respond_to?(:handle_interrupt)
58
+
59
+ # MRI
60
+ def with(options = {})
61
+ Thread.handle_interrupt(Exception => :never) do
62
+ conn = checkout(options)
63
+ begin
64
+ Thread.handle_interrupt(Exception => :immediate) do
65
+ yield conn
66
+ end
67
+ ensure
68
+ checkin
69
+ end
70
+ end
71
+ end
72
+
73
+ else
74
+
75
+ # jruby 1.7.x
76
+ def with(options = {})
77
+ conn = checkout(options)
78
+ begin
79
+ yield conn
80
+ ensure
81
+ checkin
82
+ end
83
+ end
84
+
85
+ end
86
+
87
+ def checkout(options = {})
88
+ if ::Thread.current[@key]
89
+ ::Thread.current[@key_count]+= 1
90
+ ::Thread.current[@key]
91
+ else
92
+ ::Thread.current[@key_count]= 1
93
+ ::Thread.current[@key]= @available.pop(options[:timeout] || @timeout)
94
+ end
95
+ end
96
+
97
+ def checkin
98
+ if ::Thread.current[@key]
99
+ if ::Thread.current[@key_count] == 1
100
+ @available.push(::Thread.current[@key])
101
+ ::Thread.current[@key]= nil
102
+ else
103
+ ::Thread.current[@key_count]-= 1
104
+ end
105
+ else
106
+ raise Bundler::ConnectionPool::Error, 'no connections are checked out'
107
+ end
108
+
109
+ nil
110
+ end
111
+
112
+ def shutdown(&block)
113
+ @available.shutdown(&block)
114
+ end
115
+
116
+ # Size of this connection pool
117
+ def size
118
+ @size
119
+ end
120
+
121
+ # Number of pool entries available for checkout at this instant.
122
+ def available
123
+ @available.length
124
+ end
125
+
126
+ private
127
+
128
+ class Wrapper < ::BasicObject
129
+ METHODS = [:with, :pool_shutdown]
130
+
131
+ def initialize(options = {}, &block)
132
+ @pool = options.fetch(:pool) { ::Bundler::ConnectionPool.new(options, &block) }
133
+ end
134
+
135
+ def with(&block)
136
+ @pool.with(&block)
137
+ end
138
+
139
+ def pool_shutdown(&block)
140
+ @pool.shutdown(&block)
141
+ end
142
+
143
+ def pool_size
144
+ @pool.size
145
+ end
146
+
147
+ def pool_available
148
+ @pool.available
149
+ end
150
+
151
+ def respond_to?(id, *args)
152
+ METHODS.include?(id) || with { |c| c.respond_to?(id, *args) }
153
+ end
154
+
155
+ def method_missing(name, *args, &block)
156
+ with do |connection|
157
+ connection.send(name, *args, &block)
158
+ end
159
+ end
160
+ end
161
+ end