rubygems-update 3.7.2 → 4.0.0.beta2

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 (211) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +1431 -1323
  3. data/CODE_OF_CONDUCT.md +7 -129
  4. data/Manifest.txt +5 -11
  5. data/README.md +2 -2
  6. data/bundler/CHANGELOG.md +1011 -917
  7. data/bundler/README.md +4 -4
  8. data/bundler/bundler.gemspec +3 -3
  9. data/bundler/lib/bundler/build_metadata.rb +2 -2
  10. data/bundler/lib/bundler/capistrano.rb +1 -19
  11. data/bundler/lib/bundler/cli/cache.rb +1 -11
  12. data/bundler/lib/bundler/cli/common.rb +20 -3
  13. data/bundler/lib/bundler/cli/config.rb +1 -2
  14. data/bundler/lib/bundler/cli/console.rb +5 -0
  15. data/bundler/lib/bundler/cli/exec.rb +29 -4
  16. data/bundler/lib/bundler/cli/gem.rb +19 -33
  17. data/bundler/lib/bundler/cli/install.rb +9 -82
  18. data/bundler/lib/bundler/cli/issue.rb +2 -2
  19. data/bundler/lib/bundler/cli/list.rb +33 -2
  20. data/bundler/lib/bundler/cli/plugin.rb +5 -1
  21. data/bundler/lib/bundler/cli/show.rb +1 -1
  22. data/bundler/lib/bundler/cli/update.rb +3 -3
  23. data/bundler/lib/bundler/cli.rb +91 -85
  24. data/bundler/lib/bundler/compact_index_client.rb +0 -1
  25. data/bundler/lib/bundler/current_ruby.rb +3 -15
  26. data/bundler/lib/bundler/definition.rb +65 -36
  27. data/bundler/lib/bundler/deployment.rb +1 -64
  28. data/bundler/lib/bundler/digest.rb +1 -1
  29. data/bundler/lib/bundler/dsl.rb +26 -36
  30. data/bundler/lib/bundler/endpoint_specification.rb +0 -22
  31. data/bundler/lib/bundler/environment_preserver.rb +1 -0
  32. data/bundler/lib/bundler/errors.rb +1 -5
  33. data/bundler/lib/bundler/feature_flag.rb +0 -33
  34. data/bundler/lib/bundler/fetcher/compact_index.rb +1 -1
  35. data/bundler/lib/bundler/friendly_errors.rb +2 -2
  36. data/bundler/lib/bundler/index.rb +0 -7
  37. data/bundler/lib/bundler/inline.rb +9 -1
  38. data/bundler/lib/bundler/installer/gem_installer.rb +0 -11
  39. data/bundler/lib/bundler/installer.rb +0 -6
  40. data/bundler/lib/bundler/lockfile_generator.rb +1 -1
  41. data/bundler/lib/bundler/lockfile_parser.rb +2 -12
  42. data/bundler/lib/bundler/man/bundle-add.1 +1 -1
  43. data/bundler/lib/bundler/man/bundle-binstubs.1 +3 -6
  44. data/bundler/lib/bundler/man/bundle-binstubs.1.ronn +4 -6
  45. data/bundler/lib/bundler/man/bundle-cache.1 +2 -14
  46. data/bundler/lib/bundler/man/bundle-cache.1.ronn +1 -14
  47. data/bundler/lib/bundler/man/bundle-check.1 +2 -5
  48. data/bundler/lib/bundler/man/bundle-check.1.ronn +0 -5
  49. data/bundler/lib/bundler/man/bundle-clean.1 +1 -1
  50. data/bundler/lib/bundler/man/bundle-config.1 +9 -33
  51. data/bundler/lib/bundler/man/bundle-config.1.ronn +24 -55
  52. data/bundler/lib/bundler/man/bundle-console.1 +1 -1
  53. data/bundler/lib/bundler/man/bundle-doctor.1 +1 -1
  54. data/bundler/lib/bundler/man/bundle-env.1 +1 -1
  55. data/bundler/lib/bundler/man/bundle-exec.1 +2 -5
  56. data/bundler/lib/bundler/man/bundle-exec.1.ronn +1 -5
  57. data/bundler/lib/bundler/man/bundle-fund.1 +1 -1
  58. data/bundler/lib/bundler/man/bundle-gem.1 +3 -6
  59. data/bundler/lib/bundler/man/bundle-gem.1.ronn +2 -5
  60. data/bundler/lib/bundler/man/bundle-help.1 +1 -1
  61. data/bundler/lib/bundler/man/bundle-info.1 +1 -1
  62. data/bundler/lib/bundler/man/bundle-init.1 +1 -1
  63. data/bundler/lib/bundler/man/bundle-install.1 +14 -57
  64. data/bundler/lib/bundler/man/bundle-install.1.ronn +25 -105
  65. data/bundler/lib/bundler/man/bundle-issue.1 +1 -1
  66. data/bundler/lib/bundler/man/bundle-licenses.1 +1 -1
  67. data/bundler/lib/bundler/man/bundle-list.1 +6 -1
  68. data/bundler/lib/bundler/man/bundle-list.1.ronn +5 -0
  69. data/bundler/lib/bundler/man/bundle-lock.1 +1 -1
  70. data/bundler/lib/bundler/man/bundle-open.1 +1 -1
  71. data/bundler/lib/bundler/man/bundle-outdated.1 +1 -1
  72. data/bundler/lib/bundler/man/bundle-platform.1 +1 -1
  73. data/bundler/lib/bundler/man/bundle-plugin.1 +2 -9
  74. data/bundler/lib/bundler/man/bundle-plugin.1.ronn +0 -8
  75. data/bundler/lib/bundler/man/bundle-pristine.1 +1 -1
  76. data/bundler/lib/bundler/man/bundle-remove.1 +2 -8
  77. data/bundler/lib/bundler/man/bundle-remove.1.ronn +1 -8
  78. data/bundler/lib/bundler/man/bundle-show.1 +2 -5
  79. data/bundler/lib/bundler/man/bundle-show.1.ronn +0 -4
  80. data/bundler/lib/bundler/man/bundle-update.1 +1 -1
  81. data/bundler/lib/bundler/man/bundle-version.1 +1 -1
  82. data/bundler/lib/bundler/man/bundle.1 +1 -10
  83. data/bundler/lib/bundler/man/bundle.1.ronn +0 -9
  84. data/bundler/lib/bundler/man/gemfile.5 +32 -1
  85. data/bundler/lib/bundler/man/gemfile.5.ronn +28 -0
  86. data/bundler/lib/bundler/man/index.txt +0 -2
  87. data/bundler/lib/bundler/materialization.rb +1 -1
  88. data/bundler/lib/bundler/plugin/installer.rb +0 -10
  89. data/bundler/lib/bundler/plugin/source_list.rb +1 -1
  90. data/bundler/lib/bundler/plugin.rb +1 -1
  91. data/bundler/lib/bundler/resolver.rb +1 -1
  92. data/bundler/lib/bundler/ruby_dsl.rb +2 -0
  93. data/bundler/lib/bundler/ruby_version.rb +1 -3
  94. data/bundler/lib/bundler/rubygems_ext.rb +1 -1
  95. data/bundler/lib/bundler/rubygems_gem_installer.rb +1 -1
  96. data/bundler/lib/bundler/rubygems_integration.rb +1 -5
  97. data/bundler/lib/bundler/runtime.rb +5 -1
  98. data/bundler/lib/bundler/self_manager.rb +1 -1
  99. data/bundler/lib/bundler/settings.rb +8 -26
  100. data/bundler/lib/bundler/shared_helpers.rb +12 -20
  101. data/bundler/lib/bundler/source/git/git_proxy.rb +3 -11
  102. data/bundler/lib/bundler/source/git.rb +2 -3
  103. data/bundler/lib/bundler/source/path.rb +3 -7
  104. data/bundler/lib/bundler/source/rubygems.rb +11 -17
  105. data/bundler/lib/bundler/source.rb +1 -1
  106. data/bundler/lib/bundler/source_list.rb +4 -45
  107. data/bundler/lib/bundler/source_map.rb +2 -5
  108. data/bundler/lib/bundler/spec_set.rb +6 -15
  109. data/bundler/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +7 -129
  110. data/bundler/lib/bundler/templates/newgem/Rakefile.tt +5 -0
  111. data/bundler/lib/bundler/templates/newgem/circleci/config.yml.tt +12 -0
  112. data/bundler/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +1 -1
  113. data/bundler/lib/bundler/templates/newgem/ext/newgem/extconf-go.rb.tt +11 -0
  114. data/bundler/lib/bundler/templates/newgem/ext/newgem/go.mod.tt +5 -0
  115. data/bundler/lib/bundler/templates/newgem/ext/newgem/newgem-go.c.tt +2 -0
  116. data/bundler/lib/bundler/templates/newgem/ext/newgem/newgem.go.tt +31 -0
  117. data/bundler/lib/bundler/templates/newgem/github/workflows/main.yml.tt +6 -0
  118. data/bundler/lib/bundler/templates/newgem/gitlab-ci.yml.tt +9 -0
  119. data/bundler/lib/bundler/templates/newgem/newgem.gemspec.tt +4 -1
  120. data/bundler/lib/bundler/ui/shell.rb +10 -6
  121. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/timed_stack.rb +26 -23
  122. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool/version.rb +1 -1
  123. data/bundler/lib/bundler/vendor/connection_pool/lib/connection_pool.rb +50 -6
  124. data/bundler/lib/bundler/vendor/fileutils/lib/fileutils.rb +57 -52
  125. data/bundler/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +5 -2
  126. data/bundler/lib/bundler/vendor/thor/lib/thor/runner.rb +1 -1
  127. data/bundler/lib/bundler/vendor/uri/lib/uri/common.rb +57 -15
  128. data/bundler/lib/bundler/vendor/uri/lib/uri/file.rb +1 -1
  129. data/bundler/lib/bundler/vendor/uri/lib/uri/generic.rb +34 -21
  130. data/bundler/lib/bundler/vendor/uri/lib/uri/http.rb +12 -0
  131. data/bundler/lib/bundler/vendor/uri/lib/uri/rfc2396_parser.rb +9 -8
  132. data/bundler/lib/bundler/vendor/uri/lib/uri/version.rb +2 -2
  133. data/bundler/lib/bundler/version.rb +1 -1
  134. data/bundler/lib/bundler/vlad.rb +1 -14
  135. data/bundler/lib/bundler.rb +6 -28
  136. data/doc/MAINTAINERS.txt +0 -7
  137. data/doc/bundler/UPGRADING.md +11 -5
  138. data/doc/rubygems/CONTRIBUTING.md +1 -1
  139. data/lib/rubygems/basic_specification.rb +3 -9
  140. data/lib/rubygems/bundler_version_finder.rb +38 -3
  141. data/lib/rubygems/command.rb +1 -1
  142. data/lib/rubygems/command_manager.rb +3 -4
  143. data/lib/rubygems/commands/build_command.rb +0 -7
  144. data/lib/rubygems/commands/cert_command.rb +1 -1
  145. data/lib/rubygems/commands/install_command.rb +1 -5
  146. data/lib/rubygems/commands/setup_command.rb +5 -3
  147. data/lib/rubygems/config_file.rb +1 -1
  148. data/lib/rubygems/dependency.rb +1 -1
  149. data/lib/rubygems/dependency_installer.rb +0 -77
  150. data/lib/rubygems/dependency_list.rb +1 -2
  151. data/lib/rubygems/deprecate.rb +74 -72
  152. data/lib/rubygems/doctor.rb +1 -1
  153. data/lib/rubygems/errors.rb +1 -1
  154. data/lib/rubygems/exceptions.rb +2 -3
  155. data/lib/rubygems/ext/builder.rb +6 -2
  156. data/lib/rubygems/ext/cargo_builder.rb +2 -2
  157. data/lib/rubygems/ext/cmake_builder.rb +97 -8
  158. data/lib/rubygems/ext/configure_builder.rb +2 -2
  159. data/lib/rubygems/ext/ext_conf_builder.rb +6 -2
  160. data/lib/rubygems/ext/rake_builder.rb +2 -2
  161. data/lib/rubygems/gem_runner.rb +0 -1
  162. data/lib/rubygems/install_update_options.rb +1 -2
  163. data/lib/rubygems/installer.rb +16 -54
  164. data/lib/rubygems/name_tuple.rb +7 -1
  165. data/lib/rubygems/package/tar_header.rb +4 -4
  166. data/lib/rubygems/package/tar_reader.rb +2 -0
  167. data/lib/rubygems/package/tar_writer.rb +1 -1
  168. data/lib/rubygems/package.rb +21 -12
  169. data/lib/rubygems/platform.rb +31 -11
  170. data/lib/rubygems/remote_fetcher.rb +8 -5
  171. data/lib/rubygems/resolver/conflict.rb +1 -1
  172. data/lib/rubygems/resolver.rb +1 -1
  173. data/lib/rubygems/security/signer.rb +1 -1
  174. data/lib/rubygems/source.rb +2 -2
  175. data/lib/rubygems/spec_fetcher.rb +4 -4
  176. data/lib/rubygems/specification.rb +5 -96
  177. data/lib/rubygems/specification_policy.rb +0 -36
  178. data/lib/rubygems/specification_record.rb +1 -1
  179. data/lib/rubygems/text.rb +1 -1
  180. data/lib/rubygems/uninstaller.rb +17 -6
  181. data/lib/rubygems/user_interaction.rb +6 -9
  182. data/lib/rubygems/util.rb +0 -22
  183. data/lib/rubygems/validator.rb +1 -1
  184. data/lib/rubygems/vendor/net-http/lib/net/http/generic_request.rb +25 -9
  185. data/lib/rubygems/vendor/net-http/lib/net/http/responses.rb +2 -2
  186. data/lib/rubygems/vendor/net-http/lib/net/http.rb +14 -14
  187. data/lib/rubygems/vendor/optparse/lib/optparse.rb +82 -41
  188. data/lib/rubygems/vendor/resolv/lib/resolv.rb +1 -1
  189. data/lib/rubygems/vendor/timeout/lib/timeout.rb +4 -1
  190. data/lib/rubygems/vendor/uri/lib/uri/common.rb +57 -15
  191. data/lib/rubygems/vendor/uri/lib/uri/file.rb +1 -1
  192. data/lib/rubygems/vendor/uri/lib/uri/generic.rb +34 -21
  193. data/lib/rubygems/vendor/uri/lib/uri/http.rb +12 -0
  194. data/lib/rubygems/vendor/uri/lib/uri/rfc2396_parser.rb +9 -8
  195. data/lib/rubygems/vendor/uri/lib/uri/version.rb +2 -2
  196. data/lib/rubygems/version.rb +8 -20
  197. data/lib/rubygems/win_platform.rb +31 -0
  198. data/lib/rubygems.rb +12 -40
  199. data/rubygems-update.gemspec +6 -4
  200. metadata +10 -18
  201. data/bundler/lib/bundler/cli/inject.rb +0 -60
  202. data/bundler/lib/bundler/cli/viz.rb +0 -31
  203. data/bundler/lib/bundler/graph.rb +0 -152
  204. data/bundler/lib/bundler/man/bundle-inject.1 +0 -31
  205. data/bundler/lib/bundler/man/bundle-inject.1.ronn +0 -32
  206. data/bundler/lib/bundler/man/bundle-viz.1 +0 -30
  207. data/bundler/lib/bundler/man/bundle-viz.1.ronn +0 -36
  208. data/bundler/lib/bundler/similarity_detector.rb +0 -63
  209. data/lib/rubygems/commands/query_command.rb +0 -43
  210. data/lib/rubygems/compatibility.rb +0 -41
  211. data/lib/rubygems/install_default_message.rb +0 -13
