bundler 2.0.0 → 2.1.2

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 (249) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +778 -572
  3. data/LICENSE.md +18 -19
  4. data/README.md +9 -8
  5. data/bundler.gemspec +8 -25
  6. data/exe/bundle +19 -3
  7. data/lib/bundler.rb +202 -87
  8. data/lib/bundler/build_metadata.rb +3 -3
  9. data/lib/bundler/capistrano.rb +5 -5
  10. data/lib/bundler/cli.rb +182 -144
  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 +31 -11
  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 +8 -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 +19 -43
  36. data/lib/bundler/env.rb +8 -13
  37. data/lib/bundler/environment_preserver.rb +0 -1
  38. data/lib/bundler/feature_flag.rb +2 -14
  39. data/lib/bundler/fetcher.rb +16 -13
  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 +5 -2
  43. data/lib/bundler/fetcher/index.rb +5 -3
  44. data/lib/bundler/friendly_errors.rb +6 -7
  45. data/lib/bundler/gem_helper.rb +40 -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 +40 -30
  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 -3
  57. data/lib/bundler/lockfile_parser.rb +14 -21
  58. data/lib/bundler/match_platform.rb +1 -1
  59. data/lib/bundler/mirror.rb +3 -3
  60. data/lib/bundler/plugin.rb +42 -29
  61. data/lib/bundler/plugin/api.rb +1 -1
  62. data/lib/bundler/plugin/api/source.rb +4 -6
  63. data/lib/bundler/plugin/index.rb +14 -3
  64. data/lib/bundler/plugin/installer.rb +28 -15
  65. data/lib/bundler/psyched_yaml.rb +1 -1
  66. data/lib/bundler/remote_specification.rb +0 -2
  67. data/lib/bundler/resolver.rb +72 -24
  68. data/lib/bundler/resolver/spec_group.rb +3 -2
  69. data/lib/bundler/retry.rb +2 -2
  70. data/lib/bundler/ruby_version.rb +4 -19
  71. data/lib/bundler/rubygems_ext.rb +11 -67
  72. data/lib/bundler/rubygems_gem_installer.rb +1 -1
  73. data/lib/bundler/rubygems_integration.rb +148 -398
  74. data/lib/bundler/runtime.rb +2 -9
  75. data/lib/bundler/settings.rb +22 -52
  76. data/lib/bundler/setup.rb +11 -12
  77. data/lib/bundler/shared_helpers.rb +51 -77
  78. data/lib/bundler/similarity_detector.rb +2 -2
  79. data/lib/bundler/source.rb +5 -5
  80. data/lib/bundler/source/git.rb +24 -17
  81. data/lib/bundler/source/git/git_proxy.rb +38 -41
  82. data/lib/bundler/source/metadata.rb +7 -2
  83. data/lib/bundler/source/path.rb +13 -8
  84. data/lib/bundler/source/rubygems.rb +14 -8
  85. data/lib/bundler/source/rubygems/remote.rb +2 -3
  86. data/lib/bundler/source_list.rb +9 -12
  87. data/lib/bundler/spec_set.rb +1 -6
  88. data/lib/bundler/stub_specification.rb +18 -30
  89. data/lib/bundler/templates/Executable.bundler +23 -14
  90. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +3 -3
  91. data/lib/bundler/templates/newgem/Gemfile.tt +8 -0
  92. data/lib/bundler/templates/newgem/README.md.tt +4 -3
  93. data/lib/bundler/templates/newgem/newgem.gemspec.tt +6 -27
  94. data/lib/bundler/templates/newgem/test/test_helper.rb.tt +1 -1
  95. data/lib/bundler/templates/newgem/travis.yml.tt +0 -1
  96. data/lib/bundler/ui.rb +3 -3
  97. data/lib/bundler/ui/rg_proxy.rb +1 -1
  98. data/lib/bundler/ui/shell.rb +4 -8
  99. data/lib/bundler/uri_credentials_filter.rb +7 -3
  100. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +161 -0
  101. data/lib/bundler/vendor/connection_pool/lib/connection_pool/monotonic_time.rb +66 -0
  102. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +176 -0
  103. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +3 -0
  104. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +273 -147
  105. data/lib/bundler/vendor/molinillo/lib/molinillo.rb +6 -6
  106. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +2 -2
  107. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +1 -1
  108. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +1 -1
  109. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +1 -1
  110. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +1 -1
  111. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +6 -6
  112. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +1 -1
  113. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +1 -1
  114. data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +30 -8
  115. data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +1 -1
  116. data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +4 -4
  117. data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +2 -2
  118. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +273 -304
  119. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/connection.rb +40 -0
  120. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/pool.rb +53 -0
  121. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +79 -0
  122. data/lib/bundler/vendor/thor/lib/thor.rb +19 -4
  123. data/lib/bundler/vendor/thor/lib/thor/actions.rb +27 -12
  124. data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +1 -1
  125. data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +1 -1
  126. data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +7 -17
  127. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +16 -7
  128. data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +19 -8
  129. data/lib/bundler/vendor/thor/lib/thor/base.rb +54 -43
  130. data/lib/bundler/vendor/thor/lib/thor/command.rb +21 -14
  131. data/lib/bundler/vendor/thor/lib/thor/error.rb +78 -0
  132. data/lib/bundler/vendor/thor/lib/thor/group.rb +3 -3
  133. data/lib/bundler/vendor/thor/lib/thor/invocation.rb +1 -0
  134. data/lib/bundler/vendor/thor/lib/thor/line_editor.rb +2 -2
  135. data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +1 -1
  136. data/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +6 -6
  137. data/lib/bundler/vendor/thor/lib/thor/nested_context.rb +29 -0
  138. data/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -4
  139. data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +2 -2
  140. data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +20 -7
  141. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +20 -5
  142. data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +1 -0
  143. data/lib/bundler/vendor/thor/lib/thor/runner.rb +15 -14
  144. data/lib/bundler/vendor/thor/lib/thor/shell.rb +4 -4
  145. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +62 -8
  146. data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +6 -2
  147. data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +3 -3
  148. data/lib/bundler/vendor/thor/lib/thor/util.rb +18 -2
  149. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  150. data/lib/bundler/vendor/uri/lib/uri.rb +104 -0
  151. data/lib/bundler/vendor/uri/lib/uri/common.rb +744 -0
  152. data/lib/bundler/vendor/uri/lib/uri/file.rb +94 -0
  153. data/lib/bundler/vendor/uri/lib/uri/ftp.rb +267 -0
  154. data/lib/bundler/vendor/uri/lib/uri/generic.rb +1568 -0
  155. data/lib/bundler/vendor/uri/lib/uri/http.rb +88 -0
  156. data/lib/bundler/vendor/uri/lib/uri/https.rb +23 -0
  157. data/lib/bundler/vendor/uri/lib/uri/ldap.rb +261 -0
  158. data/lib/bundler/vendor/uri/lib/uri/ldaps.rb +21 -0
  159. data/lib/bundler/vendor/uri/lib/uri/mailto.rb +294 -0
  160. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +546 -0
  161. data/lib/bundler/vendor/uri/lib/uri/rfc3986_parser.rb +125 -0
  162. data/lib/bundler/vendor/uri/lib/uri/version.rb +6 -0
  163. data/lib/bundler/vendored_fileutils.rb +1 -6
  164. data/lib/bundler/vendored_molinillo.rb +1 -1
  165. data/lib/bundler/vendored_persistent.rb +7 -5
  166. data/lib/bundler/vendored_thor.rb +2 -2
  167. data/lib/bundler/vendored_uri.rb +4 -0
  168. data/lib/bundler/version.rb +1 -20
  169. data/lib/bundler/version_ranges.rb +51 -5
  170. data/lib/bundler/vlad.rb +3 -3
  171. data/lib/bundler/worker.rb +1 -3
  172. data/lib/bundler/yaml_serializer.rb +2 -3
  173. data/man/bundle-add.1 +10 -2
  174. data/man/bundle-add.1.txt +11 -5
  175. data/man/bundle-add.ronn +7 -1
  176. data/man/bundle-binstubs.1 +2 -2
  177. data/man/bundle-binstubs.1.txt +2 -2
  178. data/man/bundle-binstubs.ronn +1 -1
  179. data/man/bundle-cache.1 +55 -0
  180. data/man/bundle-cache.1.txt +78 -0
  181. data/man/{bundle-package.ronn → bundle-cache.ronn} +15 -15
  182. data/man/bundle-check.1 +1 -1
  183. data/man/bundle-check.1.txt +6 -6
  184. data/man/bundle-clean.1 +1 -1
  185. data/man/bundle-clean.1.txt +1 -1
  186. data/man/bundle-config.1 +36 -36
  187. data/man/bundle-config.1.txt +66 -67
  188. data/man/bundle-config.ronn +42 -40
  189. data/man/bundle-doctor.1 +1 -1
  190. data/man/bundle-doctor.1.txt +1 -1
  191. data/man/bundle-exec.1 +2 -2
  192. data/man/bundle-exec.1.txt +2 -2
  193. data/man/bundle-exec.ronn +1 -1
  194. data/man/bundle-gem.1 +1 -1
  195. data/man/bundle-gem.1.txt +3 -3
  196. data/man/bundle-info.1 +1 -1
  197. data/man/bundle-info.1.txt +1 -1
  198. data/man/bundle-init.1 +2 -2
  199. data/man/bundle-init.1.txt +2 -2
  200. data/man/bundle-init.ronn +1 -1
  201. data/man/bundle-inject.1 +1 -1
  202. data/man/bundle-inject.1.txt +1 -1
  203. data/man/bundle-install.1 +8 -5
  204. data/man/bundle-install.1.txt +56 -51
  205. data/man/bundle-install.ronn +9 -4
  206. data/man/bundle-list.1 +1 -1
  207. data/man/bundle-list.1.txt +1 -1
  208. data/man/bundle-lock.1 +1 -1
  209. data/man/bundle-lock.1.txt +16 -16
  210. data/man/bundle-open.1 +1 -1
  211. data/man/bundle-open.1.txt +1 -1
  212. data/man/bundle-outdated.1 +1 -1
  213. data/man/bundle-outdated.1.txt +1 -1
  214. data/man/bundle-platform.1 +1 -1
  215. data/man/bundle-platform.1.txt +1 -1
  216. data/man/bundle-pristine.1 +1 -1
  217. data/man/bundle-pristine.1.txt +1 -1
  218. data/man/bundle-remove.1 +1 -1
  219. data/man/bundle-remove.1.txt +1 -1
  220. data/man/bundle-show.1 +1 -1
  221. data/man/bundle-show.1.txt +1 -1
  222. data/man/bundle-update.1 +4 -4
  223. data/man/bundle-update.1.txt +64 -65
  224. data/man/bundle-update.ronn +3 -3
  225. data/man/bundle-viz.1 +1 -1
  226. data/man/bundle-viz.1.txt +1 -1
  227. data/man/bundle.1 +3 -3
  228. data/man/bundle.1.txt +8 -8
  229. data/man/bundle.ronn +2 -2
  230. data/man/gemfile.5 +13 -16
  231. data/man/gemfile.5.ronn +10 -14
  232. data/man/gemfile.5.txt +104 -108
  233. data/man/index.txt +1 -1
  234. metadata +33 -108
  235. data/exe/bundle_ruby +0 -60
  236. data/lib/bundler/cli/package.rb +0 -49
  237. data/lib/bundler/compatibility_guard.rb +0 -14
  238. data/lib/bundler/gem_remote_fetcher.rb +0 -43
  239. data/lib/bundler/ssl_certs/.document +0 -1
  240. data/lib/bundler/ssl_certs/certificate_manager.rb +0 -66
  241. data/lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +0 -21
  242. data/lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +0 -23
  243. data/lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +0 -25
  244. data/lib/bundler/vendor/net-http-persistent/lib/net/http/faster.rb +0 -27
  245. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse.rb +0 -129
  246. data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +0 -12
  247. data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +0 -129
  248. data/man/bundle-package.1 +0 -55
  249. data/man/bundle-package.1.txt +0 -79
