bundler-extension_in_lib 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a71f3a5f424b93482fe6affddbf71bedc7a1810314eaa08cf412a231e5254fcb
4
+ data.tar.gz: eccd30901cd4f3927599b9050dd1c5ac03d7d20b4a0cb1732345b39c2841c047
5
+ SHA512:
6
+ metadata.gz: 76d16ddbe60bd1144d6248c71cabef3ae7325cd26e64963f069976a3c1970c30551af19fe4f82dade5634e334ce08638f66eadd720a78059b92f9df8b4002176
7
+ data.tar.gz: 535a61c064abdb43c17740b09e813c97e401f22e2f2a1913268ac151733f385a40cbc6aefb272ffb107452e10dda4d8308266b43f7a8fe1a90607ad041b6f8f1
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2026 Shopify developers
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,58 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "fileutils"
4
+
5
+ module BundlerInstallExtensionInLib
6
+ VERSION = "0.1.0"
7
+
8
+ SKIP_FILES = %w[gem.build_complete mkmf.log gem_make.out].freeze
9
+
10
+ @gem_names = []
11
+
12
+ def self.add(name)
13
+ @gem_names << name.to_s
14
+ end
15
+
16
+ def self.registered?(name)
17
+ @gem_names.include?(name.to_s)
18
+ end
19
+
20
+ def self.handle_after_install(spec_install)
21
+ return unless spec_install.state == :installed
22
+ return unless registered?(spec_install.name)
23
+
24
+ spec = spec_install.spec
25
+ return if spec.extensions.empty?
26
+
27
+ extension_dir = spec.extension_dir
28
+ return unless File.directory?(extension_dir)
29
+
30
+ lib_dir = File.join(spec.full_gem_path, spec.raw_require_paths.first)
31
+
32
+ ext_files = Dir.glob(File.join(extension_dir, "**", "*"))
33
+ .select { |f| File.file?(f) }
34
+ .reject { |f| SKIP_FILES.include?(File.basename(f)) }
35
+ return if ext_files.empty?
36
+
37
+ copied = ext_files.count do |ext_file|
38
+ relative = ext_file.delete_prefix("#{extension_dir}/")
39
+ dest = File.join(lib_dir, relative)
40
+ next false if File.exist?(dest)
41
+
42
+ FileUtils.mkdir_p(File.dirname(dest))
43
+ FileUtils.cp(ext_file, dest, verbose: true)
44
+ true
45
+ end
46
+
47
+ Bundler.ui.info "bundler-install_extension_in_lib: Copied #{copied} extension(s) to #{lib_dir}" if copied > 0
48
+ end
49
+
50
+ module DSL
51
+ def gem(name, *args, install_extension_in_lib: false, **kwargs)
52
+ ::BundlerInstallExtensionInLib.add(name) if install_extension_in_lib
53
+ super(name, *args, **kwargs)
54
+ end
55
+ end
56
+ Bundler::Dsl.prepend DSL
57
+ end
58
+
data/plugins.rb ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler-install_extension_in_lib"
4
+
5
+ Bundler::Plugin::API.hook(Bundler::Plugin::Events::GEM_AFTER_INSTALL) do |spec_install|
6
+ BundlerInstallExtensionInLib.handle_after_install(spec_install)
7
+ end
metadata ADDED
@@ -0,0 +1,46 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bundler-extension_in_lib
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Shopify Engineering
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies: []
12
+ description: Per-gem control over copying native extension shared libraries (.so/.bundle)
13
+ into the gem's lib/ directory after installation. Useful for old/unmaintained gems
14
+ that expect extensions in lib/.
15
+ email: gems@shopify.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - LICENSE.txt
21
+ - lib/bundler-install_extension_in_lib.rb
22
+ - plugins.rb
23
+ homepage: https://github.com/Shopify/bundler-install_extension_in_lib
24
+ licenses:
25
+ - MIT
26
+ metadata:
27
+ allowed_push_host: https://rubygems.org
28
+ source_code_uri: https://github.com/Shopify/bundler-install_extension_in_lib/tree/v0.1.0
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 3.2.0
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - ">="
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubygems_version: 4.0.6
44
+ specification_version: 4
45
+ summary: Bundler plugin to copy compiled extensions into gem lib/ directories
46
+ test_files: []