@@ -9,7 +9,7 @@ module Bundler
9
9
  :metadata_source
10
10
 
11
11
  def global_rubygems_source
12
- @global_rubygems_source ||= rubygems_aggregate_class.new("allow_local" => true)
12
+ @global_rubygems_source ||= source_class.new("allow_local" => true)
13
13
  end
14
14
 
15
15
  def initialize
@@ -21,19 +21,9 @@ module Bundler
21
21
  @rubygems_sources = []
22
22
  @metadata_source = Source::Metadata.new
23
23
 
24
- @merged_gem_lockfile_sections = false
25
24
  @local_mode = true
26
25
  end
27
26
 
28
- def merged_gem_lockfile_sections?
29
- @merged_gem_lockfile_sections
30
- end
31
-
32
- def merged_gem_lockfile_sections!(replacement_source)
33
- @merged_gem_lockfile_sections = true
34
- @global_rubygems_source = replacement_source
35
- end
36
-
37
27
  def aggregate_global_source?
38
28
  global_rubygems_source.multiple_remotes?
39
29
  end
@@ -90,10 +80,6 @@ module Bundler
90
80
  @rubygems_sources
91
81
  end
92
82
 
93
- def rubygems_remotes
94
- rubygems_sources.flat_map(&:remotes).uniq
95
- end
96
-
97
83
  def all_sources
