bundler 2.6.9 → 4.0.11

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.
Files changed (191) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +2229 -1879
  3. data/README.md +11 -11
  4. data/bundler.gemspec +5 -5
  5. data/lib/bundler/build_metadata.rb +10 -11
  6. data/lib/bundler/capistrano.rb +1 -19
  7. data/lib/bundler/checksum.rb +6 -0
  8. data/lib/bundler/cli/add.rb +10 -0
  9. data/lib/bundler/cli/cache.rb +1 -12
  10. data/lib/bundler/cli/common.rb +21 -4
  11. data/lib/bundler/cli/config.rb +1 -2
  12. data/lib/bundler/cli/console.rb +5 -0
  13. data/lib/bundler/cli/exec.rb +29 -4
  14. data/lib/bundler/cli/gem.rb +90 -64
  15. data/lib/bundler/cli/install.rb +15 -90
  16. data/lib/bundler/cli/issue.rb +2 -2
  17. data/lib/bundler/cli/list.rb +33 -2
  18. data/lib/bundler/cli/lock.rb +5 -5
  19. data/lib/bundler/cli/outdated.rb +1 -1
  20. data/lib/bundler/cli/plugin.rb +5 -1
  21. data/lib/bundler/cli/pristine.rb +5 -1
  22. data/lib/bundler/cli/show.rb +3 -7
  23. data/lib/bundler/cli/update.rb +5 -5
  24. data/lib/bundler/cli.rb +162 -127
  25. data/lib/bundler/compact_index_client.rb +1 -6
  26. data/lib/bundler/current_ruby.rb +17 -5
  27. data/lib/bundler/definition.rb +201 -117
  28. data/lib/bundler/dependency.rb +1 -1
  29. data/lib/bundler/deployment.rb +1 -64
  30. data/lib/bundler/digest.rb +1 -1
  31. data/lib/bundler/dsl.rb +48 -48
  32. data/lib/bundler/environment_preserver.rb +1 -0
  33. data/lib/bundler/errors.rb +1 -5
  34. data/lib/bundler/feature_flag.rb +5 -35
  35. data/lib/bundler/fetcher/compact_index.rb +1 -1
  36. data/lib/bundler/fetcher/dependency.rb +9 -2
  37. data/lib/bundler/fetcher/downloader.rb +33 -8
  38. data/lib/bundler/fetcher/gem_remote_fetcher.rb +6 -0
  39. data/lib/bundler/fetcher.rb +49 -19
  40. data/lib/bundler/friendly_errors.rb +4 -3
  41. data/lib/bundler/index.rb +7 -9
  42. data/lib/bundler/injector.rb +1 -2
  43. data/lib/bundler/inline.rb +9 -1
  44. data/lib/bundler/installer/gem_installer.rb +14 -11
  45. data/lib/bundler/installer/parallel_installer.rb +74 -36
  46. data/lib/bundler/installer.rb +6 -19
  47. data/lib/bundler/lazy_specification.rb +47 -20
  48. data/lib/bundler/lockfile_generator.rb +17 -2
  49. data/lib/bundler/lockfile_parser.rb +19 -6
  50. data/lib/bundler/man/bundle-add.1 +1 -1
  51. data/lib/bundler/man/bundle-binstubs.1 +3 -6
  52. data/lib/bundler/man/bundle-binstubs.1.ronn +4 -6
  53. data/lib/bundler/man/bundle-cache.1 +2 -14
  54. data/lib/bundler/man/bundle-cache.1.ronn +1 -14
  55. data/lib/bundler/man/bundle-check.1 +2 -5
  56. data/lib/bundler/man/bundle-check.1.ronn +0 -5
  57. data/lib/bundler/man/bundle-clean.1 +1 -1
  58. data/lib/bundler/man/bundle-config.1 +206 -148
  59. data/lib/bundler/man/bundle-config.1.ronn +136 -119
  60. data/lib/bundler/man/bundle-console.1 +1 -1
  61. data/lib/bundler/man/bundle-doctor.1 +43 -4
  62. data/lib/bundler/man/bundle-doctor.1.ronn +48 -4
  63. data/lib/bundler/man/bundle-env.1 +1 -1
  64. data/lib/bundler/man/bundle-exec.1 +2 -5
  65. data/lib/bundler/man/bundle-exec.1.ronn +1 -5
  66. data/lib/bundler/man/bundle-fund.1 +1 -1
  67. data/lib/bundler/man/bundle-gem.1 +64 -44
  68. data/lib/bundler/man/bundle-gem.1.ronn +10 -9
  69. data/lib/bundler/man/bundle-help.1 +1 -1
  70. data/lib/bundler/man/bundle-info.1 +1 -1
  71. data/lib/bundler/man/bundle-init.1 +1 -1
  72. data/lib/bundler/man/bundle-install.1 +16 -59
  73. data/lib/bundler/man/bundle-install.1.ronn +27 -108
  74. data/lib/bundler/man/bundle-issue.1 +1 -1
  75. data/lib/bundler/man/bundle-licenses.1 +1 -1
  76. data/lib/bundler/man/bundle-list.1 +6 -1
  77. data/lib/bundler/man/bundle-list.1.ronn +5 -0
  78. data/lib/bundler/man/bundle-lock.1 +1 -1
  79. data/lib/bundler/man/bundle-open.1 +1 -1
  80. data/lib/bundler/man/bundle-outdated.1 +1 -1
  81. data/lib/bundler/man/bundle-platform.1 +1 -1
  82. data/lib/bundler/man/bundle-plugin.1 +33 -15
  83. data/lib/bundler/man/bundle-plugin.1.ronn +36 -15
  84. data/lib/bundler/man/bundle-pristine.1 +1 -1
  85. data/lib/bundler/man/bundle-remove.1 +2 -8
  86. data/lib/bundler/man/bundle-remove.1.ronn +1 -8
  87. data/lib/bundler/man/bundle-show.1 +2 -5
  88. data/lib/bundler/man/bundle-show.1.ronn +0 -4
  89. data/lib/bundler/man/bundle-update.1 +5 -5
  90. data/lib/bundler/man/bundle-update.1.ronn +4 -4
  91. data/lib/bundler/man/bundle-version.1 +1 -1
  92. data/lib/bundler/man/bundle.1 +1 -10
  93. data/lib/bundler/man/bundle.1.ronn +0 -9
  94. data/lib/bundler/man/gemfile.5 +32 -1
  95. data/lib/bundler/man/gemfile.5.ronn +28 -0
  96. data/lib/bundler/man/index.txt +0 -2
  97. data/lib/bundler/match_platform.rb +31 -12
  98. data/lib/bundler/materialization.rb +3 -3
  99. data/lib/bundler/plugin/api/source.rb +8 -0
  100. data/lib/bundler/plugin/index.rb +6 -0
  101. data/lib/bundler/plugin/installer.rb +2 -11
  102. data/lib/bundler/plugin/source_list.rb +1 -1
  103. data/lib/bundler/plugin.rb +7 -4
  104. data/lib/bundler/resolver/package.rb +2 -1
  105. data/lib/bundler/resolver/strategy.rb +6 -3
  106. data/lib/bundler/resolver.rb +20 -4
  107. data/lib/bundler/retry.rb +30 -4
  108. data/lib/bundler/ruby_dsl.rb +17 -12
  109. data/lib/bundler/ruby_version.rb +1 -3
  110. data/lib/bundler/rubygems_ext.rb +117 -121
  111. data/lib/bundler/rubygems_gem_installer.rb +5 -4
  112. data/lib/bundler/rubygems_integration.rb +13 -12
  113. data/lib/bundler/runtime.rb +14 -3
  114. data/lib/bundler/self_manager.rb +34 -43
  115. data/lib/bundler/settings/validator.rb +5 -21
  116. data/lib/bundler/settings.rb +17 -32
  117. data/lib/bundler/shared_helpers.rb +12 -18
  118. data/lib/bundler/source/gemspec.rb +4 -0
  119. data/lib/bundler/source/git/git_proxy.rb +55 -29
  120. data/lib/bundler/source/git.rb +2 -3
  121. data/lib/bundler/source/metadata.rb +4 -0
  122. data/lib/bundler/source/path.rb +12 -7
  123. data/lib/bundler/source/rubygems.rb +59 -43
  124. data/lib/bundler/source/rubygems_aggregate.rb +4 -1
  125. data/lib/bundler/source.rb +3 -1
  126. data/lib/bundler/source_list.rb +5 -50
  127. data/lib/bundler/source_map.rb +8 -7
  128. data/lib/bundler/spec_set.rb +9 -14
  129. data/lib/bundler/stub_specification.rb +1 -0
  130. data/lib/bundler/templates/Executable +0 -11
  131. data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +7 -129
  132. data/lib/bundler/templates/newgem/Cargo.toml.tt +6 -0
  133. data/lib/bundler/templates/newgem/Rakefile.tt +5 -0
  134. data/lib/bundler/templates/newgem/circleci/config.yml.tt +12 -0
  135. data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +8 -1
  136. data/lib/bundler/templates/newgem/ext/newgem/build.rs.tt +5 -0
  137. data/lib/bundler/templates/newgem/ext/newgem/extconf-go.rb.tt +11 -0
  138. data/lib/bundler/templates/newgem/ext/newgem/go.mod.tt +5 -0
  139. data/lib/bundler/templates/newgem/ext/newgem/newgem-go.c.tt +2 -0
  140. data/lib/bundler/templates/newgem/ext/newgem/newgem.go.tt +31 -0
  141. data/lib/bundler/templates/newgem/ext/newgem/src/lib.rs.tt +13 -2
  142. data/lib/bundler/templates/newgem/github/workflows/build-gems.yml.tt +69 -0
  143. data/lib/bundler/templates/newgem/github/workflows/main.yml.tt +12 -1
  144. data/lib/bundler/templates/newgem/gitlab-ci.yml.tt +9 -0
  145. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +1 -1
  146. data/lib/bundler/templates/newgem/newgem.gemspec.tt +17 -11
  147. data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +8 -0
  148. data/lib/bundler/templates/newgem/test/minitest/test_newgem.rb.tt +6 -0
  149. data/lib/bundler/ui/shell.rb +12 -8
  150. data/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +26 -23
  151. data/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  152. data/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +50 -6
  153. data/lib/bundler/vendor/fileutils/lib/fileutils.rb +57 -52
  154. data/lib/bundler/vendor/net-http-persistent/README.rdoc +1 -1
  155. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/timed_stack_multi.rb +2 -1
  156. data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +84 -42
  157. data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +42 -6
  158. data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +1 -1
  159. data/lib/bundler/vendor/thor/lib/thor/runner.rb +2 -2
  160. data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +3 -7
  161. data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
  162. data/lib/bundler/vendor/thor/lib/thor.rb +1 -1
  163. data/lib/bundler/vendor/uri/lib/uri/common.rb +57 -15
  164. data/lib/bundler/vendor/uri/lib/uri/file.rb +1 -1
  165. data/lib/bundler/vendor/uri/lib/uri/generic.rb +34 -21
  166. data/lib/bundler/vendor/uri/lib/uri/http.rb +12 -0
  167. data/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +9 -8
  168. data/lib/bundler/vendor/uri/lib/uri/version.rb +2 -2
  169. data/lib/bundler/version.rb +10 -2
  170. data/lib/bundler/vlad.rb +1 -14
  171. data/lib/bundler/worker.rb +12 -4
  172. data/lib/bundler.rb +20 -40
  173. metadata +13 -25
  174. data/lib/bundler/cli/inject.rb +0 -60
  175. data/lib/bundler/cli/viz.rb +0 -31
  176. data/lib/bundler/gem_helpers.rb +0 -144
  177. data/lib/bundler/graph.rb +0 -152
  178. data/lib/bundler/man/bundle-inject.1 +0 -31
  179. data/lib/bundler/man/bundle-inject.1.ronn +0 -32
  180. data/lib/bundler/man/bundle-viz.1 +0 -30
  181. data/lib/bundler/man/bundle-viz.1.ronn +0 -36
  182. data/lib/bundler/similarity_detector.rb +0 -63
  183. data/lib/bundler/templates/Executable.bundler +0 -109
  184. data/lib/bundler/vendor/connection_pool/.document +0 -1
  185. data/lib/bundler/vendor/fileutils/.document +0 -1
  186. data/lib/bundler/vendor/net-http-persistent/.document +0 -1
  187. data/lib/bundler/vendor/pub_grub/.document +0 -1
  188. data/lib/bundler/vendor/securerandom/.document +0 -1
  189. data/lib/bundler/vendor/thor/.document +0 -1
  190. data/lib/bundler/vendor/tsort/.document +0 -1
  191. data/lib/bundler/vendor/uri/.document +0 -1
