diff options
author | Asutosh Palai <asupalai@gmail.com> | 2016-05-27 12:33:32 +0530 |
---|---|---|
committer | Asutosh Palai <asupalai@gmail.com> | 2016-05-27 12:51:55 +0530 |
commit | 10c87cff76e2ec5a21d7b8978debfb19ea9e5ebb (patch) | |
tree | 71a917b667b84f5a099e4e7f9402d8c667705da7 /lib | |
parent | 5ab32cdb78510079d203a2c56ecb2ac56b9de984 (diff) | |
download | bundler-10c87cff76e2ec5a21d7b8978debfb19ea9e5ebb.tar.gz |
Added spec for gemfile eval and a few docs
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bundler/plugin.rb | 4 | ||||
-rw-r--r-- | lib/bundler/plugin/dsl.rb | 8 | ||||
-rw-r--r-- | lib/bundler/plugin/installer.rb | 18 | ||||
-rw-r--r-- | lib/bundler/plugin/source_list.rb | 4 |
4 files changed, 21 insertions, 13 deletions
diff --git a/lib/bundler/plugin.rb b/lib/bundler/plugin.rb index 1421b6fd..e4ab9287 100644 --- a/lib/bundler/plugin.rb +++ b/lib/bundler/plugin.rb @@ -27,6 +27,10 @@ module Bundler Bundler.ui.error "Failed to install plugin #{name}: #{e.message}\n #{e.backtrace.join("\n ")}" end + # Evaluates the Gemfile with a limited DSL and installs the plugins + # specified by plugin method + # + # @param [Pathname] gemfile path def eval_gemfile(gemfile) definition = Dsl.evaluate(gemfile, nil, {}) return unless definition.dependencies.any? diff --git a/lib/bundler/plugin/dsl.rb b/lib/bundler/plugin/dsl.rb index f59c051f..b0fb6735 100644 --- a/lib/bundler/plugin/dsl.rb +++ b/lib/bundler/plugin/dsl.rb @@ -1,12 +1,14 @@ # frozen_string_literal: true module Bundler + # Dsl to parse the Gemfile looking for plugins to install class Plugin::Dsl < Bundler::Dsl alias_method :_gem, :gem # To use for plugin installation as gem - # So that we don't have to overwrite all there methods to dummy ones - [:gemspec, :gem, :path, :install_if, :platforms, :env] - .each {|m| undef_method m} + # So that we don't have to override all there methods to dummy ones + # explicitly. + # They will be handled by missing_methods + [:gemspec, :gem, :path, :install_if, :platforms, :env].each {|m| undef_method m } def initialize @sources = Plugin::SourceList.new diff --git a/lib/bundler/plugin/installer.rb b/lib/bundler/plugin/installer.rb index 16dc05a5..605d272d 100644 --- a/lib/bundler/plugin/installer.rb +++ b/lib/bundler/plugin/installer.rb @@ -6,8 +6,6 @@ module Bundler # This class is supposed to be wrapper over the existing gem installation infra # but currently it itself handles everything as the Source's subclasses (e.g. Source::RubyGems) # are heavily dependent on the Gemfile. - # - # @todo: Remove the dependencies of Source's subclasses and try to use the Bundler sources directly. This will reduce the redundancies. class Plugin::Installer def install(name, options) if options[:git] @@ -22,6 +20,11 @@ module Bundler end end + # Installs the plugin from Definition object created by limited parsing of + # Gemfile searching for plugins to be installed + # + # @param [Definition] definiton object + # @return [Hash] map of plugin names to thier paths def install_definition(definition) plugins = definition.dependencies.map(&:name) @@ -30,7 +33,7 @@ module Bundler paths = install_from_spec specs - paths.select {|name, _| plugins.include? name} + paths.select {|name, _| plugins.include? name } end private @@ -74,13 +77,12 @@ module Bundler paths[name] end - # Installs the plugin from the provided spec and returns the path where the - # plugin was installed. + # Installs the plugins and deps from the provided specs and returns map of + # gems to their paths # - # @param spec to fetch and install - # @raise [ArgumentError] if the spec object has no remote set + # @param specs to install # - # @return [String] the path where the plugin was installed + # @return [Hash] map of names to path where the plugin was installed def install_from_spec(specs) paths = {} diff --git a/lib/bundler/plugin/source_list.rb b/lib/bundler/plugin/source_list.rb index 457b4ef7..c1903e9d 100644 --- a/lib/bundler/plugin/source_list.rb +++ b/lib/bundler/plugin/source_list.rb @@ -1,8 +1,9 @@ # frozen_string_literal: true module Bundler + # SourceList object to be used while parsing the Gemfile, setting the + # approptiate options to be used with Source classes for plugin installation class Plugin::SourceList < Bundler::SourceList - def initialize @rubygems_aggregate = Source::Rubygems.new :plugin => true super @@ -15,6 +16,5 @@ module Bundler def add_rubygems_source(options = {}) add_source_to_list Source::Rubygems.new(options.merge(:plugin => true)), @rubygems_sources end - end end |