98
84
  path_sources + git_sources + plugin_sources + rubygems_sources + [metadata_source]
99
85
  end
@@ -115,11 +101,7 @@ module Bundler
115
101
  end
116
102
 
117
103
  def lock_rubygems_sources
118
- if merged_gem_lockfile_sections?
119
- [combine_rubygems_sources]
120
- else
121
- rubygems_sources.sort_by(&:identifier)
122
- end
104
+ rubygems_sources.sort_by(&:identifier)
123
105
  end
124
106
 
125
107
  # Returns true if there are changes
@@ -129,16 +111,7 @@ module Bundler
129
111
  @rubygems_sources, @path_sources, @git_sources, @plugin_sources = map_sources(replacement_sources)
130
112
  @global_rubygems_source = global_replacement_source(replacement_sources)
131
113
 
132
- different_sources?(lock_sources, replacement_sources)
133
- end
134
-
135
- # Returns true if there are changes
136
- def expired_sources?(replacement_sources)
137
- return false if replacement_sources.empty?
138
-
139
- lock_sources = dup_with_replaced_sources(replacement_sources).lock_sources
140
-
141
- different_sources?(lock_sources, replacement_sources)
114
+ !equivalent_sources?(lock_sources, replacement_sources)
142
115
  end
143
116
 
