diff options
author | Asutosh Palai <asupalai@gmail.com> | 2016-05-20 14:06:28 +0530 |
---|---|---|
committer | Asutosh Palai <asupalai@gmail.com> | 2016-05-24 21:15:01 +0530 |
commit | 011c69901ae3a103ec91385378f3df70b0f778d2 (patch) | |
tree | a5da1887f763a3ba63df38e676835ac323b87696 /lib/bundler/plugin.rb | |
parent | dbad52b5b477936b25c2c5605247a9e70a0796cb (diff) | |
download | bundler-011c69901ae3a103ec91385378f3df70b0f778d2.tar.gz |
Added plugin module with install functionality
Diffstat (limited to 'lib/bundler/plugin.rb')
-rw-r--r-- | lib/bundler/plugin.rb | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/lib/bundler/plugin.rb b/lib/bundler/plugin.rb new file mode 100644 index 0000000000..364401ded1 --- /dev/null +++ b/lib/bundler/plugin.rb @@ -0,0 +1,34 @@ +#frozen_string_literal: true + +module Bundler + class Plugin + + class << self + + def install(name, options) + require "bundler/plugin/installer.rb" + + source = options[:source] || raise(ArgumentError, "You need to provide the source") + version = options[:version] || [">= 0"] + + plugin_path = Installer.install(name, source, version) + + puts plugin_path + + Bundler.ui.info "Installed plugin #{name}" + rescue StandardError => e + Bundler.ui.error "Failed to install plugin #{name}: #{e.message}\n #{e.backtrace.join("\n ")}" + Bundler.ui.trace e + end + + + def root + @root ||= Bundler.user_bundle_path.join("plugin") + end + + def cache + @cache ||= root.join "cache" + end + end + end +end |