@@ -0,0 +1,88 @@
1
+ # frozen_string_literal: false
2
+ # = uri/http.rb
3
+ #
4
+ # Author:: Akira Yamada <akira@ruby-lang.org>
5
+ # License:: You can redistribute it and/or modify it under the same term as Ruby.
6
+ # Revision:: $Id$
7
+ #
8
+ # See Bundler::URI for general documentation
9
+ #
10
+
11
+ require_relative 'generic'
12
+
13
+ module Bundler::URI
14
+
15
+ #
16
+ # The syntax of HTTP URIs is defined in RFC1738 section 3.3.
17
+ #
18
+ # Note that the Ruby Bundler::URI library allows HTTP URLs containing usernames and
19
+ # passwords. This is not legal as per the RFC, but used to be
20
+ # supported in Internet Explorer 5 and 6, before the MS04-004 security
21
+ # update. See <URL:http://support.microsoft.com/kb/834489>.
22
+ #
23
+ class HTTP < Generic
24
+ # A Default port of 80 for Bundler::URI::HTTP.
25
+ DEFAULT_PORT = 80
26
+
27
+ # An Array of the available components for Bundler::URI::HTTP.
28
+ COMPONENT = %i[
29
+ scheme
30
+ userinfo host port
31
+ path
32
+ query
33
+ fragment
34
+ ].freeze
35
+
36
+ #
37
+ # == Description
38
+ #
39
+ # Creates a new Bundler::URI::HTTP object from components, with syntax checking.
40
+ #
41
+ # The components accepted are userinfo, host, port, path, query, and
42
+ # fragment.
43
+ #
44
+ # The components should be provided either as an Array, or as a Hash
45
+ # with keys formed by preceding the component names with a colon.
46
+ #
47
+ # If an Array is used, the components must be passed in the
48
+ # order <code>[userinfo, host, port, path, query, fragment]</code>.
49
+ #
50
+ # Example:
51
+ #
52
+ # uri = Bundler::URI::HTTP.build(host: 'www.example.com', path: '/foo/bar')
53
+ #
54
+ # uri = Bundler::URI::HTTP.build([nil, "www.example.com", nil, "/path",
55
+ # "query", 'fragment'])
56
+ #
57
+ # Currently, if passed userinfo components this method generates
58
+ # invalid HTTP URIs as per RFC 1738.
59
+ #
60
+ def self.build(args)
61
+ tmp = Util.make_components_hash(self, args)
62
+ super(tmp)
63
+ end
64
+
65
+ #
66
+ # == Description
67
+ #
68
+ # Returns the full path for an HTTP request, as required by Net::HTTP::Get.
69
+ #
70
+ # If the Bundler::URI contains a query, the full path is Bundler::URI#path + '?' + Bundler::URI#query.
71
+ # Otherwise, the path is simply Bundler::URI#path.
72
+ #
73
+ # Example:
74
+ #
75
+ # uri = Bundler::URI::HTTP.build(path: '/foo/bar', query: 'test=true')
76
+ # uri.request_uri # => "/foo/bar?test=true"
77
+ #
78
+ def request_uri
79
+ return unless @path
80
+
81
+ url = @query ? "#@path?#@query" : @path.dup
82
+ url.start_with?(?/.freeze) ? url : ?/ + url
83
+ end
84
+ end
85
+
86
+ @@schemes['HTTP'] = HTTP
87
+
88
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: false
2
+ # = uri/https.rb
3
+ #
4
+ # Author:: Akira Yamada <akira@ruby-lang.org>
5
+ # License:: You can redistribute it and/or modify it under the same term as Ruby.
6
+ # Revision:: $Id$
7
+ #
8
+ # See Bundler::URI for general documentation
9
+ #
10
+
11
+ require_relative 'http'
12
+
13
+ module Bundler::URI
14
+
15
+ # The default port for HTTPS URIs is 443, and the scheme is 'https:' rather
16
+ # than 'http:'. Other than that, HTTPS URIs are identical to HTTP URIs;
17
+ # see Bundler::URI::HTTP.
18
+ class HTTPS < HTTP
19
+ # A Default port of 443 for Bundler::URI::HTTPS
20
+ DEFAULT_PORT = 443
21
+ end
22
+ @@schemes['HTTPS'] = HTTPS
23
+ end
@@ -0,0 +1,261 @@
1
+ # frozen_string_literal: false
2
+ # = uri/ldap.rb
3
+ #
4
+ # Author::
5
+ # Takaaki Tateishi <ttate@jaist.ac.jp>
6
+ # Akira Yamada <akira@ruby-lang.org>
7
+ # License::
8
+ # Bundler::URI::LDAP is copyrighted free software by Takaaki Tateishi and Akira Yamada.
9
+ # You can redistribute it and/or modify it under the same term as Ruby.
10
+ # Revision:: $Id$
11
+ #
12
+ # See Bundler::URI for general documentation
13
+ #
14
+
15
+ require_relative 'generic'
16
+
17
+ module Bundler::URI
18
+
19
+ #
20
+ # LDAP Bundler::URI SCHEMA (described in RFC2255).
21
+ #--
22
+ # ldap://<host>/<dn>[?<attrs>[?<scope>[?<filter>[?<extensions>]]]]
23
+ #++
24
+ class LDAP < Generic
25
+
26
+ # A Default port of 389 for Bundler::URI::LDAP.
27
+ DEFAULT_PORT = 389
28
+
29
+ # An Array of the available components for Bundler::URI::LDAP.
30
+ COMPONENT = [
31
+ :scheme,
32
+ :host, :port,
33
+ :dn,
34
+ :attributes,
35
+ :scope,
36
+ :filter,
37
+ :extensions,
38
+ ].freeze
39
+
40
+ # Scopes available for the starting point.
41
+ #
42
+ # * SCOPE_BASE - the Base DN
43
+ # * SCOPE_ONE - one level under the Base DN, not including the base DN and
44
+ # not including any entries under this
45
+ # * SCOPE_SUB - subtrees, all entries at all levels
46
+ #
47
+ SCOPE = [
48
+ SCOPE_ONE = 'one',
49
+ SCOPE_SUB = 'sub',
50
+ SCOPE_BASE = 'base',
51
+ ].freeze
52
+
53
+ #
54
+ # == Description
55
+ #
56
+ # Creates a new Bundler::URI::LDAP object from components, with syntax checking.
57
+ #
58
+ # The components accepted are host, port, dn, attributes,
59
+ # scope, filter, and extensions.
60
+ #
61
+ # The components should be provided either as an Array, or as a Hash
62
+ # with keys formed by preceding the component names with a colon.
63
+ #
64
+ # If an Array is used, the components must be passed in the
65
+ # order <code>[host, port, dn, attributes, scope, filter, extensions]</code>.
66
+ #
67
+ # Example:
68
+ #
69
+ # uri = Bundler::URI::LDAP.build({:host => 'ldap.example.com',
70
+ # :dn => '/dc=example'})
71
+ #
72
+ # uri = Bundler::URI::LDAP.build(["ldap.example.com", nil,
73
+ # "/dc=example;dc=com", "query", nil, nil, nil])
74
+ #
75
+ def self.build(args)
76
+ tmp = Util::make_components_hash(self, args)
77
+
78
+ if tmp[:dn]
79
+ tmp[:path] = tmp[:dn]
80
+ end
81
+
82
+ query = []
83
+ [:extensions, :filter, :scope, :attributes].collect do |x|
84
+ next if !tmp[x] && query.size == 0
85
+ query.unshift(tmp[x])
86
+ end
87
+
88
+ tmp[:query] = query.join('?')
89
+
90
+ return super(tmp)
91
+ end
92
+
93
+ #
94
+ # == Description
95
+ #
96
+ # Creates a new Bundler::URI::LDAP object from generic Bundler::URI components as per
97
+ # RFC 2396. No LDAP-specific syntax checking is performed.
98
+ #
99
+ # Arguments are +scheme+, +userinfo+, +host+, +port+, +registry+, +path+,
100
+ # +opaque+, +query+, and +fragment+, in that order.
101
+ #
102
+ # Example:
103
+ #
104
+ # uri = Bundler::URI::LDAP.new("ldap", nil, "ldap.example.com", nil, nil,
105
+ # "/dc=example;dc=com", nil, "query", nil)
106
+ #
107
+ # See also Bundler::URI::Generic.new.
108
+ #
109
+ def initialize(*arg)
110
+ super(*arg)
111
+
112
+ if @fragment
113
+ raise InvalidURIError, 'bad LDAP URL'
114
+ end
115
+
116
+ parse_dn
117
+ parse_query
118
+ end
119
+
120
+ # Private method to cleanup +dn+ from using the +path+ component attribute.
121
+ def parse_dn
122
+ @dn = @path[1..-1]
123
+ end
124
+ private :parse_dn
125
+
126
+ # Private method to cleanup +attributes+, +scope+, +filter+, and +extensions+
127
+ # from using the +query+ component attribute.
128
+ def parse_query
129
+ @attributes = nil
130
+ @scope = nil
131
+ @filter = nil
132
+ @extensions = nil
133
+
134
+ if @query
135
+ attrs, scope, filter, extensions = @query.split('?')
136
+
137
+ @attributes = attrs if attrs && attrs.size > 0
138
+ @scope = scope if scope && scope.size > 0
139
+ @filter = filter if filter && filter.size > 0
140
+ @extensions = extensions if extensions && extensions.size > 0
141
+ end
142
+ end
143
+ private :parse_query
144
+
145
+ # Private method to assemble +query+ from +attributes+, +scope+, +filter+, and +extensions+.
146
+ def build_path_query
147
+ @path = '/' + @dn
148
+
149
+ query = []
150
+ [@extensions, @filter, @scope, @attributes].each do |x|
151
+ next if !x && query.size == 0
152
+ query.unshift(x)
153
+ end
154
+ @query = query.join('?')
155
+ end
156
+ private :build_path_query
157
+
158
+ # Returns dn.
159
+ def dn
160
+ @dn
161
+ end
162
+
163
+ # Private setter for dn +val+.
164
+ def set_dn(val)
165
+ @dn = val
166
+ build_path_query
167
+ @dn
168
+ end
169
+ protected :set_dn
170
+
171
+ # Setter for dn +val+.
172
+ def dn=(val)
173
+ set_dn(val)
174
+ val
175
+ end
176
+
177
+ # Returns attributes.
178
+ def attributes
179
+ @attributes
180
+ end
181
+
182
+ # Private setter for attributes +val+.
183
+ def set_attributes(val)
184
+ @attributes = val
185
+ build_path_query
186
+ @attributes
187
+ end
188
+ protected :set_attributes
189
+
190
+ # Setter for attributes +val+.
191
+ def attributes=(val)
192
+ set_attributes(val)
193
+ val
194
+ end
195
+
196
+ # Returns scope.
197
+ def scope
198
+ @scope
199
+ end
200
+
201
+ # Private setter for scope +val+.
202
+ def set_scope(val)
203
+ @scope = val
204
+ build_path_query
205
+ @scope
206
+ end
207
+ protected :set_scope
208
+
209
+ # Setter for scope +val+.
210
+ def scope=(val)
211
+ set_scope(val)
212
+ val
213
+ end
214
+
215
+ # Returns filter.
216
+ def filter
217
+ @filter
218
+ end
219
+
220
+ # Private setter for filter +val+.
221
+ def set_filter(val)
222
+ @filter = val
223
+ build_path_query
224
+ @filter
225
+ end
226
+ protected :set_filter
227
+
228
+ # Setter for filter +val+.
229
+ def filter=(val)
230
+ set_filter(val)
231
+ val
232
+ end
233
+
234
+ # Returns extensions.
235
+ def extensions
236
+ @extensions
237
+ end
238
+
239
+ # Private setter for extensions +val+.
240
+ def set_extensions(val)
241
+ @extensions = val
242
+ build_path_query
243
+ @extensions
244
+ end
245
+ protected :set_extensions
246
+
247
+ # Setter for extensions +val+.
248
+ def extensions=(val)
249
+ set_extensions(val)
250
+ val
251
+ end
252
+
253
+ # Checks if Bundler::URI has a path.
254
+ # For Bundler::URI::LDAP this will return +false+.
255
+ def hierarchical?
256
+ false
257
+ end
258
+ end
259
+
260
+ @@schemes['LDAP'] = LDAP
261
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: false
2
+ # = uri/ldap.rb
3
+ #
4
+ # License:: You can redistribute it and/or modify it under the same term as Ruby.
5
+ #
6
+ # See Bundler::URI for general documentation
7
+ #
8
+
9
+ require_relative 'ldap'
10
+
11
+ module Bundler::URI
12
+
13
+ # The default port for LDAPS URIs is 636, and the scheme is 'ldaps:' rather
14
+ # than 'ldap:'. Other than that, LDAPS URIs are identical to LDAP URIs;
15
+ # see Bundler::URI::LDAP.
16
+ class LDAPS < LDAP
17
+ # A Default port of 636 for Bundler::URI::LDAPS
18
+ DEFAULT_PORT = 636
19
+ end
20
+ @@schemes['LDAPS'] = LDAPS
21
+ end
@@ -0,0 +1,294 @@
1
+ # frozen_string_literal: false
2
+ # = uri/mailto.rb
3
+ #
4
+ # Author:: Akira Yamada <akira@ruby-lang.org>
5
+ # License:: You can redistribute it and/or modify it under the same term as Ruby.
6
+ # Revision:: $Id$
7
+ #
8
+ # See Bundler::URI for general documentation
9
+ #
10
+
11
+ require_relative 'generic'
12
+
13
+ module Bundler::URI
14
+
15
+ #
16
+ # RFC6068, the mailto URL scheme.
17
+ #
18
+ class MailTo < Generic
19
+ include REGEXP
20
+
21
+ # A Default port of nil for Bundler::URI::MailTo.
22
+ DEFAULT_PORT = nil
23
+
24
+ # An Array of the available components for Bundler::URI::MailTo.
25
+ COMPONENT = [ :scheme, :to, :headers ].freeze
26
+
27
+ # :stopdoc:
28
+ # "hname" and "hvalue" are encodings of an RFC 822 header name and
29
+ # value, respectively. As with "to", all URL reserved characters must
30
+ # be encoded.
31
+ #
32
+ # "#mailbox" is as specified in RFC 822 [RFC822]. This means that it
33
+ # consists of zero or more comma-separated mail addresses, possibly
34
+ # including "phrase" and "comment" components. Note that all URL
35
+ # reserved characters in "to" must be encoded: in particular,
36
+ # parentheses, commas, and the percent sign ("%"), which commonly occur
37
+ # in the "mailbox" syntax.
38
+ #
39
+ # Within mailto URLs, the characters "?", "=", "&" are reserved.
40
+
41
+ # ; RFC 6068
42
+ # hfields = "?" hfield *( "&" hfield )
43
+ # hfield = hfname "=" hfvalue
44
+ # hfname = *qchar
45
+ # hfvalue = *qchar
46
+ # qchar = unreserved / pct-encoded / some-delims
47
+ # some-delims = "!" / "$" / "'" / "(" / ")" / "*"
48
+ # / "+" / "," / ";" / ":" / "@"
49
+ #
50
+ # ; RFC3986
51
+ # unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~"
52
+ # pct-encoded = "%" HEXDIG HEXDIG
53
+ HEADER_REGEXP = /\A(?<hfield>(?:%\h\h|[!$'-.0-;@-Z_a-z~])*=(?:%\h\h|[!$'-.0-;@-Z_a-z~])*)(?:&\g<hfield>)*\z/
54
+ # practical regexp for email address
55
+ # https://html.spec.whatwg.org/multipage/input.html#valid-e-mail-address
56
+ EMAIL_REGEXP = /\A[a-zA-Z0-9.!\#$%&'*+\/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*\z/
57
+ # :startdoc:
58
+
59
+ #
60
+ # == Description
61
+ #
62
+ # Creates a new Bundler::URI::MailTo object from components, with syntax checking.
63
+ #
64
+ # Components can be provided as an Array or Hash. If an Array is used,
65
+ # the components must be supplied as <code>[to, headers]</code>.
66
+ #
67
+ # If a Hash is used, the keys are the component names preceded by colons.
68
+ #
69
+ # The headers can be supplied as a pre-encoded string, such as
70
+ # <code>"subject=subscribe&cc=address"</code>, or as an Array of Arrays
71
+ # like <code>[['subject', 'subscribe'], ['cc', 'address']]</code>.
72
+ #
73
+ # Examples:
74
+ #
75
+ # require 'bundler/vendor/uri/lib/uri'
76
+ #
77
+ # m1 = Bundler::URI::MailTo.build(['joe@example.com', 'subject=Ruby'])
78
+ # m1.to_s # => "mailto:joe@example.com?subject=Ruby"
79
+ #
80
+ # m2 = Bundler::URI::MailTo.build(['john@example.com', [['Subject', 'Ruby'], ['Cc', 'jack@example.com']]])
81
+ # m2.to_s # => "mailto:john@example.com?Subject=Ruby&Cc=jack@example.com"
82
+ #
83
+ # m3 = Bundler::URI::MailTo.build({:to => 'listman@example.com', :headers => [['subject', 'subscribe']]})
84
+ # m3.to_s # => "mailto:listman@example.com?subject=subscribe"
85
+ #
86
+ def self.build(args)
87
+ tmp = Util.make_components_hash(self, args)
88
+
89
+ case tmp[:to]
90
+ when Array
91
+ tmp[:opaque] = tmp[:to].join(',')
92
+ when String
93
+ tmp[:opaque] = tmp[:to].dup
94
+ else
95
+ tmp[:opaque] = ''
96
+ end
97
+
98
+ if tmp[:headers]
99
+ query =
100
+ case tmp[:headers]
101
+ when Array
102
+ tmp[:headers].collect { |x|
103
+ if x.kind_of?(Array)
104
+ x[0] + '=' + x[1..-1].join
105
+ else
106
+ x.to_s
107
+ end
108
+ }.join('&')
109
+ when Hash
110
+ tmp[:headers].collect { |h,v|
111
+ h + '=' + v
112
+ }.join('&')
113
+ else
114
+ tmp[:headers].to_s
115
+ end
116
+ unless query.empty?
117
+ tmp[:opaque] << '?' << query
118
+ end
119
+ end
120
+
121
+ super(tmp)
122
+ end
123
+
124
+ #
125
+ # == Description
126
+ #
127
+ # Creates a new Bundler::URI::MailTo object from generic URL components with
128
+ # no syntax checking.
129
+ #
130
+ # This method is usually called from Bundler::URI::parse, which checks
131
+ # the validity of each component.
132
+ #
133
+ def initialize(*arg)
134
+ super(*arg)
135
+
136
+ @to = nil
137
+ @headers = []
138
+
139
+ # The RFC3986 parser does not normally populate opaque
140
+ @opaque = "?#{@query}" if @query && !@opaque
141
+
142
+ unless @opaque
143
+ raise InvalidComponentError,
144
+ "missing opaque part for mailto URL"
145
+ end
146
+ to, header = @opaque.split('?', 2)
147
+ # allow semicolon as a addr-spec separator
148
+ # http://support.microsoft.com/kb/820868
149
+ unless /\A(?:[^@,;]+@[^@,;]+(?:\z|[,;]))*\z/ =~ to
150
+ raise InvalidComponentError,
151
+ "unrecognised opaque part for mailtoURL: #{@opaque}"
152
+ end
153
+
154
+ if arg[10] # arg_check
155
+ self.to = to
156
+ self.headers = header
157
+ else
158
+ set_to(to)
159
+ set_headers(header)
160
+ end
161
+ end
162
+
163
+ # The primary e-mail address of the URL, as a String.
164
+ attr_reader :to
165
+
166
+ # E-mail headers set by the URL, as an Array of Arrays.
167
+ attr_reader :headers
168
+
169
+ # Checks the to +v+ component.
170
+ def check_to(v)
171
+ return true unless v
172
+ return true if v.size == 0
173
+
174
+ v.split(/[,;]/).each do |addr|
175
+ # check url safety as path-rootless
176
+ if /\A(?:%\h\h|[!$&-.0-;=@-Z_a-z~])*\z/ !~ addr
177
+ raise InvalidComponentError,
178
+ "an address in 'to' is invalid as Bundler::URI #{addr.dump}"
179
+ end
180
+
181
+ # check addr-spec
182
+ # don't s/\+/ /g
183
+ addr.gsub!(/%\h\h/, Bundler::URI::TBLDECWWWCOMP_)
184
+ if EMAIL_REGEXP !~ addr
185
+ raise InvalidComponentError,
186
+ "an address in 'to' is invalid as uri-escaped addr-spec #{addr.dump}"
187
+ end
188
+ end
189
+
190
+ true
191
+ end
192
+ private :check_to
193
+
194
+ # Private setter for to +v+.
195
+ def set_to(v)
196
+ @to = v
197
+ end
198
+ protected :set_to
199
+
200
+ # Setter for to +v+.
201
+ def to=(v)
202
+ check_to(v)
203
+ set_to(v)
204
+ v
205
+ end
206
+
207
+ # Checks the headers +v+ component against either
208
+ # * HEADER_REGEXP
209
+ def check_headers(v)
210
+ return true unless v
211
+ return true if v.size == 0
212
+ if HEADER_REGEXP !~ v
213
+ raise InvalidComponentError,
214
+ "bad component(expected opaque component): #{v}"
215
+ end
216
+
217
+ true
218
+ end
219
+ private :check_headers
220
+
221
+ # Private setter for headers +v+.
222
+ def set_headers(v)
223
+ @headers = []
224
+ if v
225
+ v.split('&').each do |x|
226
+ @headers << x.split(/=/, 2)
227
+ end
228
+ end
229
+ end
230
+ protected :set_headers
231
+
232
+ # Setter for headers +v+.
233
+ def headers=(v)
234
+ check_headers(v)
235
+ set_headers(v)
236
+ v
237
+ end
238
+
239
+ # Constructs String from Bundler::URI.
240
+ def to_s
241
+ @scheme + ':' +
242
+ if @to
243
+ @to
244
+ else
245
+ ''
246
+ end +
247
+ if @headers.size > 0
248
+ '?' + @headers.collect{|x| x.join('=')}.join('&')
249
+ else
250
+ ''
251
+ end +
252
+ if @fragment
253
+ '#' + @fragment
254
+ else
255
+ ''
256
+ end
257
+ end
258
+
259
+ # Returns the RFC822 e-mail text equivalent of the URL, as a String.
260
+ #
261
+ # Example:
262
+ #
263
+ # require 'bundler/vendor/uri/lib/uri'
264
+ #
265
+ # uri = Bundler::URI.parse("mailto:ruby-list@ruby-lang.org?Subject=subscribe&cc=myaddr")
266
+ # uri.to_mailtext
267
+ # # => "To: ruby-list@ruby-lang.org\nSubject: subscribe\nCc: myaddr\n\n\n"
268
+ #
269
+ def to_mailtext
270
+ to = Bundler::URI.decode_www_form_component(@to)
271
+ head = ''
272
+ body = ''
273
+ @headers.each do |x|
274
+ case x[0]
275
+ when 'body'
276
+ body = Bundler::URI.decode_www_form_component(x[1])
277
+ when 'to'
278
+ to << ', ' + Bundler::URI.decode_www_form_component(x[1])
279
+ else
280
+ head << Bundler::URI.decode_www_form_component(x[0]).capitalize + ': ' +
281
+ Bundler::URI.decode_www_form_component(x[1]) + "\n"
282
+ end
283
+ end
284
+
285
+ "To: #{to}
286
+ #{head}
287
+ #{body}
288
+ "
289
+ end
290
+ alias to_rfc822text to_mailtext
291
+ end
292
+
293
+ @@schemes['MAILTO'] = MailTo
294
+ end