bundler 2.7.2 → 4.0.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +990 -917
- data/README.md +4 -4
- data/bundler.gemspec +3 -3
- data/lib/bundler/build_metadata.rb +2 -2
- data/lib/bundler/capistrano.rb +1 -19
- data/lib/bundler/cli/cache.rb +1 -11
- data/lib/bundler/cli/common.rb +20 -3
- data/lib/bundler/cli/config.rb +1 -2
- data/lib/bundler/cli/console.rb +5 -0
- data/lib/bundler/cli/exec.rb +29 -4
- data/lib/bundler/cli/gem.rb +19 -33
- data/lib/bundler/cli/install.rb +7 -82
- data/lib/bundler/cli/issue.rb +2 -2
- data/lib/bundler/cli/list.rb +33 -2
- data/lib/bundler/cli/plugin.rb +5 -1
- data/lib/bundler/cli/show.rb +1 -1
- data/lib/bundler/cli/update.rb +3 -3
- data/lib/bundler/cli.rb +75 -83
- data/lib/bundler/compact_index_client.rb +0 -1
- data/lib/bundler/current_ruby.rb +3 -15
- data/lib/bundler/definition.rb +45 -35
- data/lib/bundler/deployment.rb +1 -64
- data/lib/bundler/digest.rb +1 -1
- data/lib/bundler/dsl.rb +13 -35
- data/lib/bundler/endpoint_specification.rb +0 -22
- data/lib/bundler/errors.rb +1 -5
- data/lib/bundler/feature_flag.rb +0 -33
- data/lib/bundler/fetcher/compact_index.rb +1 -1
- data/lib/bundler/friendly_errors.rb +2 -2
- data/lib/bundler/index.rb +0 -7
- data/lib/bundler/inline.rb +1 -1
- data/lib/bundler/installer/gem_installer.rb +0 -11
- data/lib/bundler/installer.rb +0 -6
- data/lib/bundler/lockfile_generator.rb +1 -1
- data/lib/bundler/lockfile_parser.rb +2 -12
- data/lib/bundler/man/bundle-add.1 +1 -1
- data/lib/bundler/man/bundle-binstubs.1 +3 -6
- data/lib/bundler/man/bundle-binstubs.1.ronn +4 -6
- data/lib/bundler/man/bundle-cache.1 +2 -14
- data/lib/bundler/man/bundle-cache.1.ronn +1 -14
- data/lib/bundler/man/bundle-check.1 +2 -5
- data/lib/bundler/man/bundle-check.1.ronn +0 -5
- data/lib/bundler/man/bundle-clean.1 +1 -1
- data/lib/bundler/man/bundle-config.1 +6 -33
- data/lib/bundler/man/bundle-config.1.ronn +20 -55
- data/lib/bundler/man/bundle-console.1 +1 -1
- data/lib/bundler/man/bundle-doctor.1 +1 -1
- data/lib/bundler/man/bundle-env.1 +1 -1
- data/lib/bundler/man/bundle-exec.1 +2 -5
- data/lib/bundler/man/bundle-exec.1.ronn +1 -5
- data/lib/bundler/man/bundle-fund.1 +1 -1
- data/lib/bundler/man/bundle-gem.1 +3 -6
- data/lib/bundler/man/bundle-gem.1.ronn +2 -5
- data/lib/bundler/man/bundle-help.1 +1 -1
- data/lib/bundler/man/bundle-info.1 +1 -1
- data/lib/bundler/man/bundle-init.1 +1 -1
- data/lib/bundler/man/bundle-install.1 +8 -59
- data/lib/bundler/man/bundle-install.1.ronn +12 -107
- data/lib/bundler/man/bundle-issue.1 +1 -1
- data/lib/bundler/man/bundle-licenses.1 +1 -1
- data/lib/bundler/man/bundle-list.1 +6 -1
- data/lib/bundler/man/bundle-list.1.ronn +5 -0
- data/lib/bundler/man/bundle-lock.1 +1 -1
- data/lib/bundler/man/bundle-open.1 +1 -1
- data/lib/bundler/man/bundle-outdated.1 +1 -1
- data/lib/bundler/man/bundle-platform.1 +1 -1
- data/lib/bundler/man/bundle-plugin.1 +2 -9
- data/lib/bundler/man/bundle-plugin.1.ronn +0 -8
- data/lib/bundler/man/bundle-pristine.1 +1 -1
- data/lib/bundler/man/bundle-remove.1 +2 -8
- data/lib/bundler/man/bundle-remove.1.ronn +1 -8
- data/lib/bundler/man/bundle-show.1 +2 -5
- data/lib/bundler/man/bundle-show.1.ronn +0 -4
- data/lib/bundler/man/bundle-update.1 +1 -1
- data/lib/bundler/man/bundle-version.1 +1 -1
- data/lib/bundler/man/bundle.1 +1 -10
- data/lib/bundler/man/bundle.1.ronn +0 -9
- data/lib/bundler/man/gemfile.5 +1 -1
- data/lib/bundler/man/index.txt +0 -2
- data/lib/bundler/materialization.rb +1 -1
- data/lib/bundler/plugin/installer.rb +0 -10
- data/lib/bundler/plugin/source_list.rb +1 -1
- data/lib/bundler/plugin.rb +1 -1
- data/lib/bundler/resolver.rb +1 -1
- data/lib/bundler/ruby_dsl.rb +2 -0
- data/lib/bundler/ruby_version.rb +1 -3
- data/lib/bundler/rubygems_ext.rb +1 -1
- data/lib/bundler/rubygems_gem_installer.rb +1 -1
- data/lib/bundler/rubygems_integration.rb +1 -5
- data/lib/bundler/self_manager.rb +1 -1
- data/lib/bundler/settings.rb +7 -26
- data/lib/bundler/shared_helpers.rb +8 -20
- data/lib/bundler/source/git/git_proxy.rb +3 -11
- data/lib/bundler/source/git.rb +2 -3
- data/lib/bundler/source/path.rb +3 -7
- data/lib/bundler/source/rubygems.rb +11 -17
- data/lib/bundler/source.rb +1 -1
- data/lib/bundler/source_list.rb +4 -45
- data/lib/bundler/source_map.rb +2 -5
- data/lib/bundler/spec_set.rb +6 -15
- data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +7 -129
- data/lib/bundler/templates/newgem/circleci/config.yml.tt +12 -0
- data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +1 -1
- data/lib/bundler/templates/newgem/ext/newgem/extconf-go.rb.tt +11 -0
- data/lib/bundler/templates/newgem/ext/newgem/go.mod.tt +5 -0
- data/lib/bundler/templates/newgem/ext/newgem/newgem-go.c.tt +2 -0
- data/lib/bundler/templates/newgem/ext/newgem/newgem.go.tt +31 -0
- data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +6 -0
- data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +9 -0
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +4 -1
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +26 -23
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
- data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +50 -6
- data/lib/bundler/vendor/fileutils/lib/fileutils.rb +57 -52
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +5 -2
- data/lib/bundler/vendor/thor/lib/thor/runner.rb +1 -1
- data/lib/bundler/vendor/uri/lib/uri/common.rb +57 -15
- data/lib/bundler/vendor/uri/lib/uri/file.rb +1 -1
- data/lib/bundler/vendor/uri/lib/uri/generic.rb +34 -21
- data/lib/bundler/vendor/uri/lib/uri/http.rb +12 -0
- data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +9 -8
- data/lib/bundler/vendor/uri/lib/uri/version.rb +2 -2
- data/lib/bundler/version.rb +1 -1
- data/lib/bundler/vlad.rb +1 -14
- data/lib/bundler.rb +6 -28
- metadata +9 -13
- data/lib/bundler/cli/inject.rb +0 -60
- data/lib/bundler/cli/viz.rb +0 -31
- data/lib/bundler/graph.rb +0 -152
- data/lib/bundler/man/bundle-inject.1 +0 -31
- data/lib/bundler/man/bundle-inject.1.ronn +0 -32
- data/lib/bundler/man/bundle-viz.1 +0 -30
- data/lib/bundler/man/bundle-viz.1.ronn +0 -36
- data/lib/bundler/similarity_detector.rb +0 -63
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
package main
|
|
2
|
+
|
|
3
|
+
/*
|
|
4
|
+
#include "<%= config[:underscored_name] %>.h"
|
|
5
|
+
|
|
6
|
+
VALUE rb_<%= config[:underscored_name] %>_sum(VALUE self, VALUE a, VALUE b);
|
|
7
|
+
*/
|
|
8
|
+
import "C"
|
|
9
|
+
|
|
10
|
+
import (
|
|
11
|
+
"github.com/ruby-go-gem/go-gem-wrapper/ruby"
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
//export rb_<%= config[:underscored_name] %>_sum
|
|
15
|
+
func rb_<%= config[:underscored_name] %>_sum(_ C.VALUE, a C.VALUE, b C.VALUE) C.VALUE {
|
|
16
|
+
longA := ruby.NUM2LONG(ruby.VALUE(a))
|
|
17
|
+
longB := ruby.NUM2LONG(ruby.VALUE(b))
|
|
18
|
+
|
|
19
|
+
sum := longA + longB
|
|
20
|
+
|
|
21
|
+
return C.VALUE(ruby.LONG2NUM(sum))
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
//export Init_<%= config[:underscored_name] %>
|
|
25
|
+
func Init_<%= config[:underscored_name] %>() {
|
|
26
|
+
rb_m<%= config[:constant_array].join %> := ruby.RbDefineModule(<%= config[:constant_name].inspect %>)
|
|
27
|
+
ruby.RbDefineSingletonMethod(rb_m<%= config[:constant_array].join %>, "sum", C.rb_<%= config[:underscored_name] %>_sum, 2)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
func main() {
|
|
31
|
+
}
|
|
@@ -34,6 +34,12 @@ jobs:
|
|
|
34
34
|
with:
|
|
35
35
|
ruby-version: ${{ matrix.ruby }}
|
|
36
36
|
bundler-cache: true
|
|
37
|
+
<%- end -%>
|
|
38
|
+
<%- if config[:ext] == 'go' -%>
|
|
39
|
+
- name: Setup Go
|
|
40
|
+
uses: actions/setup-go@v5
|
|
41
|
+
with:
|
|
42
|
+
go-version-file: ext/<%= config[:underscored_name] %>/go.mod
|
|
37
43
|
<%- end -%>
|
|
38
44
|
- name: Run the default task
|
|
39
45
|
run: bundle exec rake
|
|
@@ -5,6 +5,11 @@ default:
|
|
|
5
5
|
<%- if config[:ext] == 'rust' -%>
|
|
6
6
|
- apt-get update && apt-get install -y clang
|
|
7
7
|
- gem update --system '<%= ::Gem.rubygems_version %>'
|
|
8
|
+
<%- end -%>
|
|
9
|
+
<%- if config[:ext] == 'go' -%>
|
|
10
|
+
- wget https://go.dev/dl/go$GO_VERSION.linux-amd64.tar.gz -O /tmp/go.tar.gz
|
|
11
|
+
- tar -C /usr/local -xzf /tmp/go.tar.gz
|
|
12
|
+
- export PATH=/usr/local/go/bin:$PATH
|
|
8
13
|
<%- end -%>
|
|
9
14
|
- gem install bundler -v <%= Bundler::VERSION %>
|
|
10
15
|
- bundle install
|
|
@@ -13,6 +18,10 @@ example_job:
|
|
|
13
18
|
<%- if config[:ext] == 'rust' -%>
|
|
14
19
|
variables:
|
|
15
20
|
RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN: 'true'
|
|
21
|
+
<%- end -%>
|
|
22
|
+
<%- if config[:ext] == 'go' -%>
|
|
23
|
+
variables:
|
|
24
|
+
GO_VERSION: '1.23.0'
|
|
16
25
|
<%- end -%>
|
|
17
26
|
script:
|
|
18
27
|
- bundle exec rake
|
|
@@ -38,7 +38,7 @@ Gem::Specification.new do |spec|
|
|
|
38
38
|
spec.bindir = "exe"
|
|
39
39
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
|
40
40
|
spec.require_paths = ["lib"]
|
|
41
|
-
<%- if
|
|
41
|
+
<%- if %w(c rust go).include?(config[:ext]) -%>
|
|
42
42
|
spec.extensions = ["ext/<%= config[:underscored_name] %>/extconf.rb"]
|
|
43
43
|
<%- end -%>
|
|
44
44
|
|
|
@@ -47,6 +47,9 @@ Gem::Specification.new do |spec|
|
|
|
47
47
|
<%- if config[:ext] == 'rust' -%>
|
|
48
48
|
spec.add_dependency "rb_sys", "~> 0.9.91"
|
|
49
49
|
<%- end -%>
|
|
50
|
+
<%- if config[:ext] == 'go' -%>
|
|
51
|
+
spec.add_dependency "go_gem", "~> 0.2"
|
|
52
|
+
<%- end -%>
|
|
50
53
|
|
|
51
54
|
# For more information and examples about making a new gem, check out our
|
|
52
55
|
# guide at: https://bundler.io/guides/creating_gem.html
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
##
|
|
2
2
|
# The TimedStack manages a pool of homogeneous connections (or any resource
|
|
3
|
-
# you wish to manage).
|
|
3
|
+
# you wish to manage). Connections are created lazily up to a given maximum
|
|
4
4
|
# number.
|
|
5
|
-
|
|
5
|
+
#
|
|
6
6
|
# Examples:
|
|
7
7
|
#
|
|
8
8
|
# ts = TimedStack.new(1) { MyConnection.new }
|
|
@@ -16,14 +16,12 @@
|
|
|
16
16
|
# conn = ts.pop
|
|
17
17
|
# ts.pop timeout: 5
|
|
18
18
|
# #=> raises Bundler::ConnectionPool::TimeoutError after 5 seconds
|
|
19
|
-
|
|
20
19
|
class Bundler::ConnectionPool::TimedStack
|
|
21
20
|
attr_reader :max
|
|
22
21
|
|
|
23
22
|
##
|
|
24
23
|
# Creates a new pool with +size+ connections that are created from the given
|
|
25
24
|
# +block+.
|
|
26
|
-
|
|
27
25
|
def initialize(size = 0, &block)
|
|
28
26
|
@create_block = block
|
|
29
27
|
@created = 0
|
|
@@ -35,9 +33,8 @@ class Bundler::ConnectionPool::TimedStack
|
|
|
35
33
|
end
|
|
36
34
|
|
|
37
35
|
##
|
|
38
|
-
# Returns +obj+ to the stack.
|
|
36
|
+
# Returns +obj+ to the stack. +options+ is ignored in TimedStack but may be
|
|
39
37
|
# used by subclasses that extend TimedStack.
|
|
40
|
-
|
|
41
38
|
def push(obj, options = {})
|
|
42
39
|
@mutex.synchronize do
|
|
43
40
|
if @shutdown_block
|
|
@@ -53,14 +50,13 @@ class Bundler::ConnectionPool::TimedStack
|
|
|
53
50
|
alias_method :<<, :push
|
|
54
51
|
|
|
55
52
|
##
|
|
56
|
-
# Retrieves a connection from the stack.
|
|
57
|
-
# immediately returned.
|
|
53
|
+
# Retrieves a connection from the stack. If a connection is available it is
|
|
54
|
+
# immediately returned. If no connection is available within the given
|
|
58
55
|
# timeout a Bundler::ConnectionPool::TimeoutError is raised.
|
|
59
56
|
#
|
|
60
57
|
# +:timeout+ is the only checked entry in +options+ and is preferred over
|
|
61
|
-
# the +timeout+ argument (which will be removed in a future release).
|
|
58
|
+
# the +timeout+ argument (which will be removed in a future release). Other
|
|
62
59
|
# options may be used by subclasses that extend TimedStack.
|
|
63
|
-
|
|
64
60
|
def pop(timeout = 0.5, options = {})
|
|
65
61
|
options, timeout = timeout, 0.5 if Hash === timeout
|
|
66
62
|
timeout = options.fetch :timeout, timeout
|
|
@@ -69,7 +65,9 @@ class Bundler::ConnectionPool::TimedStack
|
|
|
69
65
|
@mutex.synchronize do
|
|
70
66
|
loop do
|
|
71
67
|
raise Bundler::ConnectionPool::PoolShuttingDownError if @shutdown_block
|
|
72
|
-
|
|
68
|
+
if (conn = try_fetch_connection(options))
|
|
69
|
+
return conn
|
|
70
|
+
end
|
|
73
71
|
|
|
74
72
|
connection = try_create(options)
|
|
75
73
|
return connection if connection
|
|
@@ -86,7 +84,6 @@ class Bundler::ConnectionPool::TimedStack
|
|
|
86
84
|
# removing it from the pool. Attempting to checkout a connection after
|
|
87
85
|
# shutdown will raise +Bundler::ConnectionPool::PoolShuttingDownError+ unless
|
|
88
86
|
# +:reload+ is +true+.
|
|
89
|
-
|
|
90
87
|
def shutdown(reload: false, &block)
|
|
91
88
|
raise ArgumentError, "shutdown must receive a block" unless block
|
|
92
89
|
|
|
@@ -121,14 +118,12 @@ class Bundler::ConnectionPool::TimedStack
|
|
|
121
118
|
|
|
122
119
|
##
|
|
123
120
|
# Returns +true+ if there are no available connections.
|
|
124
|
-
|
|
125
121
|
def empty?
|
|
126
122
|
(@created - @que.length) >= @max
|
|
127
123
|
end
|
|
128
124
|
|
|
129
125
|
##
|
|
130
126
|
# The number of connections available on the stack.
|
|
131
|
-
|
|
132
127
|
def length
|
|
133
128
|
@max - @created + @que.length
|
|
134
129
|
end
|
|
@@ -139,6 +134,12 @@ class Bundler::ConnectionPool::TimedStack
|
|
|
139
134
|
@que.length
|
|
140
135
|
end
|
|
141
136
|
|
|
137
|
+
##
|
|
138
|
+
# Reduce the created count
|
|
139
|
+
def decrement_created
|
|
140
|
+
@created -= 1 unless @created == 0
|
|
141
|
+
end
|
|
142
|
+
|
|
142
143
|
private
|
|
143
144
|
|
|
144
145
|
def current_time
|
|
@@ -148,8 +149,17 @@ class Bundler::ConnectionPool::TimedStack
|
|
|
148
149
|
##
|
|
149
150
|
# This is an extension point for TimedStack and is called with a mutex.
|
|
150
151
|
#
|
|
151
|
-
# This method must returns
|
|
152
|
+
# This method must returns a connection from the stack if one exists. Allows
|
|
153
|
+
# subclasses with expensive match/search algorithms to avoid double-handling
|
|
154
|
+
# their stack.
|
|
155
|
+
def try_fetch_connection(options = nil)
|
|
156
|
+
connection_stored?(options) && fetch_connection(options)
|
|
157
|
+
end
|
|
152
158
|
|
|
159
|
+
##
|
|
160
|
+
# This is an extension point for TimedStack and is called with a mutex.
|
|
161
|
+
#
|
|
162
|
+
# This method must returns true if a connection is available on the stack.
|
|
153
163
|
def connection_stored?(options = nil)
|
|
154
164
|
!@que.empty?
|
|
155
165
|
end
|
|
@@ -158,7 +168,6 @@ class Bundler::ConnectionPool::TimedStack
|
|
|
158
168
|
# This is an extension point for TimedStack and is called with a mutex.
|
|
159
169
|
#
|
|
160
170
|
# This method must return a connection from the stack.
|
|
161
|
-
|
|
162
171
|
def fetch_connection(options = nil)
|
|
163
172
|
@que.pop&.first
|
|
164
173
|
end
|
|
@@ -167,10 +176,8 @@ class Bundler::ConnectionPool::TimedStack
|
|
|
167
176
|
# This is an extension point for TimedStack and is called with a mutex.
|
|
168
177
|
#
|
|
169
178
|
# This method must shut down all connections on the stack.
|
|
170
|
-
|
|
171
179
|
def shutdown_connections(options = nil)
|
|
172
|
-
while
|
|
173
|
-
conn = fetch_connection(options)
|
|
180
|
+
while (conn = try_fetch_connection(options))
|
|
174
181
|
@created -= 1 unless @created == 0
|
|
175
182
|
@shutdown_block.call(conn)
|
|
176
183
|
end
|
|
@@ -181,7 +188,6 @@ class Bundler::ConnectionPool::TimedStack
|
|
|
181
188
|
#
|
|
182
189
|
# This method returns the oldest idle connection if it has been idle for more than idle_seconds.
|
|
183
190
|
# This requires that the stack is kept in order of checked in time (oldest first).
|
|
184
|
-
|
|
185
191
|
def reserve_idle_connection(idle_seconds)
|
|
186
192
|
return unless idle_connections?(idle_seconds)
|
|
187
193
|
|
|
@@ -194,7 +200,6 @@ class Bundler::ConnectionPool::TimedStack
|
|
|
194
200
|
# This is an extension point for TimedStack and is called with a mutex.
|
|
195
201
|
#
|
|
196
202
|
# Returns true if the first connection in the stack has been idle for more than idle_seconds
|
|
197
|
-
|
|
198
203
|
def idle_connections?(idle_seconds)
|
|
199
204
|
connection_stored? && (current_time - @que.first.last > idle_seconds)
|
|
200
205
|
end
|
|
@@ -203,7 +208,6 @@ class Bundler::ConnectionPool::TimedStack
|
|
|
203
208
|
# This is an extension point for TimedStack and is called with a mutex.
|
|
204
209
|
#
|
|
205
210
|
# This method must return +obj+ to the stack.
|
|
206
|
-
|
|
207
211
|
def store_connection(obj, options = nil)
|
|
208
212
|
@que.push [obj, current_time]
|
|
209
213
|
end
|
|
@@ -213,7 +217,6 @@ class Bundler::ConnectionPool::TimedStack
|
|
|
213
217
|
#
|
|
214
218
|
# This method must create a connection if and only if the total number of
|
|
215
219
|
# connections allowed has not been met.
|
|
216
|
-
|
|
217
220
|
def try_create(options = nil)
|
|
218
221
|
unless @created == @max
|
|
219
222
|
object = @create_block.call
|
|
@@ -39,7 +39,7 @@ end
|
|
|
39
39
|
# - :auto_reload_after_fork - automatically drop all connections after fork, defaults to true
|
|
40
40
|
#
|
|
41
41
|
class Bundler::ConnectionPool
|
|
42
|
-
DEFAULTS = {size: 5, timeout: 5, auto_reload_after_fork: true}
|
|
42
|
+
DEFAULTS = {size: 5, timeout: 5, auto_reload_after_fork: true}.freeze
|
|
43
43
|
|
|
44
44
|
def self.wrap(options, &block)
|
|
45
45
|
Wrapper.new(options, &block)
|
|
@@ -99,7 +99,8 @@ class Bundler::ConnectionPool
|
|
|
99
99
|
@available = TimedStack.new(@size, &block)
|
|
100
100
|
@key = :"pool-#{@available.object_id}"
|
|
101
101
|
@key_count = :"pool-#{@available.object_id}-count"
|
|
102
|
-
|
|
102
|
+
@discard_key = :"pool-#{@available.object_id}-discard"
|
|
103
|
+
INSTANCES[self] = self if @auto_reload_after_fork && INSTANCES
|
|
103
104
|
end
|
|
104
105
|
|
|
105
106
|
def with(options = {})
|
|
@@ -116,20 +117,65 @@ class Bundler::ConnectionPool
|
|
|
116
117
|
end
|
|
117
118
|
alias_method :then, :with
|
|
118
119
|
|
|
120
|
+
##
|
|
121
|
+
# Marks the current thread's checked-out connection for discard.
|
|
122
|
+
#
|
|
123
|
+
# When a connection is marked for discard, it will not be returned to the pool
|
|
124
|
+
# when checked in. Instead, the connection will be discarded.
|
|
125
|
+
# This is useful when a connection has become invalid or corrupted
|
|
126
|
+
# and should not be reused.
|
|
127
|
+
#
|
|
128
|
+
# Takes an optional block that will be called with the connection to be discarded.
|
|
129
|
+
# The block should perform any necessary clean-up on the connection.
|
|
130
|
+
#
|
|
131
|
+
# @yield [conn]
|
|
132
|
+
# @yieldparam conn [Object] The connection to be discarded.
|
|
133
|
+
# @yieldreturn [void]
|
|
134
|
+
#
|
|
135
|
+
#
|
|
136
|
+
# Note: This only affects the connection currently checked out by the calling thread.
|
|
137
|
+
# The connection will be discarded when +checkin+ is called.
|
|
138
|
+
#
|
|
139
|
+
# @return [void]
|
|
140
|
+
#
|
|
141
|
+
# @example
|
|
142
|
+
# pool.with do |conn|
|
|
143
|
+
# begin
|
|
144
|
+
# conn.execute("SELECT 1")
|
|
145
|
+
# rescue SomeConnectionError
|
|
146
|
+
# pool.discard_current_connection # Mark connection as bad
|
|
147
|
+
# raise
|
|
148
|
+
# end
|
|
149
|
+
# end
|
|
150
|
+
def discard_current_connection(&block)
|
|
151
|
+
::Thread.current[@discard_key] = block || proc { |conn| conn }
|
|
152
|
+
end
|
|
153
|
+
|
|
119
154
|
def checkout(options = {})
|
|
120
155
|
if ::Thread.current[@key]
|
|
121
156
|
::Thread.current[@key_count] += 1
|
|
122
157
|
::Thread.current[@key]
|
|
123
158
|
else
|
|
124
159
|
::Thread.current[@key_count] = 1
|
|
125
|
-
::Thread.current[@key] = @available.pop(options[:timeout] || @timeout)
|
|
160
|
+
::Thread.current[@key] = @available.pop(options[:timeout] || @timeout, options)
|
|
126
161
|
end
|
|
127
162
|
end
|
|
128
163
|
|
|
129
164
|
def checkin(force: false)
|
|
130
165
|
if ::Thread.current[@key]
|
|
131
166
|
if ::Thread.current[@key_count] == 1 || force
|
|
132
|
-
|
|
167
|
+
if ::Thread.current[@discard_key]
|
|
168
|
+
begin
|
|
169
|
+
@available.decrement_created
|
|
170
|
+
::Thread.current[@discard_key].call(::Thread.current[@key])
|
|
171
|
+
rescue
|
|
172
|
+
nil
|
|
173
|
+
ensure
|
|
174
|
+
::Thread.current[@discard_key] = nil
|
|
175
|
+
end
|
|
176
|
+
else
|
|
177
|
+
@available.push(::Thread.current[@key])
|
|
178
|
+
end
|
|
133
179
|
::Thread.current[@key] = nil
|
|
134
180
|
::Thread.current[@key_count] = nil
|
|
135
181
|
else
|
|
@@ -146,7 +192,6 @@ class Bundler::ConnectionPool
|
|
|
146
192
|
# Shuts down the Bundler::ConnectionPool by passing each connection to +block+ and
|
|
147
193
|
# then removing it from the pool. Attempting to checkout a connection after
|
|
148
194
|
# shutdown will raise +Bundler::ConnectionPool::PoolShuttingDownError+.
|
|
149
|
-
|
|
150
195
|
def shutdown(&block)
|
|
151
196
|
@available.shutdown(&block)
|
|
152
197
|
end
|
|
@@ -155,7 +200,6 @@ class Bundler::ConnectionPool
|
|
|
155
200
|
# Reloads the Bundler::ConnectionPool by passing each connection to +block+ and then
|
|
156
201
|
# removing it the pool. Subsequent checkouts will create new connections as
|
|
157
202
|
# needed.
|
|
158
|
-
|
|
159
203
|
def reload(&block)
|
|
160
204
|
@available.shutdown(reload: true, &block)
|
|
161
205
|
end
|
|
@@ -181,7 +181,7 @@ end
|
|
|
181
181
|
#
|
|
182
182
|
module Bundler::FileUtils
|
|
183
183
|
# The version number.
|
|
184
|
-
VERSION = "1.
|
|
184
|
+
VERSION = "1.8.0"
|
|
185
185
|
|
|
186
186
|
def self.private_module_function(name) #:nodoc:
|
|
187
187
|
module_function name
|
|
@@ -706,11 +706,12 @@ module Bundler::FileUtils
|
|
|
706
706
|
#
|
|
707
707
|
def ln_s(src, dest, force: nil, relative: false, target_directory: true, noop: nil, verbose: nil)
|
|
708
708
|
if relative
|
|
709
|
-
return ln_sr(src, dest, force: force, noop: noop, verbose: verbose)
|
|
709
|
+
return ln_sr(src, dest, force: force, target_directory: target_directory, noop: noop, verbose: verbose)
|
|
710
710
|
end
|
|
711
|
-
fu_output_message "ln -s#{force ? 'f' : ''}
|
|
711
|
+
fu_output_message "ln -s#{force ? 'f' : ''}#{
|
|
712
|
+
target_directory ? '' : 'T'} #{[src,dest].flatten.join ' '}" if verbose
|
|
712
713
|
return if noop
|
|
713
|
-
fu_each_src_dest0(src, dest) do |s,d|
|
|
714
|
+
fu_each_src_dest0(src, dest, target_directory) do |s,d|
|
|
714
715
|
remove_file d, true if force
|
|
715
716
|
File.symlink s, d
|
|
716
717
|
end
|
|
@@ -730,42 +731,37 @@ module Bundler::FileUtils
|
|
|
730
731
|
# Like Bundler::FileUtils.ln_s, but create links relative to +dest+.
|
|
731
732
|
#
|
|
732
733
|
def ln_sr(src, dest, target_directory: true, force: nil, noop: nil, verbose: nil)
|
|
733
|
-
|
|
734
|
-
dest
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
d = File.join(destdirs = dest, File.basename(s))
|
|
734
|
+
cmd = "ln -s#{force ? 'f' : ''}#{target_directory ? '' : 'T'}" if verbose
|
|
735
|
+
fu_each_src_dest0(src, dest, target_directory) do |s,d|
|
|
736
|
+
if target_directory
|
|
737
|
+
parent = File.dirname(d)
|
|
738
|
+
destdirs = fu_split_path(parent)
|
|
739
|
+
real_ddirs = fu_split_path(File.realpath(parent))
|
|
740
740
|
else
|
|
741
|
-
destdirs
|
|
741
|
+
destdirs ||= fu_split_path(dest)
|
|
742
|
+
real_ddirs ||= fu_split_path(File.realdirpath(dest))
|
|
742
743
|
end
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
744
|
+
srcdirs = fu_split_path(s)
|
|
745
|
+
i = fu_common_components(srcdirs, destdirs)
|
|
746
|
+
n = destdirs.size - i
|
|
747
|
+
n -= 1 unless target_directory
|
|
748
|
+
link1 = fu_clean_components(*Array.new([n, 0].max, '..'), *srcdirs[i..-1])
|
|
749
|
+
begin
|
|
750
|
+
real_sdirs = fu_split_path(File.realdirpath(s)) rescue nil
|
|
751
|
+
rescue
|
|
748
752
|
else
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
end
|
|
755
|
-
s = File.join(*base, *srcdirs)
|
|
753
|
+
i = fu_common_components(real_sdirs, real_ddirs)
|
|
754
|
+
n = real_ddirs.size - i
|
|
755
|
+
n -= 1 unless target_directory
|
|
756
|
+
link2 = fu_clean_components(*Array.new([n, 0].max, '..'), *real_sdirs[i..-1])
|
|
757
|
+
link1 = link2 if link1.size > link2.size
|
|
756
758
|
end
|
|
757
|
-
|
|
759
|
+
s = File.join(link1)
|
|
760
|
+
fu_output_message [cmd, s, d].flatten.join(' ') if verbose
|
|
758
761
|
next if noop
|
|
759
762
|
remove_file d, true if force
|
|
760
763
|
File.symlink s, d
|
|
761
764
|
end
|
|
762
|
-
case srcs.size
|
|
763
|
-
when 0
|
|
764
|
-
when 1
|
|
765
|
-
link[srcs[0], target_directory && File.directory?(dest)]
|
|
766
|
-
else
|
|
767
|
-
srcs.each(&link)
|
|
768
|
-
end
|
|
769
765
|
end
|
|
770
766
|
module_function :ln_sr
|
|
771
767
|
|
|
@@ -800,13 +796,13 @@ module Bundler::FileUtils
|
|
|
800
796
|
# File.file?('dest1/dir1/t2.txt') # => true
|
|
801
797
|
# File.file?('dest1/dir1/t3.txt') # => true
|
|
802
798
|
#
|
|
803
|
-
#
|
|
799
|
+
# Optional arguments:
|
|
804
800
|
#
|
|
805
|
-
# -
|
|
806
|
-
# -
|
|
801
|
+
# - +dereference_root+ - dereferences +src+ if it is a symbolic link (+false+ by default).
|
|
802
|
+
# - +remove_destination+ - removes +dest+ before creating links (+false+ by default).
|
|
807
803
|
#
|
|
808
804
|
# Raises an exception if +dest+ is the path to an existing file or directory
|
|
809
|
-
# and
|
|
805
|
+
# and optional argument +remove_destination+ is not given.
|
|
810
806
|
#
|
|
811
807
|
# Related: Bundler::FileUtils.ln (has different options).
|
|
812
808
|
#
|
|
@@ -1029,12 +1025,12 @@ module Bundler::FileUtils
|
|
|
1029
1025
|
# directories, and symbolic links;
|
|
1030
1026
|
# other file types (FIFO streams, device files, etc.) are not supported.
|
|
1031
1027
|
#
|
|
1032
|
-
#
|
|
1028
|
+
# Optional arguments:
|
|
1033
1029
|
#
|
|
1034
|
-
# -
|
|
1035
|
-
# follows the link.
|
|
1036
|
-
# -
|
|
1037
|
-
# -
|
|
1030
|
+
# - +dereference_root+ - if +src+ is a symbolic link,
|
|
1031
|
+
# follows the link (+false+ by default).
|
|
1032
|
+
# - +preserve+ - preserves file times (+false+ by default).
|
|
1033
|
+
# - +remove_destination+ - removes +dest+ before copying files (+false+ by default).
|
|
1038
1034
|
#
|
|
1039
1035
|
# Related: {methods for copying}[rdoc-ref:FileUtils@Copying].
|
|
1040
1036
|
#
|
|
@@ -1065,12 +1061,12 @@ module Bundler::FileUtils
|
|
|
1065
1061
|
# Bundler::FileUtils.copy_file('src0.txt', 'dest0.txt')
|
|
1066
1062
|
# File.file?('dest0.txt') # => true
|
|
1067
1063
|
#
|
|
1068
|
-
#
|
|
1064
|
+
# Optional arguments:
|
|
1069
1065
|
#
|
|
1070
|
-
# -
|
|
1071
|
-
#
|
|
1072
|
-
# -
|
|
1073
|
-
# -
|
|
1066
|
+
# - +dereference+ - if +src+ is a symbolic link,
|
|
1067
|
+
# follows the link (+true+ by default).
|
|
1068
|
+
# - +preserve+ - preserves file times (+false+ by default).
|
|
1069
|
+
# - +remove_destination+ - removes +dest+ before copying files (+false+ by default).
|
|
1074
1070
|
#
|
|
1075
1071
|
# Related: {methods for copying}[rdoc-ref:FileUtils@Copying].
|
|
1076
1072
|
#
|
|
@@ -1491,7 +1487,8 @@ module Bundler::FileUtils
|
|
|
1491
1487
|
# Related: {methods for deleting}[rdoc-ref:FileUtils@Deleting].
|
|
1492
1488
|
#
|
|
1493
1489
|
def remove_dir(path, force = false)
|
|
1494
|
-
|
|
1490
|
+
raise Errno::ENOTDIR, path unless force or File.directory?(path)
|
|
1491
|
+
remove_entry path, force
|
|
1495
1492
|
end
|
|
1496
1493
|
module_function :remove_dir
|
|
1497
1494
|
|
|
@@ -2475,6 +2472,10 @@ module Bundler::FileUtils
|
|
|
2475
2472
|
|
|
2476
2473
|
def fu_each_src_dest0(src, dest, target_directory = true) #:nodoc:
|
|
2477
2474
|
if tmp = Array.try_convert(src)
|
|
2475
|
+
unless target_directory or tmp.size <= 1
|
|
2476
|
+
tmp = tmp.map {|f| File.path(f)} # A workaround for RBS
|
|
2477
|
+
raise ArgumentError, "extra target #{tmp}"
|
|
2478
|
+
end
|
|
2478
2479
|
tmp.each do |s|
|
|
2479
2480
|
s = File.path(s)
|
|
2480
2481
|
yield s, (target_directory ? File.join(dest, File.basename(s)) : dest)
|
|
@@ -2509,7 +2510,11 @@ module Bundler::FileUtils
|
|
|
2509
2510
|
path = File.path(path)
|
|
2510
2511
|
list = []
|
|
2511
2512
|
until (parent, base = File.split(path); parent == path or parent == ".")
|
|
2512
|
-
list
|
|
2513
|
+
if base != '..' and list.last == '..' and !(fu_have_symlink? && File.symlink?(path))
|
|
2514
|
+
list.pop
|
|
2515
|
+
else
|
|
2516
|
+
list << base
|
|
2517
|
+
end
|
|
2513
2518
|
path = parent
|
|
2514
2519
|
end
|
|
2515
2520
|
list << path
|
|
@@ -2517,14 +2522,14 @@ module Bundler::FileUtils
|
|
|
2517
2522
|
end
|
|
2518
2523
|
private_module_function :fu_split_path
|
|
2519
2524
|
|
|
2520
|
-
def
|
|
2525
|
+
def fu_common_components(target, base) #:nodoc:
|
|
2521
2526
|
i = 0
|
|
2522
2527
|
while target[i]&.== base[i]
|
|
2523
2528
|
i += 1
|
|
2524
2529
|
end
|
|
2525
|
-
|
|
2530
|
+
i
|
|
2526
2531
|
end
|
|
2527
|
-
private_module_function :
|
|
2532
|
+
private_module_function :fu_common_components
|
|
2528
2533
|
|
|
2529
2534
|
def fu_clean_components(*comp) #:nodoc:
|
|
2530
2535
|
comp.shift while comp.first == "."
|
|
@@ -2534,7 +2539,7 @@ module Bundler::FileUtils
|
|
|
2534
2539
|
while c = comp.shift
|
|
2535
2540
|
if c == ".." and clean.last != ".." and !(fu_have_symlink? && File.symlink?(path))
|
|
2536
2541
|
clean.pop
|
|
2537
|
-
path.
|
|
2542
|
+
path.sub!(%r((?<=\A|/)[^/]+/\z), "")
|
|
2538
2543
|
else
|
|
2539
2544
|
clean << c
|
|
2540
2545
|
path << c << "/"
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
require_relative '../../../../../vendored_net_http'
|
|
2
2
|
require_relative '../../../../../vendored_uri'
|
|
3
|
-
|
|
4
|
-
require 'cgi/
|
|
3
|
+
begin
|
|
4
|
+
require 'cgi/escape'
|
|
5
|
+
rescue LoadError
|
|
6
|
+
require 'cgi/util' # for escaping
|
|
7
|
+
end
|
|
5
8
|
require_relative '../../../../connection_pool/lib/connection_pool'
|
|
6
9
|
|
|
7
10
|
autoload :OpenSSL, 'openssl'
|
|
@@ -2,7 +2,7 @@ require_relative "../thor"
|
|
|
2
2
|
require_relative "group"
|
|
3
3
|
|
|
4
4
|
require "digest/sha2"
|
|
5
|
-
require "pathname"
|
|
5
|
+
require "pathname" unless defined?(Pathname)
|
|
6
6
|
|
|
7
7
|
class Bundler::Thor::Runner < Bundler::Thor #:nodoc:
|
|
8
8
|
map "-T" => :list, "-i" => :install, "-u" => :update, "-v" => :version
|