@@ -6,6 +6,10 @@ jobs:
6
6
  <%- if config[:ext] == 'rust' -%>
7
7
  environment:
8
8
  RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN: 'true'
9
+ <%- end -%>
10
+ <%- if config[:ext] == 'go' -%>
11
+ environment:
12
+ GO_VERSION: '1.23.0'
9
13
  <%- end -%>
10
14
  steps:
11
15
  - checkout
@@ -16,6 +20,14 @@ jobs:
16
20
  - run:
17
21
  name: Install a RubyGems version that can compile rust extensions
18
22
  command: gem update --system '<%= ::Gem.rubygems_version %>'
23
+ <%- end -%>
24
+ <%- if config[:ext] == 'go' -%>
25
+ - run:
26
+ name: Install Go
27
+ command: |
28
+ wget https://go.dev/dl/go$GO_VERSION.linux-amd64.tar.gz -O /tmp/go.tar.gz
29
+ tar -C /usr/local -xzf /tmp/go.tar.gz
30
+ echo 'export PATH=/usr/local/go/bin:"$PATH"' >> "$BASH_ENV"
19
31
  <%- end -%>
20
32
  - run:
21
33
  name: Run the default task
@@ -12,4 +12,11 @@ publish = false
12
12
  crate-type = ["cdylib"]