144
117
  def prefer_local!
@@ -165,12 +138,6 @@ module Bundler
165
138
 
166
139
  private
167
140
 
168
- def dup_with_replaced_sources(replacement_sources)
169
- new_source_list = dup
170
- new_source_list.replace_sources!(replacement_sources)
171
- new_source_list
172
- end
173
-
174
141
  def map_sources(replacement_sources)
175
142
  rubygems = @rubygems_sources.map do |source|
176
143
  replace_rubygems_source(replacement_sources, source)
@@ -224,11 +191,7 @@ module Bundler
224
191
  end
225
192
  end
226
193
 
227
- def different_sources?(lock_sources, replacement_sources)
228
- !equivalent_sources?(lock_sources, replacement_sources)
229
- end
230
-
231
- def rubygems_aggregate_class
194
+ def source_class
232
195
  Source::Rubygems
233
196
  end
234
197
 
@@ -247,10 +210,6 @@ module Bundler
247
210
  end
248
211
  end
249
212
 
250
- def combine_rubygems_sources
251
- Source::Rubygems.new("remotes" => rubygems_remotes)
252
- end
253
-
254
213
  def warn_on_git_protocol(source)
255
214
  return if Bundler.settings["git.allow_insecure"]
256
215
 
@@ -23,15 +23,12 @@ module Bundler
23
23
  if previous_source.nil?
