bundler-source-vault 0.1.5 → 0.2.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/plugins.rb +33 -14
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 62096b2c3b6ffd526e3966e2edabb75db044f550297744aea293fb0d2ad44a97
4
- data.tar.gz: 7a701f9b39f34b3d49b097b4e34f11bb6bd74903dd928cc0db7bcf575368bc12
3
+ metadata.gz: e9dd9d758331183b7fe023c975f48730512d8bb5b40bd97bd6b3ab97e39836b7
4
+ data.tar.gz: c9b20bd237cf149953cae0f50921b16018f9fa2a75dfb3d4124b90851fac9f78
5
5
  SHA512:
6
- metadata.gz: e40163ad4c191c4f4a96180c186ea8fb6d39dc6d4cd3881f934af5b8d9607f1a474ca453c79f6061ece769be33bfcd8db187f1c32f4f9f958992b0d3c9596582
7
- data.tar.gz: b4ab91d8e009e1ea0f385ddb3c38892db673369a2ce3649c709ce1f218f48324f543cb71ed838d98afd6cb4a2f6e5f24113ce5d9d034d9017b0504f674366429
6
+ metadata.gz: fc6d4456bb45e43ce03903820d3a8b17ec077cadca5e6b0aeca8428a5dd85999e1d6ec05d23fd3eb942114d1f4f96095bfb6fe3fc9b61bd8a65f54136ac0662a
7
+ data.tar.gz: 91eb3531d515d09e60506bd2d1977fce87a8f92fa91fd5fc08f9759efefa493742a35e5d3feedacfec2f3a9d68c9837ab7d89d43c3f0b013c05b66b0e5b3c2d5
data/plugins.rb CHANGED
@@ -1,20 +1,39 @@
1
- # Bundler installs plugin dependencies (e.g. sqlite3) into Plugin.root but
2
- # does not add their load paths before loading plugins.rb. This is a known
3
- # Bundler limitation -- see the "Currently not done to avoid conflicts" comment
4
- # in bundler/plugin.rb#load_plugin.
1
+ # Bundler installs plugin dependencies (here: gemvault) alongside the plugin
2
+ # but does not put them on the load path before loading plugins.rb -- see the
3
+ # "Currently not done to avoid conflicts" comment in bundler/plugin.rb. The
4
+ # require below must resolve gemvault through RubyGems itself, so every gem
5
+ # root that may hold gemvault has to be visible to Gem::Specification first.
5
6
  #
6
- # Work around by registering Plugin.root as a gem search path so dependencies
7
- # installed there are activatable via `require`.
8
7
  # Development: when loaded from within the gemvault source tree, the gemvault
9
- # gem isn't installed so its lib/ must be on $LOAD_PATH for the require below.
10
- gemvault_lib = File.expand_path("../lib", __dir__)
11
- $LOAD_PATH.unshift(gemvault_lib) unless $LOAD_PATH.include?(gemvault_lib)
8
+ # gem isn't installed, so its lib/ must be on $LOAD_PATH for the require below.
9
+ gemvault_lib = Pathname(__dir__).parent.join("lib")
10
+ $LOAD_PATH.unshift(gemvault_lib.to_s) if gemvault_lib.directory? && !$LOAD_PATH.include?(gemvault_lib.to_s)
12
11
 
13
- if defined?(Bundler::Plugin)
14
- plugin_root = Bundler::Plugin.root.to_s
15
- spec_dir = File.join(plugin_root, "specifications")
16
- if File.directory?(spec_dir) && !Gem::Specification.dirs.include?(spec_dir)
17
- Gem::Specification.dirs = Gem.path + [plugin_root]
12
+ # Installed, this file lives at <gem root>/gems/bundler-source-vault-<v>/, and
13
+ # gemvault sits in the same root: Bundler's local or global plugin root, or a
14
+ # plain GEM_HOME when installed with `gem install`. Bundler's plugin roots are
15
+ # also candidates because `Bundler::Plugin.root` is the project-local root even
16
+ # when the plugin actually loads from the global one.
17
+ plugin_roots = defined?(Bundler::Plugin) ? [Bundler::Plugin.root, Bundler::Plugin.global_root] : []
18
+ gem_root = Pathname(__dir__).parent.parent
19
+ candidate_dirs = [gem_root, *plugin_roots]
20
+ .map { |root| Pathname(root.to_s).join("specifications") }
21
+ .uniq
22
+ .select(&:directory?)
23
+
24
+ searched_dirs = Gem::Specification.dirs.map { |dir| Pathname(dir) }
25
+ unsearched_dirs = candidate_dirs - searched_dirs
26
+
27
+ if unsearched_dirs.any?
28
+ Gem::Specification.dirs = (searched_dirs + unsearched_dirs).map { |dir| dir.parent.to_s }
29
+ elsif candidate_dirs.any?
30
+ begin
31
+ Gem::Specification.find_by_name("gemvault")
32
+ rescue Gem::LoadError
33
+ # The searched dirs are right but the spec cache predates this install:
34
+ # `bundle plugin install` switches GEM_HOME to the plugin root and caches
35
+ # specs during resolution, before gemvault lands there.
36
+ Gem::Specification.reset
18
37
  end
19
38
  end
20
39
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundler-source-vault
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Gillis
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 0.1.5
18
+ version: 0.2.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: 0.1.5
25
+ version: 0.2.0
26
26
  description: Registers the :vault source type with Bundler, enabling gem installation
27
27
  from .gemv vault files
28
28
  email: