Class: Gemvault::BundlerPluginRoot
- Inherits:
-
Object
- Object
- Gemvault::BundlerPluginRoot
- Defined in:
- lib/gemvault/bundler_plugin_root.rb
Overview
Where Bundler keeps plugin data for a directory.
Bundler::Plugin.root answers the project-local .bundle/plugin when
SharedHelpers.in_bundle? holds, and the global
~/.bundle/plugin when it does not. Since in_bundle? is just
"was a Gemfile found", a project can own a plugin root that Bundler
declines to look in.
Constant Summary collapse
- LOCAL_DIR =
".bundle/plugin".freeze
Instance Method Summary collapse
-
#consulted ⇒ Object
The plugin root Bundler will consult here: beside the Gemfile when one was found, the project's own root when doctor points Bundler at it (see #unreachable?), the global root otherwise.
-
#global ⇒ Object
Where Bundler keeps plugins for a user outside any project, mirroring Bundler's user_bundle_path lookup for plugins: BUNDLE_USER_PLUGIN names the root directly, BUNDLE_USER_HOME relocates .bundle, and the home directory is the default.
-
#initialize(dir: Dir.pwd, gemfile: BundlerGemfile.new(dir: dir), env: ENV) ⇒ BundlerPluginRoot
constructor
A new instance of BundlerPluginRoot.
-
#local ⇒ Object
The project's own plugin root, whether or not Bundler would consult it.
-
#unreachable? ⇒ Boolean
Whether this project has a plugin root that Bundler currently ignores.
Constructor Details
#initialize(dir: Dir.pwd, gemfile: BundlerGemfile.new(dir: dir), env: ENV) ⇒ BundlerPluginRoot
Returns a new instance of BundlerPluginRoot.
16 17 18 19 20 |
# File 'lib/gemvault/bundler_plugin_root.rb', line 16 def initialize(dir: Dir.pwd, gemfile: BundlerGemfile.new(dir: dir), env: ENV) @dir = Pathname(dir) @gemfile = gemfile @env = env end |
Instance Method Details
#consulted ⇒ Object
The plugin root Bundler will consult here: beside the Gemfile when one was found, the project's own root when doctor points Bundler at it (see #unreachable?), the global root otherwise.
41 42 43 44 45 46 |
# File 'lib/gemvault/bundler_plugin_root.rb', line 41 def consulted return @gemfile.path.dirname / LOCAL_DIR if @gemfile.exist? return local if unreachable? global end |
#global ⇒ Object
Where Bundler keeps plugins for a user outside any project, mirroring Bundler's user_bundle_path lookup for plugins: BUNDLE_USER_PLUGIN names the root directly, BUNDLE_USER_HOME relocates .bundle, and the home directory is the default.
31 32 33 34 35 36 |
# File 'lib/gemvault/bundler_plugin_root.rb', line 31 def global named = @env["BUNDLE_USER_PLUGIN"] return Pathname(named) if named Pathname(@env["BUNDLE_USER_HOME"] || File.join(Dir.home, ".bundle")) / "plugin" end |
#local ⇒ Object
The project's own plugin root, whether or not Bundler would consult it.
23 24 25 |
# File 'lib/gemvault/bundler_plugin_root.rb', line 23 def local @dir. / LOCAL_DIR end |
#unreachable? ⇒ Boolean
Whether this project has a plugin root that Bundler currently ignores.
bundler/inline installs plugins into
55 56 57 |
# File 'lib/gemvault/bundler_plugin_root.rb', line 55 def unreachable? !@gemfile.exist? && local.directory? end |