24
24
  requirements[indirect_dependency_name] = source
25
25
  else
26
- no_ambiguous_sources = Bundler.feature_flag.bundler_4_mode?
27
-
28
26
  msg = ["The gem '#{indirect_dependency_name}' was found in multiple relevant sources."]
29
27
  msg.concat [previous_source, source].map {|s| " * #{s}" }.sort
30
- msg << "You #{no_ambiguous_sources ? :must : :should} add this gem to the source block for the source you wish it to be installed from."
28
+ msg << "You must add this gem to the source block for the source you wish it to be installed from."
31
29
  msg = msg.join("\n")
32
30
 
33
- raise SecurityError, msg if no_ambiguous_sources
34
- Bundler.ui.warn "Warning: #{msg}"
31
+ raise SecurityError, msg
35
32
  end
36
33
  end
37
34
 
@@ -11,16 +11,11 @@ module Bundler
11
11
  @specs = specs
12
12
  end
13
13
 
14
- def for(dependencies, platforms_or_legacy_check = [nil], legacy_platforms = [nil], skips: [])
15
- platforms = if [true, false].include?(platforms_or_legacy_check)
16
- Bundler::SharedHelpers.major_deprecation 2,
14
+ def for(dependencies, platforms = [nil], legacy_platforms = [nil], skips: [])
15
+ if [true, false].include?(platforms)
16
+ Bundler::SharedHelpers.feature_removed! \
17
17
  "SpecSet#for received a `check` parameter, but that's no longer used and deprecated. " \