13
13
 
14
14
  [dependencies]
15
- magnus = { version = "0.6.2" }
15
+ magnus = { version = "0.8.2" }
16
+ rb-sys = { version = "0.9", features = ["stable-api-compiled-fallback"] }
17
+
18
+ [build-dependencies]
19
+ rb-sys-env = "0.2.2"
20
+
21
+ [dev-dependencies]
22
+ rb-sys-test-helpers = { version = "0.2.2" }
@@ -0,0 +1,5 @@
1
+ pub fn main() -> Result<(), Box<dyn std::error::Error>> {
2
+ let _ = rb_sys_env::activate()?;
3
+
4
+ Ok(())
5
+ }
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "mkmf"
4
+ require "go_gem/mkmf"
5
+
6
+ # Makes all symbols private by default to avoid unintended conflict
7
+ # with other gems. To explicitly export symbols you can use RUBY_FUNC_EXPORTED
8
+ # selectively, or entirely remove this flag.
9
+ append_cflags("-fvisibility=hidden")
10
+
11
+ create_go_makefile(<%= config[:makefile_path].inspect %>)
@@ -0,0 +1,5 @@
1
+ module github.com/<%= config[:go_module_username] %>/<%= config[:underscored_name] %>
2
+
3
+ go 1.23
4
+
5
+ require github.com/ruby-go-gem/go-gem-wrapper latest
@@ -0,0 +1,2 @@
1
+ #include "<%= config[:underscored_name] %>.h"
2
+ #include "_cgo_export.h"
@@ -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
+ }
@@ -1,7 +1,7 @@
1
1
  use magnus::{function, prelude::*, Error, Ruby};
2
2
 
3
- fn hello(subject: String) -> String {
4
- format!("Hello from Rust, {subject}!")
3
+ pub fn hello(subject: String) -> String {
4
+ format!("Hello {subject}, from Rust!")
5
5
  }
6
6
 
7
7
  #[magnus::init]
@@ -10,3 +10,14 @@ fn init(ruby: &Ruby) -> Result<(), Error> {
10
10
  module.define_singleton_method("hello", function!(hello, 1))?;
11
11
  Ok(())
12
12
  }
13
+
14
+ #[cfg(test)]
15
+ mod tests {
16
+ use rb_sys_test_helpers::ruby_test;
17
+ use super::hello;
18
+
19
+ #[ruby_test]
20
+ fn test_hello() {
21
+ assert_eq!("Hello world, from Rust!", hello("world".to_string()));
22
+ }
23
+ }
@@ -0,0 +1,69 @@
1
+ ---
2
+ name: Build gems
3
+
4
+ on:
5
+ push:
6
+ tags:
7
+ - "v*"
8
+ - "cross-gem/*"
9
+ workflow_dispatch:
10
+
11
+ permissions:
12
+ contents: read
13
+ packages: write
14
+
15
+ jobs:
16
+ ci-data:
17
+ runs-on: ubuntu-latest
18
+ outputs:
19
+ result: ${{ steps.fetch.outputs.result }}
20
+ steps:
21
+ - uses: oxidize-rb/actions/fetch-ci-data@v1
22
+ id: fetch
23
+ with:
24
+ supported-ruby-platforms: |
25
+ exclude: ["arm-linux", "x64-mingw32"]
26
+ stable-ruby-versions: |
27
+ exclude: ["head"]
28
+
29
+ source-gem:
30
+ runs-on: ubuntu-latest
31
+ steps:
32
+ - uses: actions/checkout@v6
33
+
34
+ - uses: ruby/setup-ruby@v1
35
+ with:
36
+ bundler-cache: true
37
+
38
+ - name: Build gem
39
+ run: bundle exec rake build
40
+
41
+ - uses: actions/upload-artifact@v7
42
+ with:
43
+ name: source-gem
44
+ path: pkg/*.gem
45
+
46
+ cross-gem:
47
+ name: Compile native gem for ${{ matrix.platform }}
48
+ runs-on: ubuntu-latest
49
+ needs: ci-data
50
+ strategy:
51
+ matrix:
52
+ platform: ${{ fromJSON(needs.ci-data.outputs.result).supported-ruby-platforms }}
53
+ steps:
54
+ - uses: actions/checkout@v6
55
+
56
+ - uses: ruby/setup-ruby@v1
57
+ with:
58
+ bundler-cache: true
59
+
60
+ - uses: oxidize-rb/actions/cross-gem@v1
61
+ id: cross-gem
62
+ with:
63
+ platform: ${{ matrix.platform }}
64
+ ruby-versions: ${{ join(fromJSON(needs.ci-data.outputs.result).stable-ruby-versions, ',') }}
65
+
66
+ - uses: actions/upload-artifact@v7
67
+ with:
68
+ name: cross-gem
69
+ path: ${{ steps.cross-gem.outputs.gem-path }}
@@ -7,6 +7,9 @@ on:
7
7
 
8
8
  pull_request:
9
9
 
10
+ permissions:
11
+ contents: read
12
+
10
13
  jobs:
11
14
  build:
12
15
  runs-on: ubuntu-latest
@@ -17,7 +20,9 @@ jobs:
17
20
  - '<%= RUBY_VERSION %>'
18
21
 
19
22
  steps:
20
- - uses: actions/checkout@v4
23
+ - uses: actions/checkout@v6
24
+ with:
25
+ persist-credentials: false
21
26
  <%- if config[:ext] == 'rust' -%>
22
27
  - name: Set up Ruby & Rust
23
28
  uses: oxidize-rb/actions/setup-ruby-and-rust@v1
@@ -32,6 +37,12 @@ jobs:
32
37
  with:
33
38
  ruby-version: ${{ matrix.ruby }}
34
39
  bundler-cache: true
40
+ <%- end -%>
41
+ <%- if config[:ext] == 'go' -%>
42
+ - name: Setup Go
43
+ uses: actions/setup-go@v5
44
+ with:
45
+ go-version-file: ext/<%= config[:underscored_name] %>/go.mod
35
46
  <%- end -%>
36
47
  - name: Run the default task
37
48
  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
@@ -2,7 +2,7 @@
2
2
 
3
3
  require_relative "<%= File.basename(config[:namespaced_path]) %>/version"
4
4
  <%- if config[:ext] -%>
5
- require_relative "<%= File.basename(config[:namespaced_path]) %>/<%= config[:underscored_name] %>"
5
+ require "<%= File.basename(config[:namespaced_path]) %>/<%= config[:underscored_name] %>"
6
6
  <%- end -%>
7
7
 
8
8
  <%- config[:constant_array].each_with_index do |c, i| -%>
@@ -10,20 +10,23 @@ Gem::Specification.new do |spec|
10
10
 
11
11
  spec.summary = "TODO: Write a short summary, because RubyGems requires one."
12
12
  spec.description = "TODO: Write a longer description or delete this line."
13
- spec.homepage = "TODO: Put your gem's website or public repo URL here."
13
+ spec.homepage = "<%= config[:homepage_uri] %>"
14
14
  <%- if config[:mit] -%>
15
15
  spec.license = "MIT"
16
16
  <%- end -%>
17
17
  spec.required_ruby_version = ">= <%= config[:required_ruby_version] %>"
18
- <%- if config[:ext] == 'rust' -%>
19
- spec.required_rubygems_version = ">= <%= config[:rust_builder_required_rubygems_version] %>"
20
- <%- end -%>
21
-
22
18
  spec.metadata["allowed_push_host"] = "TODO: Set to your gem server 'https://example.com'"
23
-
24
19
  spec.metadata["homepage_uri"] = spec.homepage
25
- spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
26
- spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
20
+ spec.metadata["source_code_uri"] = "<%= config[:source_code_uri] %>"
21
+ <%- if config[:changelog] -%>
22
+ spec.metadata["changelog_uri"] = "<%= config[:changelog_uri] %>"
23
+ <%- end -%>
24
+
25
+ # Uncomment the line below to require MFA for gem pushes.
26
+ # This helps protect your gem from supply chain attacks by ensuring
27
+ # no one can publish a new version without multi-factor authentication.
28
+ # See: https://guides.rubygems.org/mfa-requirement-opt-in/
29
+ # spec.metadata["rubygems_mfa_required"] = "true"
27
30
 
28
31
  # Specify which files should be added to the gem when it is released.
29
32
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -31,13 +34,13 @@ Gem::Specification.new do |spec|
31
34
  spec.files = IO.popen(%w[git ls-files -z], chdir: __dir__, err: IO::NULL) do |ls|
32
35
  ls.readlines("\x0", chomp: true).reject do |f|
33
36
  (f == gemspec) ||
34
- f.start_with?(*%w[bin/ test/ spec/ features/ .git <%= config[:ci_config_path] %>appveyor Gemfile])
37
+ f.start_with?(*%w[<%= config[:ignore_paths].join(" ") %>])
35
38
  end
36
39
  end
37
40
  spec.bindir = "exe"
38
41
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
39
42
  spec.require_paths = ["lib"]
40
- <%- if config[:ext] == 'c' || config[:ext] == 'rust' -%>
43
+ <%- if %w(c rust go).include?(config[:ext]) -%>
41
44
  spec.extensions = ["ext/<%= config[:underscored_name] %>/extconf.rb"]
42
45
  <%- end -%>
43
46
 
@@ -46,7 +49,10 @@ Gem::Specification.new do |spec|
46
49
  <%- if config[:ext] == 'rust' -%>
47
50
  spec.add_dependency "rb_sys", "~> 0.9.91"
48
51
  <%- end -%>
52
+ <%- if config[:ext] == 'go' -%>
53
+ spec.add_dependency "go_gem", "~> 0.2"
54
+ <%- end -%>
49
55
 
50
56
  # For more information and examples about making a new gem, check out our
51
- # guide at: https://bundler.io/guides/creating_gem.html
57
+ # guide at: https://guides.rubygems.org/make-your-own-gem/
52
58
  end
@@ -5,7 +5,15 @@ RSpec.describe <%= config[:constant_name] %> do
5
5
  expect(<%= config[:constant_name] %>::VERSION).not_to be nil
6
6
  end
7
7
 
8
+ <%- if config[:ext] == 'rust' -%>
9
+ it "can call into Rust" do
10
+ result = <%= config[:constant_name] %>.hello("world")
11
+
12
+ expect(result).to be("Hello earth, from Rust!")
13
+ end
14
+ <%- else -%>
8
15
  it "does something useful" do
9
16
  expect(false).to eq(true)
10
17
  end
18
+ <%- end -%>
11
19
  end
@@ -7,7 +7,13 @@ class <%= config[:minitest_constant_name] %> < Minitest::Test
7
7
  refute_nil ::<%= config[:constant_name] %>::VERSION
8
8
  end
9
9
 
10
+ <%- if config[:ext] == 'rust' -%>
11
+ def test_hello_world
12
+ assert_equal "Hello earth, from Rust!", <%= config[:constant_name] %>.hello("world")
13
+ end
14
+ <%- else -%>
10
15
  def test_it_does_something_useful
11
16
  assert false
12
17
  end
18
+ <%- end -%>
13
19
  end
@@ -17,6 +17,7 @@ module Bundler
17
17
  @level = ENV["DEBUG"] ? "debug" : "info"
18
18
  @warning_history = []
19
19
  @output_stream = :stdout
20
+ @thread_safe_logger_key = "logger_level_#{object_id}"
20
21
  end
21
22
 
22
23
  def add_color(string, *color)
@@ -80,11 +81,11 @@ module Bundler
80
81
  end
81
82
 
82
83
  def ask(msg)
83
- @shell.ask(msg)
84
+ @shell.ask(msg, :green)
84
85
  end
85
86
 
86
87
  def yes?(msg)
87
- @shell.yes?(msg)
88
+ @shell.yes?(msg, :green)
88
89
  end
89
90
 
90
91
  def no?(msg)
@@ -97,11 +98,13 @@ module Bundler
97
98
  end
98
99
 
99
100
  def level(name = nil)
100
- return @level unless name
101
+ current_level = Thread.current.thread_variable_get(@thread_safe_logger_key) || @level
102
+ return current_level unless name
103
+
101
104
  unless index = LEVELS.index(name)
102
105
  raise "#{name.inspect} is not a valid level"
103
106
  end
104
- index <= LEVELS.index(@level)
107
+ index <= LEVELS.index(current_level)
105
108
  end
106
109
 
107
110
  def output_stream=(symbol)
@@ -167,12 +170,13 @@ module Bundler
167
170
  end * "\n"
168
171
  end
169
172
 
170
- def with_level(level)
171
- original = @level
172
- @level = level
173
+ def with_level(desired_level)
174
+ old_level = level
175
+ Thread.current.thread_variable_set(@thread_safe_logger_key, desired_level)
176
+
173
177
  yield
174
178
  ensure
175
- @level = original
179
+ Thread.current.thread_variable_set(@thread_safe_logger_key, old_level)
176
180
  end
177
181
 
178
182
  def with_output_stream(symbol)
@@ -1,8 +1,8 @@
1
1
  ##
2
2
  # The TimedStack manages a pool of homogeneous connections (or any resource
3
- # you wish to manage). Connections are created lazily up to a given maximum
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. +options+ is ignored in TimedStack but may be
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. If a connection is available it is
57
- # immediately returned. If no connection is available within the given
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). Other
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
- return fetch_connection(options) if connection_stored?(options)
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 true if a connection is available on the stack.
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 connection_stored?(options)
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
@@ -1,3 +1,3 @@
1
1
  class Bundler::ConnectionPool
2
- VERSION = "2.5.0"
2
+ VERSION = "2.5.4"
3
3
  end