bundler 2.0.2 → 2.1.0
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +735 -574
- data/LICENSE.md +18 -19
- data/README.md +8 -7
- data/bundler.gemspec +5 -23
- data/exe/bundle +19 -3
- data/lib/bundler.rb +202 -87
- data/lib/bundler/build_metadata.rb +3 -3
- data/lib/bundler/capistrano.rb +5 -5
- data/lib/bundler/cli.rb +179 -143
- data/lib/bundler/cli/add.rb +28 -16
- data/lib/bundler/cli/cache.rb +25 -13
- data/lib/bundler/cli/common.rb +10 -11
- data/lib/bundler/cli/config.rb +161 -86
- data/lib/bundler/cli/console.rb +2 -2
- data/lib/bundler/cli/doctor.rb +4 -4
- data/lib/bundler/cli/exec.rb +15 -18
- data/lib/bundler/cli/gem.rb +5 -5
- data/lib/bundler/cli/info.rb +17 -5
- data/lib/bundler/cli/init.rb +1 -1
- data/lib/bundler/cli/install.rb +3 -3
- data/lib/bundler/cli/issue.rb +1 -1
- data/lib/bundler/cli/open.rb +10 -6
- data/lib/bundler/cli/outdated.rb +85 -81
- data/lib/bundler/cli/plugin.rb +9 -2
- data/lib/bundler/cli/pristine.rb +1 -1
- data/lib/bundler/cli/show.rb +1 -1
- data/lib/bundler/cli/update.rb +31 -11
- data/lib/bundler/compact_index_client.rb +25 -9
- data/lib/bundler/compact_index_client/updater.rb +2 -6
- data/lib/bundler/current_ruby.rb +8 -7
- data/lib/bundler/definition.rb +33 -26
- data/lib/bundler/dependency.rb +16 -4
- data/lib/bundler/deployment.rb +2 -2
- data/lib/bundler/dsl.rb +19 -43
- data/lib/bundler/env.rb +6 -5
- data/lib/bundler/environment_preserver.rb +0 -1
- data/lib/bundler/feature_flag.rb +1 -13
- data/lib/bundler/fetcher.rb +16 -13
- data/lib/bundler/fetcher/compact_index.rb +26 -12
- data/lib/bundler/fetcher/dependency.rb +1 -1
- data/lib/bundler/fetcher/downloader.rb +4 -1
- data/lib/bundler/fetcher/index.rb +5 -3
- data/lib/bundler/friendly_errors.rb +6 -7
- data/lib/bundler/gem_helper.rb +14 -14
- data/lib/bundler/gem_helpers.rb +2 -4
- data/lib/bundler/gem_tasks.rb +1 -1
- data/lib/bundler/gem_version_promoter.rb +3 -3
- data/lib/bundler/graph.rb +2 -2
- data/lib/bundler/injector.rb +3 -1
- data/lib/bundler/inline.rb +40 -30
- data/lib/bundler/installer.rb +7 -14
- data/lib/bundler/installer/gem_installer.rb +5 -1
- data/lib/bundler/installer/parallel_installer.rb +4 -4
- data/lib/bundler/installer/standalone.rb +1 -2
- data/lib/bundler/lazy_specification.rb +2 -3
- data/lib/bundler/lockfile_parser.rb +14 -21
- data/lib/bundler/match_platform.rb +1 -1
- data/lib/bundler/mirror.rb +3 -3
- data/lib/bundler/plugin.rb +29 -18
- data/lib/bundler/plugin/api.rb +1 -1
- data/lib/bundler/plugin/api/source.rb +4 -6
- data/lib/bundler/plugin/index.rb +10 -2
- data/lib/bundler/plugin/installer.rb +28 -15
- data/lib/bundler/psyched_yaml.rb +1 -1
- data/lib/bundler/remote_specification.rb +0 -2
- data/lib/bundler/resolver.rb +72 -24
- data/lib/bundler/resolver/spec_group.rb +3 -2
- data/lib/bundler/retry.rb +2 -2
- data/lib/bundler/ruby_version.rb +4 -19
- data/lib/bundler/rubygems_ext.rb +11 -66
- data/lib/bundler/rubygems_gem_installer.rb +1 -1
- data/lib/bundler/rubygems_integration.rb +133 -410
- data/lib/bundler/runtime.rb +2 -9
- data/lib/bundler/settings.rb +22 -52
- data/lib/bundler/setup.rb +7 -13
- data/lib/bundler/shared_helpers.rb +46 -74
- data/lib/bundler/similarity_detector.rb +2 -2
- data/lib/bundler/source.rb +5 -5
- data/lib/bundler/source/git.rb +24 -17
- data/lib/bundler/source/git/git_proxy.rb +38 -41
- data/lib/bundler/source/metadata.rb +7 -2
- data/lib/bundler/source/path.rb +13 -8
- data/lib/bundler/source/rubygems.rb +14 -8
- data/lib/bundler/source/rubygems/remote.rb +2 -3
- data/lib/bundler/source_list.rb +9 -12
- data/lib/bundler/spec_set.rb +1 -6
- data/lib/bundler/stub_specification.rb +18 -30
- data/lib/bundler/templates/Executable.bundler +22 -13
- data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +3 -3
- data/lib/bundler/templates/newgem/Gemfile.tt +8 -0
- data/lib/bundler/templates/newgem/README.md.tt +4 -3
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +2 -18
- data/lib/bundler/templates/newgem/test/test_helper.rb.tt +0 -4
- data/lib/bundler/templates/newgem/travis.yml.tt +0 -1
- data/lib/bundler/ui.rb +3 -3
- data/lib/bundler/ui/rg_proxy.rb +1 -1
- data/lib/bundler/ui/shell.rb +4 -8
- data/lib/bundler/uri_credentials_filter.rb +7 -3
- data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +161 -0
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +66 -0
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +176 -0
- data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +3 -0
- data/lib/bundler/vendor/fileutils/lib/fileutils.rb +134 -111
- data/lib/bundler/vendor/molinillo/lib/molinillo.rb +6 -6
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +2 -2
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +1 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +1 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +1 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +1 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +6 -6
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +1 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +1 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +30 -8
- data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +1 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +4 -4
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +2 -2
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +273 -304
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +40 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +53 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +79 -0
- data/lib/bundler/vendor/thor/lib/thor.rb +19 -4
- data/lib/bundler/vendor/thor/lib/thor/actions.rb +17 -12
- data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +7 -17
- data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +5 -5
- data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +19 -8
- data/lib/bundler/vendor/thor/lib/thor/base.rb +51 -39
- data/lib/bundler/vendor/thor/lib/thor/command.rb +21 -14
- data/lib/bundler/vendor/thor/lib/thor/error.rb +14 -18
- data/lib/bundler/vendor/thor/lib/thor/group.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/invocation.rb +1 -0
- data/lib/bundler/vendor/thor/lib/thor/line_editor.rb +2 -2
- data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +6 -6
- data/lib/bundler/vendor/thor/lib/thor/nested_context.rb +29 -0
- data/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -4
- data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +2 -2
- data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +20 -7
- data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +13 -3
- data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +1 -0
- data/lib/bundler/vendor/thor/lib/thor/runner.rb +13 -12
- data/lib/bundler/vendor/thor/lib/thor/shell.rb +3 -3
- data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +10 -1
- data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +6 -2
- data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +3 -3
- data/lib/bundler/vendor/thor/lib/thor/util.rb +18 -2
- data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
- data/lib/bundler/vendor/uri/lib/uri.rb +104 -0
- data/lib/bundler/vendor/uri/lib/uri/common.rb +744 -0
- data/lib/bundler/vendor/uri/lib/uri/file.rb +94 -0
- data/lib/bundler/vendor/uri/lib/uri/ftp.rb +267 -0
- data/lib/bundler/vendor/uri/lib/uri/generic.rb +1568 -0
- data/lib/bundler/vendor/uri/lib/uri/http.rb +88 -0
- data/lib/bundler/vendor/uri/lib/uri/https.rb +23 -0
- data/lib/bundler/vendor/uri/lib/uri/ldap.rb +261 -0
- data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +21 -0
- data/lib/bundler/vendor/uri/lib/uri/mailto.rb +294 -0
- data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +546 -0
- data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +125 -0
- data/lib/bundler/vendor/uri/lib/uri/version.rb +6 -0
- data/lib/bundler/vendored_fileutils.rb +1 -6
- data/lib/bundler/vendored_molinillo.rb +1 -1
- data/lib/bundler/vendored_persistent.rb +7 -5
- data/lib/bundler/vendored_thor.rb +2 -2
- data/lib/bundler/vendored_uri.rb +4 -0
- data/lib/bundler/version.rb +1 -20
- data/lib/bundler/version_ranges.rb +51 -5
- data/lib/bundler/vlad.rb +3 -3
- data/lib/bundler/worker.rb +1 -3
- data/lib/bundler/yaml_serializer.rb +2 -3
- data/man/bundle-add.1 +10 -2
- data/man/bundle-add.1.txt +11 -5
- data/man/bundle-add.ronn +7 -1
- data/man/bundle-binstubs.1 +2 -2
- data/man/bundle-binstubs.1.txt +2 -2
- data/man/bundle-binstubs.ronn +1 -1
- data/man/bundle-cache.1 +55 -0
- data/man/bundle-cache.1.txt +78 -0
- data/man/{bundle-package.ronn → bundle-cache.ronn} +15 -15
- data/man/bundle-check.1 +1 -1
- data/man/bundle-check.1.txt +6 -6
- data/man/bundle-clean.1 +1 -1
- data/man/bundle-clean.1.txt +1 -1
- data/man/bundle-config.1 +35 -35
- data/man/bundle-config.1.txt +65 -66
- data/man/bundle-config.ronn +41 -39
- data/man/bundle-doctor.1 +1 -1
- data/man/bundle-doctor.1.txt +1 -1
- data/man/bundle-exec.1 +2 -2
- data/man/bundle-exec.1.txt +2 -2
- data/man/bundle-exec.ronn +1 -1
- data/man/bundle-gem.1 +1 -1
- data/man/bundle-gem.1.txt +3 -3
- data/man/bundle-info.1 +1 -1
- data/man/bundle-info.1.txt +1 -1
- data/man/bundle-init.1 +1 -1
- data/man/bundle-init.1.txt +1 -1
- data/man/bundle-inject.1 +1 -1
- data/man/bundle-inject.1.txt +1 -1
- data/man/bundle-install.1 +8 -5
- data/man/bundle-install.1.txt +56 -51
- data/man/bundle-install.ronn +9 -4
- data/man/bundle-list.1 +1 -1
- data/man/bundle-list.1.txt +1 -1
- data/man/bundle-lock.1 +1 -1
- data/man/bundle-lock.1.txt +16 -16
- data/man/bundle-open.1 +1 -1
- data/man/bundle-open.1.txt +1 -1
- data/man/bundle-outdated.1 +1 -1
- data/man/bundle-outdated.1.txt +1 -1
- data/man/bundle-platform.1 +1 -1
- data/man/bundle-platform.1.txt +1 -1
- data/man/bundle-pristine.1 +1 -1
- data/man/bundle-pristine.1.txt +1 -1
- data/man/bundle-remove.1 +1 -1
- data/man/bundle-remove.1.txt +1 -1
- data/man/bundle-show.1 +1 -1
- data/man/bundle-show.1.txt +1 -1
- data/man/bundle-update.1 +4 -4
- data/man/bundle-update.1.txt +64 -65
- data/man/bundle-update.ronn +3 -3
- data/man/bundle-viz.1 +1 -1
- data/man/bundle-viz.1.txt +1 -1
- data/man/bundle.1 +2 -2
- data/man/bundle.1.txt +7 -7
- data/man/bundle.ronn +1 -1
- data/man/gemfile.5 +12 -15
- data/man/gemfile.5.ronn +9 -13
- data/man/gemfile.5.txt +103 -107
- data/man/index.txt +1 -1
- metadata +30 -120
- data/exe/bundle_ruby +0 -60
- data/lib/bundler/cli/package.rb +0 -49
- data/lib/bundler/compatibility_guard.rb +0 -13
- data/lib/bundler/gem_remote_fetcher.rb +0 -43
- data/lib/bundler/ssl_certs/.document +0 -1
- data/lib/bundler/ssl_certs/certificate_manager.rb +0 -66
- data/lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +0 -21
- data/lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +0 -23
- data/lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +0 -25
- data/lib/bundler/vendor/fileutils/lib/fileutils/version.rb +0 -5
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/faster.rb +0 -27
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse.rb +0 -129
- data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +0 -12
- data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +0 -129
- data/man/bundle-package.1 +0 -55
- data/man/bundle-package.1.txt +0 -79
@@ -0,0 +1,66 @@
|
|
1
|
+
# Global monotonic clock from Concurrent Ruby 1.0.
|
2
|
+
# Copyright (c) Jerry D'Antonio -- released under the MIT license.
|
3
|
+
# Slightly modified; used with permission.
|
4
|
+
# https://github.com/ruby-concurrency/concurrent-ruby
|
5
|
+
|
6
|
+
require 'thread'
|
7
|
+
|
8
|
+
class Bundler::ConnectionPool
|
9
|
+
|
10
|
+
class_definition = Class.new do
|
11
|
+
|
12
|
+
if defined?(Process::CLOCK_MONOTONIC)
|
13
|
+
|
14
|
+
# @!visibility private
|
15
|
+
def get_time
|
16
|
+
Process.clock_gettime(Process::CLOCK_MONOTONIC)
|
17
|
+
end
|
18
|
+
|
19
|
+
elsif defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby'
|
20
|
+
|
21
|
+
# @!visibility private
|
22
|
+
def get_time
|
23
|
+
java.lang.System.nanoTime() / 1_000_000_000.0
|
24
|
+
end
|
25
|
+
|
26
|
+
else
|
27
|
+
|
28
|
+
# @!visibility private
|
29
|
+
def initialize
|
30
|
+
@mutex = Mutex.new
|
31
|
+
@last_time = Time.now.to_f
|
32
|
+
end
|
33
|
+
|
34
|
+
# @!visibility private
|
35
|
+
def get_time
|
36
|
+
@mutex.synchronize do
|
37
|
+
now = Time.now.to_f
|
38
|
+
if @last_time < now
|
39
|
+
@last_time = now
|
40
|
+
else # clock has moved back in time
|
41
|
+
@last_time += 0.000_001
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
##
|
49
|
+
# Clock that cannot be set and represents monotonic time since
|
50
|
+
# some unspecified starting point.
|
51
|
+
#
|
52
|
+
# @!visibility private
|
53
|
+
GLOBAL_MONOTONIC_CLOCK = class_definition.new
|
54
|
+
private_constant :GLOBAL_MONOTONIC_CLOCK
|
55
|
+
|
56
|
+
class << self
|
57
|
+
##
|
58
|
+
# Returns the current time a tracked by the application monotonic clock.
|
59
|
+
#
|
60
|
+
# @return [Float] The current monotonic time when `since` not given else
|
61
|
+
# the elapsed monotonic time between `since` and the current time
|
62
|
+
def monotonic_time
|
63
|
+
GLOBAL_MONOTONIC_CLOCK.get_time
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,176 @@
|
|
1
|
+
require 'thread'
|
2
|
+
require 'timeout'
|
3
|
+
require_relative 'monotonic_time'
|
4
|
+
|
5
|
+
##
|
6
|
+
# Raised when you attempt to retrieve a connection from a pool that has been
|
7
|
+
# shut down.
|
8
|
+
|
9
|
+
class Bundler::ConnectionPool::PoolShuttingDownError < RuntimeError; end
|
10
|
+
|
11
|
+
##
|
12
|
+
# The TimedStack manages a pool of homogeneous connections (or any resource
|
13
|
+
# you wish to manage). Connections are created lazily up to a given maximum
|
14
|
+
# number.
|
15
|
+
|
16
|
+
# Examples:
|
17
|
+
#
|
18
|
+
# ts = TimedStack.new(1) { MyConnection.new }
|
19
|
+
#
|
20
|
+
# # fetch a connection
|
21
|
+
# conn = ts.pop
|
22
|
+
#
|
23
|
+
# # return a connection
|
24
|
+
# ts.push conn
|
25
|
+
#
|
26
|
+
# conn = ts.pop
|
27
|
+
# ts.pop timeout: 5
|
28
|
+
# #=> raises Timeout::Error after 5 seconds
|
29
|
+
|
30
|
+
class Bundler::ConnectionPool::TimedStack
|
31
|
+
attr_reader :max
|
32
|
+
|
33
|
+
##
|
34
|
+
# Creates a new pool with +size+ connections that are created from the given
|
35
|
+
# +block+.
|
36
|
+
|
37
|
+
def initialize(size = 0, &block)
|
38
|
+
@create_block = block
|
39
|
+
@created = 0
|
40
|
+
@que = []
|
41
|
+
@max = size
|
42
|
+
@mutex = Mutex.new
|
43
|
+
@resource = ConditionVariable.new
|
44
|
+
@shutdown_block = nil
|
45
|
+
end
|
46
|
+
|
47
|
+
##
|
48
|
+
# Returns +obj+ to the stack. +options+ is ignored in TimedStack but may be
|
49
|
+
# used by subclasses that extend TimedStack.
|
50
|
+
|
51
|
+
def push(obj, options = {})
|
52
|
+
@mutex.synchronize do
|
53
|
+
if @shutdown_block
|
54
|
+
@shutdown_block.call(obj)
|
55
|
+
else
|
56
|
+
store_connection obj, options
|
57
|
+
end
|
58
|
+
|
59
|
+
@resource.broadcast
|
60
|
+
end
|
61
|
+
end
|
62
|
+
alias_method :<<, :push
|
63
|
+
|
64
|
+
##
|
65
|
+
# Retrieves a connection from the stack. If a connection is available it is
|
66
|
+
# immediately returned. If no connection is available within the given
|
67
|
+
# timeout a Timeout::Error is raised.
|
68
|
+
#
|
69
|
+
# +:timeout+ is the only checked entry in +options+ and is preferred over
|
70
|
+
# the +timeout+ argument (which will be removed in a future release). Other
|
71
|
+
# options may be used by subclasses that extend TimedStack.
|
72
|
+
|
73
|
+
def pop(timeout = 0.5, options = {})
|
74
|
+
options, timeout = timeout, 0.5 if Hash === timeout
|
75
|
+
timeout = options.fetch :timeout, timeout
|
76
|
+
|
77
|
+
deadline = Bundler::ConnectionPool.monotonic_time + timeout
|
78
|
+
@mutex.synchronize do
|
79
|
+
loop do
|
80
|
+
raise Bundler::ConnectionPool::PoolShuttingDownError if @shutdown_block
|
81
|
+
return fetch_connection(options) if connection_stored?(options)
|
82
|
+
|
83
|
+
connection = try_create(options)
|
84
|
+
return connection if connection
|
85
|
+
|
86
|
+
to_wait = deadline - Bundler::ConnectionPool.monotonic_time
|
87
|
+
raise Timeout::Error, "Waited #{timeout} sec" if to_wait <= 0
|
88
|
+
@resource.wait(@mutex, to_wait)
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
##
|
94
|
+
# Shuts down the TimedStack which prevents connections from being checked
|
95
|
+
# out. The +block+ is called once for each connection on the stack.
|
96
|
+
|
97
|
+
def shutdown(&block)
|
98
|
+
raise ArgumentError, "shutdown must receive a block" unless block_given?
|
99
|
+
|
100
|
+
@mutex.synchronize do
|
101
|
+
@shutdown_block = block
|
102
|
+
@resource.broadcast
|
103
|
+
|
104
|
+
shutdown_connections
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
##
|
109
|
+
# Returns +true+ if there are no available connections.
|
110
|
+
|
111
|
+
def empty?
|
112
|
+
(@created - @que.length) >= @max
|
113
|
+
end
|
114
|
+
|
115
|
+
##
|
116
|
+
# The number of connections available on the stack.
|
117
|
+
|
118
|
+
def length
|
119
|
+
@max - @created + @que.length
|
120
|
+
end
|
121
|
+
|
122
|
+
private
|
123
|
+
|
124
|
+
##
|
125
|
+
# This is an extension point for TimedStack and is called with a mutex.
|
126
|
+
#
|
127
|
+
# This method must returns true if a connection is available on the stack.
|
128
|
+
|
129
|
+
def connection_stored?(options = nil)
|
130
|
+
!@que.empty?
|
131
|
+
end
|
132
|
+
|
133
|
+
##
|
134
|
+
# This is an extension point for TimedStack and is called with a mutex.
|
135
|
+
#
|
136
|
+
# This method must return a connection from the stack.
|
137
|
+
|
138
|
+
def fetch_connection(options = nil)
|
139
|
+
@que.pop
|
140
|
+
end
|
141
|
+
|
142
|
+
##
|
143
|
+
# This is an extension point for TimedStack and is called with a mutex.
|
144
|
+
#
|
145
|
+
# This method must shut down all connections on the stack.
|
146
|
+
|
147
|
+
def shutdown_connections(options = nil)
|
148
|
+
while connection_stored?(options)
|
149
|
+
conn = fetch_connection(options)
|
150
|
+
@shutdown_block.call(conn)
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
##
|
155
|
+
# This is an extension point for TimedStack and is called with a mutex.
|
156
|
+
#
|
157
|
+
# This method must return +obj+ to the stack.
|
158
|
+
|
159
|
+
def store_connection(obj, options = nil)
|
160
|
+
@que.push obj
|
161
|
+
end
|
162
|
+
|
163
|
+
##
|
164
|
+
# This is an extension point for TimedStack and is called with a mutex.
|
165
|
+
#
|
166
|
+
# This method must create a connection if and only if the total number of
|
167
|
+
# connections allowed has not been met.
|
168
|
+
|
169
|
+
def try_create(options = nil)
|
170
|
+
unless @created == @max
|
171
|
+
object = @create_block.call
|
172
|
+
@created += 1
|
173
|
+
object
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
@@ -6,8 +6,6 @@ rescue LoadError
|
|
6
6
|
# for make mjit-headers
|
7
7
|
end
|
8
8
|
|
9
|
-
require "bundler/vendor/fileutils/lib/fileutils/version"
|
10
|
-
|
11
9
|
#
|
12
10
|
# = fileutils.rb
|
13
11
|
#
|
@@ -24,46 +22,56 @@ require "bundler/vendor/fileutils/lib/fileutils/version"
|
|
24
22
|
#
|
25
23
|
# require 'bundler/vendor/fileutils/lib/fileutils'
|
26
24
|
#
|
27
|
-
# Bundler::FileUtils.cd(dir, options)
|
28
|
-
# Bundler::FileUtils.cd(dir, options) {|dir| block }
|
25
|
+
# Bundler::FileUtils.cd(dir, **options)
|
26
|
+
# Bundler::FileUtils.cd(dir, **options) {|dir| block }
|
29
27
|
# Bundler::FileUtils.pwd()
|
30
|
-
# Bundler::FileUtils.mkdir(dir, options)
|
31
|
-
# Bundler::FileUtils.mkdir(list, options)
|
32
|
-
# Bundler::FileUtils.mkdir_p(dir, options)
|
33
|
-
# Bundler::FileUtils.mkdir_p(list, options)
|
34
|
-
# Bundler::FileUtils.rmdir(dir, options)
|
35
|
-
# Bundler::FileUtils.rmdir(list, options)
|
36
|
-
# Bundler::FileUtils.ln(target, link, options)
|
37
|
-
# Bundler::FileUtils.ln(targets, dir, options)
|
38
|
-
# Bundler::FileUtils.ln_s(target, link, options)
|
39
|
-
# Bundler::FileUtils.ln_s(targets, dir, options)
|
40
|
-
# Bundler::FileUtils.ln_sf(target, link, options)
|
41
|
-
# Bundler::FileUtils.cp(src, dest, options)
|
42
|
-
# Bundler::FileUtils.cp(list, dir, options)
|
43
|
-
# Bundler::FileUtils.cp_r(src, dest, options)
|
44
|
-
# Bundler::FileUtils.cp_r(list, dir, options)
|
45
|
-
# Bundler::FileUtils.mv(src, dest, options)
|
46
|
-
# Bundler::FileUtils.mv(list, dir, options)
|
47
|
-
# Bundler::FileUtils.rm(list, options)
|
48
|
-
# Bundler::FileUtils.rm_r(list, options)
|
49
|
-
# Bundler::FileUtils.rm_rf(list, options)
|
50
|
-
# Bundler::FileUtils.install(src, dest, options)
|
51
|
-
# Bundler::FileUtils.chmod(mode, list, options)
|
52
|
-
# Bundler::FileUtils.chmod_R(mode, list, options)
|
53
|
-
# Bundler::FileUtils.chown(user, group, list, options)
|
54
|
-
# Bundler::FileUtils.chown_R(user, group, list, options)
|
55
|
-
# Bundler::FileUtils.touch(list, options)
|
28
|
+
# Bundler::FileUtils.mkdir(dir, **options)
|
29
|
+
# Bundler::FileUtils.mkdir(list, **options)
|
30
|
+
# Bundler::FileUtils.mkdir_p(dir, **options)
|
31
|
+
# Bundler::FileUtils.mkdir_p(list, **options)
|
32
|
+
# Bundler::FileUtils.rmdir(dir, **options)
|
33
|
+
# Bundler::FileUtils.rmdir(list, **options)
|
34
|
+
# Bundler::FileUtils.ln(target, link, **options)
|
35
|
+
# Bundler::FileUtils.ln(targets, dir, **options)
|
36
|
+
# Bundler::FileUtils.ln_s(target, link, **options)
|
37
|
+
# Bundler::FileUtils.ln_s(targets, dir, **options)
|
38
|
+
# Bundler::FileUtils.ln_sf(target, link, **options)
|
39
|
+
# Bundler::FileUtils.cp(src, dest, **options)
|
40
|
+
# Bundler::FileUtils.cp(list, dir, **options)
|
41
|
+
# Bundler::FileUtils.cp_r(src, dest, **options)
|
42
|
+
# Bundler::FileUtils.cp_r(list, dir, **options)
|
43
|
+
# Bundler::FileUtils.mv(src, dest, **options)
|
44
|
+
# Bundler::FileUtils.mv(list, dir, **options)
|
45
|
+
# Bundler::FileUtils.rm(list, **options)
|
46
|
+
# Bundler::FileUtils.rm_r(list, **options)
|
47
|
+
# Bundler::FileUtils.rm_rf(list, **options)
|
48
|
+
# Bundler::FileUtils.install(src, dest, **options)
|
49
|
+
# Bundler::FileUtils.chmod(mode, list, **options)
|
50
|
+
# Bundler::FileUtils.chmod_R(mode, list, **options)
|
51
|
+
# Bundler::FileUtils.chown(user, group, list, **options)
|
52
|
+
# Bundler::FileUtils.chown_R(user, group, list, **options)
|
53
|
+
# Bundler::FileUtils.touch(list, **options)
|
54
|
+
#
|
55
|
+
# Possible <tt>options</tt> are:
|
56
56
|
#
|
57
|
-
#
|
58
|
-
#
|
59
|
-
# <tt>:
|
60
|
-
#
|
57
|
+
# <tt>:force</tt> :: forced operation (rewrite files if exist, remove
|
58
|
+
# directories if not empty, etc.);
|
59
|
+
# <tt>:verbose</tt> :: print command to be run, in bash syntax, before
|
60
|
+
# performing it;
|
61
|
+
# <tt>:preserve</tt> :: preserve object's group, user and modification
|
62
|
+
# time on copying;
|
63
|
+
# <tt>:noop</tt> :: no changes are made (usable in combination with
|
64
|
+
# <tt>:verbose</tt> which will print the command to run)
|
65
|
+
#
|
66
|
+
# Each method documents the options that it honours. See also ::commands,
|
67
|
+
# ::options and ::options_of methods to introspect which command have which
|
68
|
+
# options.
|
61
69
|
#
|
62
70
|
# All methods that have the concept of a "source" file or directory can take
|
63
71
|
# either one file or a list of files in that argument. See the method
|
64
72
|
# documentation for examples.
|
65
73
|
#
|
66
|
-
# There are some `low level' methods, which do not accept
|
74
|
+
# There are some `low level' methods, which do not accept keyword arguments:
|
67
75
|
#
|
68
76
|
# Bundler::FileUtils.copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false)
|
69
77
|
# Bundler::FileUtils.copy_file(src, dest, preserve = false, dereference = true)
|
@@ -94,6 +102,7 @@ require "bundler/vendor/fileutils/lib/fileutils/version"
|
|
94
102
|
# <tt>:verbose</tt> flags to methods in Bundler::FileUtils.
|
95
103
|
#
|
96
104
|
module Bundler::FileUtils
|
105
|
+
VERSION = "1.4.1"
|
97
106
|
|
98
107
|
def self.private_module_function(name) #:nodoc:
|
99
108
|
module_function name
|
@@ -119,7 +128,7 @@ module Bundler::FileUtils
|
|
119
128
|
#
|
120
129
|
# Bundler::FileUtils.cd('/') # change directory
|
121
130
|
#
|
122
|
-
# Bundler::FileUtils.cd('/', :
|
131
|
+
# Bundler::FileUtils.cd('/', verbose: true) # change directory and report it
|
123
132
|
#
|
124
133
|
# Bundler::FileUtils.cd('/') do # change directory
|
125
134
|
# # ... # do something
|
@@ -164,9 +173,9 @@ module Bundler::FileUtils
|
|
164
173
|
# Creates one or more directories.
|
165
174
|
#
|
166
175
|
# Bundler::FileUtils.mkdir 'test'
|
167
|
-
# Bundler::FileUtils.mkdir %w(
|
168
|
-
# Bundler::FileUtils.mkdir 'notexist', :
|
169
|
-
# Bundler::FileUtils.mkdir 'tmp', :
|
176
|
+
# Bundler::FileUtils.mkdir %w(tmp data)
|
177
|
+
# Bundler::FileUtils.mkdir 'notexist', noop: true # Does not really create.
|
178
|
+
# Bundler::FileUtils.mkdir 'tmp', mode: 0700
|
170
179
|
#
|
171
180
|
def mkdir(list, mode: nil, noop: nil, verbose: nil)
|
172
181
|
list = fu_list(list)
|
@@ -185,7 +194,7 @@ module Bundler::FileUtils
|
|
185
194
|
#
|
186
195
|
# Bundler::FileUtils.mkdir_p '/usr/local/lib/ruby'
|
187
196
|
#
|
188
|
-
# causes to make following directories, if
|
197
|
+
# causes to make following directories, if they do not exist.
|
189
198
|
#
|
190
199
|
# * /usr
|
191
200
|
# * /usr/local
|
@@ -249,7 +258,7 @@ module Bundler::FileUtils
|
|
249
258
|
# Bundler::FileUtils.rmdir 'somedir'
|
250
259
|
# Bundler::FileUtils.rmdir %w(somedir anydir otherdir)
|
251
260
|
# # Does not really remove directory; outputs message.
|
252
|
-
# Bundler::FileUtils.rmdir 'somedir', :
|
261
|
+
# Bundler::FileUtils.rmdir 'somedir', verbose: true, noop: true
|
253
262
|
#
|
254
263
|
def rmdir(list, parents: nil, noop: nil, verbose: nil)
|
255
264
|
list = fu_list(list)
|
@@ -278,7 +287,7 @@ module Bundler::FileUtils
|
|
278
287
|
#
|
279
288
|
# In the first form, creates a hard link +link+ which points to +target+.
|
280
289
|
# If +link+ already exists, raises Errno::EEXIST.
|
281
|
-
# But if the
|
290
|
+
# But if the +force+ option is set, overwrites +link+.
|
282
291
|
#
|
283
292
|
# Bundler::FileUtils.ln 'gcc', 'cc', verbose: true
|
284
293
|
# Bundler::FileUtils.ln '/usr/bin/emacs21', '/usr/bin/emacs'
|
@@ -304,9 +313,6 @@ module Bundler::FileUtils
|
|
304
313
|
alias link ln
|
305
314
|
module_function :link
|
306
315
|
|
307
|
-
#
|
308
|
-
# :call-seq:
|
309
|
-
# Bundler::FileUtils.cp_lr(src, dest, noop: nil, verbose: nil, dereference_root: true, remove_destination: false)
|
310
316
|
#
|
311
317
|
# Hard link +src+ to +dest+. If +src+ is a directory, this method links
|
312
318
|
# all its contents recursively. If +dest+ is a directory, links
|
@@ -314,13 +320,16 @@ module Bundler::FileUtils
|
|
314
320
|
#
|
315
321
|
# +src+ can be a list of files.
|
316
322
|
#
|
317
|
-
#
|
318
|
-
#
|
323
|
+
# If +dereference_root+ is true, this method dereference tree root.
|
324
|
+
#
|
325
|
+
# If +remove_destination+ is true, this method removes each destination file before copy.
|
326
|
+
#
|
327
|
+
# Bundler::FileUtils.rm_r site_ruby + '/mylib', force: true
|
319
328
|
# Bundler::FileUtils.cp_lr 'lib/', site_ruby + '/mylib'
|
320
329
|
#
|
321
330
|
# # Examples of linking several files to target directory.
|
322
331
|
# Bundler::FileUtils.cp_lr %w(mail.rb field.rb debug/), site_ruby + '/tmail'
|
323
|
-
# Bundler::FileUtils.cp_lr Dir.glob('*.rb'), '/home/aamine/lib/ruby', :
|
332
|
+
# Bundler::FileUtils.cp_lr Dir.glob('*.rb'), '/home/aamine/lib/ruby', noop: true, verbose: true
|
324
333
|
#
|
325
334
|
# # If you want to link all contents of a directory instead of the
|
326
335
|
# # directory itself, c.f. src/x -> dest/x, src/y -> dest/y,
|
@@ -345,7 +354,7 @@ module Bundler::FileUtils
|
|
345
354
|
#
|
346
355
|
# In the first form, creates a symbolic link +link+ which points to +target+.
|
347
356
|
# If +link+ already exists, raises Errno::EEXIST.
|
348
|
-
# But if the
|
357
|
+
# But if the <tt>force</tt> option is set, overwrites +link+.
|
349
358
|
#
|
350
359
|
# Bundler::FileUtils.ln_s '/usr/bin/ruby', '/usr/local/bin/ruby'
|
351
360
|
# Bundler::FileUtils.ln_s 'verylongsourcefilename.c', 'c', force: true
|
@@ -411,7 +420,7 @@ module Bundler::FileUtils
|
|
411
420
|
#
|
412
421
|
# Bundler::FileUtils.cp 'eval.c', 'eval.c.org'
|
413
422
|
# Bundler::FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6'
|
414
|
-
# Bundler::FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6', :
|
423
|
+
# Bundler::FileUtils.cp %w(cgi.rb complex.rb date.rb), '/usr/lib/ruby/1.6', verbose: true
|
415
424
|
# Bundler::FileUtils.cp 'symlink', 'dest' # copy content, "dest" is not a symlink
|
416
425
|
#
|
417
426
|
def cp(src, dest, preserve: nil, noop: nil, verbose: nil)
|
@@ -433,13 +442,17 @@ module Bundler::FileUtils
|
|
433
442
|
#
|
434
443
|
# +src+ can be a list of files.
|
435
444
|
#
|
445
|
+
# If +dereference_root+ is true, this method dereference tree root.
|
446
|
+
#
|
447
|
+
# If +remove_destination+ is true, this method removes each destination file before copy.
|
448
|
+
#
|
436
449
|
# # Installing Ruby library "mylib" under the site_ruby
|
437
|
-
# Bundler::FileUtils.rm_r site_ruby + '/mylib', :
|
450
|
+
# Bundler::FileUtils.rm_r site_ruby + '/mylib', force: true
|
438
451
|
# Bundler::FileUtils.cp_r 'lib/', site_ruby + '/mylib'
|
439
452
|
#
|
440
453
|
# # Examples of copying several files to target directory.
|
441
454
|
# Bundler::FileUtils.cp_r %w(mail.rb field.rb debug/), site_ruby + '/tmail'
|
442
|
-
# Bundler::FileUtils.cp_r Dir.glob('*.rb'), '/home/foo/lib/ruby', :
|
455
|
+
# Bundler::FileUtils.cp_r Dir.glob('*.rb'), '/home/foo/lib/ruby', noop: true, verbose: true
|
443
456
|
#
|
444
457
|
# # If you want to copy all contents of a directory instead of the
|
445
458
|
# # directory itself, c.f. src/x -> dest/x, src/y -> dest/y,
|
@@ -474,7 +487,11 @@ module Bundler::FileUtils
|
|
474
487
|
# If +remove_destination+ is true, this method removes each destination file before copy.
|
475
488
|
#
|
476
489
|
def copy_entry(src, dest, preserve = false, dereference_root = false, remove_destination = false)
|
477
|
-
|
490
|
+
if dereference_root
|
491
|
+
src = File.realpath(src)
|
492
|
+
end
|
493
|
+
|
494
|
+
Entry_.new(src, nil, false).wrap_traverse(proc do |ent|
|
478
495
|
destent = Entry_.new(dest, ent.rel, false)
|
479
496
|
File.unlink destent.path if remove_destination && (File.file?(destent.path) || File.symlink?(destent.path))
|
480
497
|
ent.copy destent.path
|
@@ -511,10 +528,10 @@ module Bundler::FileUtils
|
|
511
528
|
# disk partition, the file is copied then the original file is removed.
|
512
529
|
#
|
513
530
|
# Bundler::FileUtils.mv 'badname.rb', 'goodname.rb'
|
514
|
-
# Bundler::FileUtils.mv 'stuff.rb', '/notexist/lib/ruby', :
|
531
|
+
# Bundler::FileUtils.mv 'stuff.rb', '/notexist/lib/ruby', force: true # no error
|
515
532
|
#
|
516
533
|
# Bundler::FileUtils.mv %w(junk.txt dust.txt), '/home/foo/.trash/'
|
517
|
-
# Bundler::FileUtils.mv Dir.glob('test*.rb'), 'test', :
|
534
|
+
# Bundler::FileUtils.mv Dir.glob('test*.rb'), 'test', noop: true, verbose: true
|
518
535
|
#
|
519
536
|
def mv(src, dest, force: nil, noop: nil, verbose: nil, secure: nil)
|
520
537
|
fu_output_message "mv#{force ? ' -f' : ''} #{[src,dest].flatten.join ' '}" if verbose
|
@@ -554,7 +571,7 @@ module Bundler::FileUtils
|
|
554
571
|
#
|
555
572
|
# Bundler::FileUtils.rm %w( junk.txt dust.txt )
|
556
573
|
# Bundler::FileUtils.rm Dir.glob('*.so')
|
557
|
-
# Bundler::FileUtils.rm 'NotExistFile', :
|
574
|
+
# Bundler::FileUtils.rm 'NotExistFile', force: true # never raises exception
|
558
575
|
#
|
559
576
|
def rm(list, force: nil, noop: nil, verbose: nil)
|
560
577
|
list = fu_list(list)
|
@@ -573,7 +590,7 @@ module Bundler::FileUtils
|
|
573
590
|
#
|
574
591
|
# Equivalent to
|
575
592
|
#
|
576
|
-
# Bundler::FileUtils.rm(list, :
|
593
|
+
# Bundler::FileUtils.rm(list, force: true)
|
577
594
|
#
|
578
595
|
def rm_f(list, noop: nil, verbose: nil)
|
579
596
|
rm list, force: true, noop: noop, verbose: verbose
|
@@ -589,18 +606,18 @@ module Bundler::FileUtils
|
|
589
606
|
# StandardError when :force option is set.
|
590
607
|
#
|
591
608
|
# Bundler::FileUtils.rm_r Dir.glob('/tmp/*')
|
592
|
-
# Bundler::FileUtils.rm_r 'some_dir', :
|
609
|
+
# Bundler::FileUtils.rm_r 'some_dir', force: true
|
593
610
|
#
|
594
611
|
# WARNING: This method causes local vulnerability
|
595
612
|
# if one of parent directories or removing directory tree are world
|
596
613
|
# writable (including /tmp, whose permission is 1777), and the current
|
597
614
|
# process has strong privilege such as Unix super user (root), and the
|
598
615
|
# system has symbolic link. For secure removing, read the documentation
|
599
|
-
# of
|
600
|
-
# Default is :
|
616
|
+
# of remove_entry_secure carefully, and set :secure option to true.
|
617
|
+
# Default is <tt>secure: false</tt>.
|
601
618
|
#
|
602
|
-
# NOTE: This method calls
|
603
|
-
# See also
|
619
|
+
# NOTE: This method calls remove_entry_secure if :secure option is set.
|
620
|
+
# See also remove_entry_secure.
|
604
621
|
#
|
605
622
|
def rm_r(list, force: nil, noop: nil, verbose: nil, secure: nil)
|
606
623
|
list = fu_list(list)
|
@@ -619,10 +636,10 @@ module Bundler::FileUtils
|
|
619
636
|
#
|
620
637
|
# Equivalent to
|
621
638
|
#
|
622
|
-
# Bundler::FileUtils.rm_r(list, :
|
639
|
+
# Bundler::FileUtils.rm_r(list, force: true)
|
623
640
|
#
|
624
641
|
# WARNING: This method causes local vulnerability.
|
625
|
-
# Read the documentation of
|
642
|
+
# Read the documentation of rm_r first.
|
626
643
|
#
|
627
644
|
def rm_rf(list, noop: nil, verbose: nil, secure: nil)
|
628
645
|
rm_r list, force: true, noop: noop, verbose: verbose, secure: secure
|
@@ -636,7 +653,7 @@ module Bundler::FileUtils
|
|
636
653
|
# This method removes a file system entry +path+. +path+ shall be a
|
637
654
|
# regular file, a directory, or something. If +path+ is a directory,
|
638
655
|
# remove it recursively. This method is required to avoid TOCTTOU
|
639
|
-
# (time-of-check-to-time-of-use) local security vulnerability of
|
656
|
+
# (time-of-check-to-time-of-use) local security vulnerability of rm_r.
|
640
657
|
# #rm_r causes security hole when:
|
641
658
|
#
|
642
659
|
# * Parent directory is world writable (including /tmp).
|
@@ -755,7 +772,7 @@ module Bundler::FileUtils
|
|
755
772
|
# +path+ might be a regular file, a directory, or something.
|
756
773
|
# If +path+ is a directory, remove it recursively.
|
757
774
|
#
|
758
|
-
# See also
|
775
|
+
# See also remove_entry_secure.
|
759
776
|
#
|
760
777
|
def remove_entry(path, force = false)
|
761
778
|
Entry_.new(path).postorder_traverse do |ent|
|
@@ -839,8 +856,8 @@ module Bundler::FileUtils
|
|
839
856
|
# mode to +mode+. If +dest+ is a directory, destination is +dest+/+src+.
|
840
857
|
# This method removes destination before copy.
|
841
858
|
#
|
842
|
-
# Bundler::FileUtils.install 'ruby', '/usr/local/bin/ruby', :
|
843
|
-
# Bundler::FileUtils.install 'lib.rb', '/usr/local/lib/ruby/site_ruby', :
|
859
|
+
# Bundler::FileUtils.install 'ruby', '/usr/local/bin/ruby', mode: 0755, verbose: true
|
860
|
+
# Bundler::FileUtils.install 'lib.rb', '/usr/local/lib/ruby/site_ruby', verbose: true
|
844
861
|
#
|
845
862
|
def install(src, dest, mode: nil, owner: nil, group: nil, preserve: nil,
|
846
863
|
noop: nil, verbose: nil)
|
@@ -970,12 +987,12 @@ module Bundler::FileUtils
|
|
970
987
|
# Absolute mode is
|
971
988
|
# Bundler::FileUtils.chmod 0755, 'somecommand'
|
972
989
|
# Bundler::FileUtils.chmod 0644, %w(my.rb your.rb his.rb her.rb)
|
973
|
-
# Bundler::FileUtils.chmod 0755, '/usr/bin/ruby', :
|
990
|
+
# Bundler::FileUtils.chmod 0755, '/usr/bin/ruby', verbose: true
|
974
991
|
#
|
975
992
|
# Symbolic mode is
|
976
993
|
# Bundler::FileUtils.chmod "u=wrx,go=rx", 'somecommand'
|
977
994
|
# Bundler::FileUtils.chmod "u=wr,go=rr", %w(my.rb your.rb his.rb her.rb)
|
978
|
-
# Bundler::FileUtils.chmod "u=wrx,go=rx", '/usr/bin/ruby', :
|
995
|
+
# Bundler::FileUtils.chmod "u=wrx,go=rx", '/usr/bin/ruby', verbose: true
|
979
996
|
#
|
980
997
|
# "a" :: is user, group, other mask.
|
981
998
|
# "u" :: is user's mask.
|
@@ -1035,7 +1052,7 @@ module Bundler::FileUtils
|
|
1035
1052
|
# the attribute.
|
1036
1053
|
#
|
1037
1054
|
# Bundler::FileUtils.chown 'root', 'staff', '/usr/local/bin/ruby'
|
1038
|
-
# Bundler::FileUtils.chown nil, 'bin', Dir.glob('/usr/bin/*'), :
|
1055
|
+
# Bundler::FileUtils.chown nil, 'bin', Dir.glob('/usr/bin/*'), verbose: true
|
1039
1056
|
#
|
1040
1057
|
def chown(user, group, list, noop: nil, verbose: nil)
|
1041
1058
|
list = fu_list(list)
|
@@ -1059,7 +1076,7 @@ module Bundler::FileUtils
|
|
1059
1076
|
# method does not change the attribute.
|
1060
1077
|
#
|
1061
1078
|
# Bundler::FileUtils.chown_R 'www', 'www', '/var/www/htdocs'
|
1062
|
-
# Bundler::FileUtils.chown_R 'cvs', 'cvs', '/var/cvs', :
|
1079
|
+
# Bundler::FileUtils.chown_R 'cvs', 'cvs', '/var/cvs', verbose: true
|
1063
1080
|
#
|
1064
1081
|
def chown_R(user, group, list, noop: nil, verbose: nil, force: nil)
|
1065
1082
|
list = fu_list(list)
|
@@ -1276,13 +1293,14 @@ module Bundler::FileUtils
|
|
1276
1293
|
opts[:encoding] = ::Encoding::UTF_8 if fu_windows?
|
1277
1294
|
|
1278
1295
|
files = if Dir.respond_to?(:children)
|
1279
|
-
Dir.children(path, opts)
|
1296
|
+
Dir.children(path, **opts)
|
1280
1297
|
else
|
1281
|
-
Dir.entries(path(), opts)
|
1298
|
+
Dir.entries(path(), **opts)
|
1282
1299
|
.reject {|n| n == '.' or n == '..' }
|
1283
1300
|
end
|
1284
1301
|
|
1285
|
-
|
1302
|
+
untaint = RUBY_VERSION < '2.7'
|
1303
|
+
files.map {|n| Entry_.new(prefix(), join(rel(), untaint ? n.untaint : n)) }
|
1286
1304
|
end
|
1287
1305
|
|
1288
1306
|
def stat
|
@@ -1369,18 +1387,21 @@ module Bundler::FileUtils
|
|
1369
1387
|
end
|
1370
1388
|
when symlink?
|
1371
1389
|
File.symlink File.readlink(path()), dest
|
1372
|
-
when chardev?
|
1373
|
-
raise "cannot handle device file"
|
1374
|
-
mknod dest, ?c, 0666, lstat().rdev
|
1375
|
-
when blockdev?
|
1376
|
-
raise "cannot handle device file" unless File.respond_to?(:mknod)
|
1377
|
-
mknod dest, ?b, 0666, lstat().rdev
|
1390
|
+
when chardev?, blockdev?
|
1391
|
+
raise "cannot handle device file"
|
1378
1392
|
when socket?
|
1379
|
-
|
1380
|
-
|
1393
|
+
begin
|
1394
|
+
require 'socket'
|
1395
|
+
rescue LoadError
|
1396
|
+
raise "cannot handle socket"
|
1397
|
+
else
|
1398
|
+
raise "cannot handle socket" unless defined?(UNIXServer)
|
1399
|
+
end
|
1400
|
+
UNIXServer.new(dest).close
|
1401
|
+
File.chmod lstat().mode, dest
|
1381
1402
|
when pipe?
|
1382
1403
|
raise "cannot handle FIFO" unless File.respond_to?(:mkfifo)
|
1383
|
-
mkfifo dest,
|
1404
|
+
File.mkfifo dest, lstat().mode
|
1384
1405
|
when door?
|
1385
1406
|
raise "cannot handle door: #{path()}"
|
1386
1407
|
else
|
@@ -1499,14 +1520,14 @@ module Bundler::FileUtils
|
|
1499
1520
|
|
1500
1521
|
private
|
1501
1522
|
|
1502
|
-
|
1523
|
+
@@fileutils_rb_have_lchmod = nil
|
1503
1524
|
|
1504
1525
|
def have_lchmod?
|
1505
1526
|
# This is not MT-safe, but it does not matter.
|
1506
|
-
if
|
1507
|
-
|
1527
|
+
if @@fileutils_rb_have_lchmod == nil
|
1528
|
+
@@fileutils_rb_have_lchmod = check_have_lchmod?
|
1508
1529
|
end
|
1509
|
-
|
1530
|
+
@@fileutils_rb_have_lchmod
|
1510
1531
|
end
|
1511
1532
|
|
1512
1533
|
def check_have_lchmod?
|
@@ -1517,14 +1538,14 @@ module Bundler::FileUtils
|
|
1517
1538
|
return false
|
1518
1539
|
end
|
1519
1540
|
|
1520
|
-
|
1541
|
+
@@fileutils_rb_have_lchown = nil
|
1521
1542
|
|
1522
1543
|
def have_lchown?
|
1523
1544
|
# This is not MT-safe, but it does not matter.
|
1524
|
-
if
|
1525
|
-
|
1545
|
+
if @@fileutils_rb_have_lchown == nil
|
1546
|
+
@@fileutils_rb_have_lchown = check_have_lchown?
|
1526
1547
|
end
|
1527
|
-
|
1548
|
+
@@fileutils_rb_have_lchown
|
1528
1549
|
end
|
1529
1550
|
|
1530
1551
|
def check_have_lchown?
|
@@ -1546,10 +1567,13 @@ module Bundler::FileUtils
|
|
1546
1567
|
else
|
1547
1568
|
DIRECTORY_TERM = "(?=/|\\z)"
|
1548
1569
|
end
|
1549
|
-
SYSCASE = File::FNM_SYSCASE.nonzero? ? "-i" : ""
|
1550
1570
|
|
1551
1571
|
def descendant_directory?(descendant, ascendant)
|
1552
|
-
|
1572
|
+
if File::FNM_SYSCASE.nonzero?
|
1573
|
+
File.expand_path(File.dirname(descendant)).casecmp(File.expand_path(ascendant)) == 0
|
1574
|
+
else
|
1575
|
+
File.expand_path(File.dirname(descendant)) == File.expand_path(ascendant)
|
1576
|
+
end
|
1553
1577
|
end
|
1554
1578
|
end # class Entry_
|
1555
1579
|
|
@@ -1588,13 +1612,13 @@ module Bundler::FileUtils
|
|
1588
1612
|
end
|
1589
1613
|
private_module_function :fu_same?
|
1590
1614
|
|
1591
|
-
@fileutils_output = $stderr
|
1592
|
-
@fileutils_label = ''
|
1593
|
-
|
1594
1615
|
def fu_output_message(msg) #:nodoc:
|
1595
|
-
@fileutils_output
|
1596
|
-
|
1597
|
-
|
1616
|
+
output = @fileutils_output if defined?(@fileutils_output)
|
1617
|
+
output ||= $stderr
|
1618
|
+
if defined?(@fileutils_label)
|
1619
|
+
msg = @fileutils_label + msg
|
1620
|
+
end
|
1621
|
+
output.puts msg
|
1598
1622
|
end
|
1599
1623
|
private_module_function :fu_output_message
|
1600
1624
|
|
@@ -1605,8 +1629,11 @@ module Bundler::FileUtils
|
|
1605
1629
|
tbl
|
1606
1630
|
}
|
1607
1631
|
|
1632
|
+
public
|
1633
|
+
|
1608
1634
|
#
|
1609
|
-
# Returns an Array of
|
1635
|
+
# Returns an Array of names of high-level methods that accept any keyword
|
1636
|
+
# arguments.
|
1610
1637
|
#
|
1611
1638
|
# p Bundler::FileUtils.commands #=> ["chmod", "cp", "cp_r", "install", ...]
|
1612
1639
|
#
|
@@ -1645,7 +1672,7 @@ module Bundler::FileUtils
|
|
1645
1672
|
end
|
1646
1673
|
|
1647
1674
|
#
|
1648
|
-
# Returns an Array of
|
1675
|
+
# Returns an Array of methods names which have the option +opt+.
|
1649
1676
|
#
|
1650
1677
|
# p Bundler::FileUtils.collect_method(:preserve) #=> ["cp", "cp_r", "copy", "install"]
|
1651
1678
|
#
|
@@ -1653,14 +1680,16 @@ module Bundler::FileUtils
|
|
1653
1680
|
OPT_TABLE.keys.select {|m| OPT_TABLE[m].include?(opt) }
|
1654
1681
|
end
|
1655
1682
|
|
1656
|
-
|
1657
|
-
|
1683
|
+
private
|
1684
|
+
|
1685
|
+
LOW_METHODS = singleton_methods(false) - collect_method(:noop).map(&:intern) # :nodoc:
|
1686
|
+
module LowMethods # :nodoc: internal use only
|
1658
1687
|
private
|
1659
1688
|
def _do_nothing(*)end
|
1660
1689
|
::Bundler::FileUtils::LOW_METHODS.map {|name| alias_method name, :_do_nothing}
|
1661
1690
|
end
|
1662
1691
|
|
1663
|
-
METHODS = singleton_methods() - [:private_module_function,
|
1692
|
+
METHODS = singleton_methods() - [:private_module_function, # :nodoc:
|
1664
1693
|
:commands, :options, :have_option?, :options_of, :collect_method]
|
1665
1694
|
|
1666
1695
|
#
|
@@ -1670,8 +1699,6 @@ module Bundler::FileUtils
|
|
1670
1699
|
#
|
1671
1700
|
module Verbose
|
1672
1701
|
include Bundler::FileUtils
|
1673
|
-
@fileutils_output = $stderr
|
1674
|
-
@fileutils_label = ''
|
1675
1702
|
names = ::Bundler::FileUtils.collect_method(:verbose)
|
1676
1703
|
names.each do |name|
|
1677
1704
|
module_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
@@ -1695,8 +1722,6 @@ module Bundler::FileUtils
|
|
1695
1722
|
module NoWrite
|
1696
1723
|
include Bundler::FileUtils
|
1697
1724
|
include LowMethods
|
1698
|
-
@fileutils_output = $stderr
|
1699
|
-
@fileutils_label = ''
|
1700
1725
|
names = ::Bundler::FileUtils.collect_method(:noop)
|
1701
1726
|
names.each do |name|
|
1702
1727
|
module_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
@@ -1721,8 +1746,6 @@ module Bundler::FileUtils
|
|
1721
1746
|
module DryRun
|
1722
1747
|
include Bundler::FileUtils
|
1723
1748
|
include LowMethods
|
1724
|
-
@fileutils_output = $stderr
|
1725
|
-
@fileutils_label = ''
|
1726
1749
|
names = ::Bundler::FileUtils.collect_method(:noop)
|
1727
1750
|
names.each do |name|
|
1728
1751
|
module_eval(<<-EOS, __FILE__, __LINE__ + 1)
|