18
- "SpecSet#for always implicitly performs validation. Please remove this parameter",
19
- print_caller_location: true
20
-
21
- legacy_platforms
22
- else
23
- platforms_or_legacy_check
18
+ "SpecSet#for always implicitly performs validation. Please remove this parameter"
24
19
  end
25
20
 
26
21
  materialize_dependencies(dependencies, platforms, skips: skips)
@@ -179,9 +174,7 @@ module Bundler
179
174
  end
180
175
 
181
176
  def -(other)
182
- SharedHelpers.major_deprecation 2, "SpecSet#- has been removed with no replacement"
183
-
184
- SpecSet.new(to_a - other.to_a)
177
+ SharedHelpers.feature_removed! "SpecSet#- has been removed with no replacement"
185
178
  end
186
179
 
187
180
  def find_by_name_and_platform(name, platform)
@@ -212,9 +205,7 @@ module Bundler
212
205
  end
213
206
 
214
207
  def <<(spec)
215
- SharedHelpers.major_deprecation 2, "SpecSet#<< has been removed with no replacement"
216
-
217
- @specs << spec
208
+ SharedHelpers.feature_removed! "SpecSet#<< has been removed with no replacement"
218
209
  end
219
210
 
220
211
  def length
@@ -1,132 +1,10 @@
1
- # Contributor Covenant Code of Conduct
1
+ # Code of Conduct
2
2
 
3
- ## Our Pledge
3
+ <%= config[:name].inspect %> follows [The Ruby Community Conduct Guideline](https://www.ruby-lang.org/en/conduct) in all "collaborative space", which is defined as community communications channels (such as mailing lists, submitted patches, commit comments, etc.):
4
4
 
5
- We as members, contributors, and leaders pledge to make participation in our
6
- community a harassment-free experience for everyone, regardless of age, body
7
- size, visible or invisible disability, ethnicity, sex characteristics, gender
8
- identity and expression, level of experience, education, socio-economic status,
9
- nationality, personal appearance, race, caste, color, religion, or sexual
10
- identity and orientation.
5
+ * Participants will be tolerant of opposing views.
6
+ * Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks.
7
+ * When interpreting the words and actions of others, participants should always assume good intentions.
8
+ * Behaviour which can be reasonably considered harassment will not be tolerated.
11
9
 
12
- We pledge to act and interact in ways that contribute to an open, welcoming,
13
- diverse, inclusive, and healthy community.
14
-
15
- ## Our Standards
16
-
17
- Examples of behavior that contributes to a positive environment for our
18
- community include:
19
-
20
- * Demonstrating empathy and kindness toward other people
21
- * Being respectful of differing opinions, viewpoints, and experiences
22
- * Giving and gracefully accepting constructive feedback
23
- * Accepting responsibility and apologizing to those affected by our mistakes,
24
- and learning from the experience
25
- * Focusing on what is best not just for us as individuals, but for the overall
26
- community
27
-
28
- Examples of unacceptable behavior include:
29
-
30
- * The use of sexualized language or imagery, and sexual attention or advances of
31
- any kind
32
- * Trolling, insulting or derogatory comments, and personal or political attacks
33
- * Public or private harassment
34
- * Publishing others' private information, such as a physical or email address,
35
- without their explicit permission
36
- * Other conduct which could reasonably be considered inappropriate in a
37
- professional setting
38
-
39
- ## Enforcement Responsibilities
40
-
41
- Community leaders are responsible for clarifying and enforcing our standards of
42
- acceptable behavior and will take appropriate and fair corrective action in
43
- response to any behavior that they deem inappropriate, threatening, offensive,
44
- or harmful.
45
-
46
- Community leaders have the right and responsibility to remove, edit, or reject
47
- comments, commits, code, wiki edits, issues, and other contributions that are
48
- not aligned to this Code of Conduct, and will communicate reasons for moderation
49
- decisions when appropriate.
50
-
51
- ## Scope
52
-
53
- This Code of Conduct applies within all community spaces, and also applies when
54
- an individual is officially representing the community in public spaces.
55
- Examples of representing our community include using an official email address,
56
- posting via an official social media account, or acting as an appointed
57
- representative at an online or offline event.
58
-
59
- ## Enforcement
60
-
61
- Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
- reported to the community leaders responsible for enforcement at
63
- [INSERT CONTACT METHOD].
64
- All complaints will be reviewed and investigated promptly and fairly.
65
-
66
- All community leaders are obligated to respect the privacy and security of the
67
- reporter of any incident.
68
-
69
- ## Enforcement Guidelines
70
-
71
- Community leaders will follow these Community Impact Guidelines in determining
72
- the consequences for any action they deem in violation of this Code of Conduct:
73
-
74
- ### 1. Correction
75
-
76
- **Community Impact**: Use of inappropriate language or other behavior deemed
77
- unprofessional or unwelcome in the community.
78
-
79
- **Consequence**: A private, written warning from community leaders, providing
80
- clarity around the nature of the violation and an explanation of why the
81
- behavior was inappropriate. A public apology may be requested.
82
-
83
- ### 2. Warning
84
-
85
- **Community Impact**: A violation through a single incident or series of
86
- actions.
87
-
88
- **Consequence**: A warning with consequences for continued behavior. No
89
- interaction with the people involved, including unsolicited interaction with
90
- those enforcing the Code of Conduct, for a specified period of time. This
91
- includes avoiding interactions in community spaces as well as external channels
92
- like social media. Violating these terms may lead to a temporary or permanent
93
- ban.
94
-
95
- ### 3. Temporary Ban
96
-
97
- **Community Impact**: A serious violation of community standards, including
98
- sustained inappropriate behavior.
99
-
100
- **Consequence**: A temporary ban from any sort of interaction or public
101
- communication with the community for a specified period of time. No public or
102
- private interaction with the people involved, including unsolicited interaction
103
- with those enforcing the Code of Conduct, is allowed during this period.
104
- Violating these terms may lead to a permanent ban.
105
-
106
- ### 4. Permanent Ban
107
-
108
- **Community Impact**: Demonstrating a pattern of violation of community
109
- standards, including sustained inappropriate behavior, harassment of an
110
- individual, or aggression toward or disparagement of classes of individuals.
111
-
112
- **Consequence**: A permanent ban from any sort of public interaction within the
113
- community.
114
-
115
- ## Attribution
116
-
117
- This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
- version 2.1, available at
119
- [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
-
121
- Community Impact Guidelines were inspired by
122
- [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
123
-
124
- For answers to common questions about this code of conduct, see the FAQ at
125
- [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
126
- [https://www.contributor-covenant.org/translations][translations].
127
-
128
- [homepage]: https://www.contributor-covenant.org
129
- [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
- [Mozilla CoC]: https://github.com/mozilla/diversity
131
- [FAQ]: https://www.contributor-covenant.org/faq
132
- [translations]: https://www.contributor-covenant.org/translations
10
+ If you have any concerns about behaviour within this project, please contact us at [<%= config[:email].inspect %>](mailto:<%= config[:email].inspect %>).
@@ -59,6 +59,11 @@ Rake::ExtensionTask.new("<%= config[:underscored_name] %>", GEMSPEC) do |ext|
59
59
  end
60
60
  <% end -%>
61
61
 
62
+ <% if config[:ext] == "go" -%>
63
+ require "go_gem/rake_task"
64
+
65
+ GoGem::RakeTask.new("<%= config[:underscored_name] %>")
66
+ <% end -%>
62
67
  <% end -%>
63
68
  <% if default_task_names.size == 1 -%>
64
69
  task default: <%= default_task_names.first.inspect %>
@@ -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,4 @@ publish = false
12
12
  crate-type = ["cdylib"]
13
13
 
14
14
  [dependencies]
15
- magnus = { version = "0.6.2" }
15
+ magnus = { version = "0.8.2" }
@@ -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
+ }
@@ -34,6 +34,12 @@ jobs:
34
34
  with:
35
35
  ruby-version: ${{ matrix.ruby }}
36
36
  bundler-cache: true
37
+ <%- end -%>
38
+ <%- if config[:ext] == 'go' -%>
39
+ - name: Setup Go
40
+ uses: actions/setup-go@v5
41
+ with:
42
+ go-version-file: ext/<%= config[:underscored_name] %>/go.mod
37
43
  <%- end -%>
38
44
  - name: Run the default task
39
45
  run: bundle exec rake
@@ -5,6 +5,11 @@ default:
5
5
  <%- if config[:ext] == 'rust' -%>
6
6
  - apt-get update && apt-get install -y clang
7
7
  - gem update --system '<%= ::Gem.rubygems_version %>'
8
+ <%- end -%>
9
+ <%- if config[:ext] == 'go' -%>
10
+ - wget https://go.dev/dl/go$GO_VERSION.linux-amd64.tar.gz -O /tmp/go.tar.gz
11
+ - tar -C /usr/local -xzf /tmp/go.tar.gz
12
+ - export PATH=/usr/local/go/bin:$PATH
8
13
  <%- end -%>
9
14
  - gem install bundler -v <%= Bundler::VERSION %>
10
15
  - bundle install
@@ -13,6 +18,10 @@ example_job:
13
18
  <%- if config[:ext] == 'rust' -%>
14
19
  variables:
15
20
  RB_SYS_FORCE_INSTALL_RUST_TOOLCHAIN: 'true'
21
+ <%- end -%>
22
+ <%- if config[:ext] == 'go' -%>
23
+ variables:
24
+ GO_VERSION: '1.23.0'
16
25
  <%- end -%>
17
26
  script:
18
27
  - bundle exec rake
@@ -38,7 +38,7 @@ Gem::Specification.new do |spec|
38
38
  spec.bindir = "exe"
39
39
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
40
40
  spec.require_paths = ["lib"]
41
- <%- if config[:ext] == 'c' || config[:ext] == 'rust' -%>
41
+ <%- if %w(c rust go).include?(config[:ext]) -%>
42
42
  spec.extensions = ["ext/<%= config[:underscored_name] %>/extconf.rb"]
43
43
  <%- end -%>
44
44
 
@@ -47,6 +47,9 @@ Gem::Specification.new do |spec|
47
47
  <%- if config[:ext] == 'rust' -%>
48
48
  spec.add_dependency "rb_sys", "~> 0.9.91"
49
49
  <%- end -%>
50
+ <%- if config[:ext] == 'go' -%>
51
+ spec.add_dependency "go_gem", "~> 0.2"
52
+ <%- end -%>
50
53
 
51
54
  # For more information and examples about making a new gem, check out our
52
55
  # guide at: https://bundler.io/guides/creating_gem.html
@@ -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)
@@ -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