summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsutosh Palai <asupalai@gmail.com>2016-06-06 12:40:55 +0530
committerAsutosh Palai <asupalai@gmail.com>2016-06-06 12:41:06 +0530
commit008722762079ecc00470a577fc3d4a9416b39506 (patch)
treee422518a4723bc3088b5761f56b83fa1a0433fdf
parentcb7286d8815d774fdabcae91e5f987260d9871e0 (diff)
downloadbundler-008722762079ecc00470a577fc3d4a9416b39506.tar.gz
Fixed the issues raised in comments
-rw-r--r--lib/bundler/cli/install.rb34
-rw-r--r--lib/bundler/plugin.rb18
-rw-r--r--lib/bundler/plugin/api.rb2
-rw-r--r--lib/bundler/plugin/dsl.rb4
-rw-r--r--lib/bundler/plugin/installer.rb8
-rw-r--r--spec/plugins/api.rb6
-rw-r--r--spec/plugins/command.rb8
-rw-r--r--spec/plugins/install.rb12
-rw-r--r--spec/support/builders.rb2
9 files changed, 50 insertions, 44 deletions
diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb
index a0197fc6f8..810eb9234c 100644
--- a/lib/bundler/cli/install.rb
+++ b/lib/bundler/cli/install.rb
@@ -185,19 +185,27 @@ module Bundler
end
def normalize_settings
- Bundler.settings[:path] = nil if options[:system]
- Bundler.settings[:path] = "vendor/bundle" if options[:deployment]
- Bundler.settings[:path] = options["path"] if options["path"]
- Bundler.settings[:path] ||= "bundle" if options["standalone"]
- Bundler.settings[:bin] = options["binstubs"] if options["binstubs"]
- Bundler.settings[:bin] = nil if options["binstubs"] && options["binstubs"].empty?
- Bundler.settings[:shebang] = options["shebang"] if options["shebang"]
- Bundler.settings[:jobs] = options["jobs"] if options["jobs"]
- Bundler.settings[:no_prune] = true if options["no-prune"]
- Bundler.settings[:no_install] = true if options["no-install"]
- Bundler.settings[:clean] = options["clean"] if options["clean"]
- Bundler.settings.without = options[:without]
- Bundler.settings.with = options[:with]
+ Bundler.settings[:path] = nil if options[:system]
+ Bundler.settings[:path] = "vendor/bundle" if options[:deployment]
+ Bundler.settings[:path] = options["path"] if options["path"]
+ Bundler.settings[:path] ||= "bundle" if options["standalone"]
+
+ Bundler.settings[:bin] = options["binstubs"] if options["binstubs"]
+ Bundler.settings[:bin] = nil if options["binstubs"] && options["binstubs"].empty?
+
+ Bundler.settings[:shebang] = options["shebang"] if options["shebang"]
+
+ Bundler.settings[:jobs] = options["jobs"] if options["jobs"]
+
+ Bundler.settings[:no_prune] = true if options["no-prune"]
+
+ Bundler.settings[:no_install] = true if options["no-install"]
+
+ Bundler.settings[:clean] = options["clean"] if options["clean"]
+
+ Bundler.settings.without = options[:without]
+ Bundler.settings.with = options[:with]
+
Bundler.settings[:disable_shared_gems] = Bundler.settings[:path] ? true : nil
end
diff --git a/lib/bundler/plugin.rb b/lib/bundler/plugin.rb
index 978f4a57a4..caf8b5b800 100644
--- a/lib/bundler/plugin.rb
+++ b/lib/bundler/plugin.rb
@@ -2,13 +2,13 @@
module Bundler
module Plugin
- autoload :Api, "bundler/plugin/api"
- autoload :Dsl, "bundler/plugin/dsl"
+ autoload :API, "bundler/plugin/api"
+ autoload :DSL, "bundler/plugin/dsl"
autoload :Index, "bundler/plugin/index"
autoload :Installer, "bundler/plugin/installer"
autoload :SourceList, "bundler/plugin/source_list"
- PLUGIN_FILE_NAME = "plugin.rb".freeze
+ PLUGIN_FILE_NAME = "plugins.rb".freeze
@commands = {}
@@ -37,7 +37,7 @@ module Bundler
#
# @param [Pathname] gemfile path
def eval_gemfile(gemfile)
- definition = Dsl.evaluate(gemfile, nil, {})
+ definition = DSL.evaluate(gemfile, nil, {})
return unless definition.dependencies.any?
plugins = Installer.new.install_definition(definition)
@@ -65,7 +65,7 @@ module Bundler
@cache ||= root.join("cache")
end
- # To be called via the Api to register to handle a command
+ # To be called via the API to register to handle a command
def add_command(command, cls)
@commands[command] = cls
end
@@ -89,16 +89,16 @@ module Bundler
# Checks if the gem is good to be a plugin
#
- # At present it only checks whether it contains plugin.rb file
+ # At present it only checks whether it contains plugins.rb file
#
# @param [Pathname] plugin_path the path plugin is installed at
- # @raise [Error] if plugin.rb file is not found
+ # @raise [Error] if plugins.rb file is not found
def validate_plugin!(plugin_path)
plugin_file = plugin_path.join(PLUGIN_FILE_NAME)
raise "#{PLUGIN_FILE_NAME} was not found in the plugin!" unless plugin_file.file?
end
- # Runs the plugin.rb file in an isolated namespace, records the plugin
+ # Runs the plugins.rb file in an isolated namespace, records the plugin
# actions it registers for and then passes the data to index to be stored.
#
# @param [String] name the name of the plugin
@@ -115,7 +115,7 @@ module Bundler
@commands = commands
end
- # Executes the plugin.rb file
+ # Executes the plugins.rb file
#
# @param [String] name of the plugin
def load_plugin(name)
diff --git a/lib/bundler/plugin/api.rb b/lib/bundler/plugin/api.rb
index ea9ff1ea12..4771c26121 100644
--- a/lib/bundler/plugin/api.rb
+++ b/lib/bundler/plugin/api.rb
@@ -21,7 +21,7 @@ module Bundler
# To use it without inheriting, you will have to create an object of this
# to use the functions (except for declaration functions like command, source,
# and hooks).
- class Plugin::Api
+ class Plugin::API
# The plugins should declare that they handle a command through this helper.
#
# @param [String] command being handled by them
diff --git a/lib/bundler/plugin/dsl.rb b/lib/bundler/plugin/dsl.rb
index 89d9140aed..dc1eb538d5 100644
--- a/lib/bundler/plugin/dsl.rb
+++ b/lib/bundler/plugin/dsl.rb
@@ -2,7 +2,7 @@
module Bundler
# Dsl to parse the Gemfile looking for plugins to install
- class Plugin::Dsl < Bundler::Dsl
+ class Plugin::DSL < Bundler::Dsl
alias_method :_gem, :gem # To use for plugin installation as gem
# So that we don't have to override all there methods to dummy ones
@@ -20,7 +20,7 @@ module Bundler
end
def method_missing(name, *args)
- # Dummy evaluation
+ super unless Bundler::Dsl.instance_methods.include? name
end
end
end
diff --git a/lib/bundler/plugin/installer.rb b/lib/bundler/plugin/installer.rb
index d4de0be502..38ca58ba09 100644
--- a/lib/bundler/plugin/installer.rb
+++ b/lib/bundler/plugin/installer.rb
@@ -34,7 +34,7 @@ module Bundler
definition.resolve_remotely!
specs = definition.specs
- paths = install_from_spec specs
+ paths = install_from_specs specs
paths.select {|name, _| plugins.include? name }
end
@@ -74,7 +74,7 @@ module Bundler
idx = rg_source.specs
specs = Resolver.resolve(deps_proxies, idx).materialize([dep])
- paths = install_from_spec specs
+ paths = install_from_specs specs
paths[name]
end
@@ -85,12 +85,10 @@ module Bundler
# @param specs to install
#
# @return [Hash] map of names to path where the plugin was installed
- def install_from_spec(specs)
+ def install_from_specs(specs)
paths = {}
specs.each do |spec|
- next if spec.name == "bundler"
-
spec.source.install spec
paths[spec.name] = spec.full_gem_path
diff --git a/spec/plugins/api.rb b/spec/plugins/api.rb
index 8fd5689227..e9bb81201a 100644
--- a/spec/plugins/api.rb
+++ b/spec/plugins/api.rb
@@ -3,10 +3,10 @@ require "spec_helper"
require "bundler/plugin"
-describe Bundler::Plugin::Api do
+describe Bundler::Plugin::API do
context "plugin declarations" do
before do
- stub_const "UserPluginClass", Class.new(Bundler::Plugin::Api)
+ stub_const "UserPluginClass", Class.new(Bundler::Plugin::API)
end
it "declares a command plugin with same class as handler" do
@@ -30,7 +30,7 @@ describe Bundler::Plugin::Api do
context "bundler interfaces provided" do
before do
- stub_const "UserPluginClass", Class.new(Bundler::Plugin::Api)
+ stub_const "UserPluginClass", Class.new(Bundler::Plugin::API)
end
subject(:api) { UserPluginClass.new }
diff --git a/spec/plugins/command.rb b/spec/plugins/command.rb
index 5e3d8217bd..bb2aa26043 100644
--- a/spec/plugins/command.rb
+++ b/spec/plugins/command.rb
@@ -5,9 +5,9 @@ describe "command plugins" do
it "executes without arguments" do
build_repo2 do
build_plugin "command-mah" do |s|
- s.write "plugin.rb", <<-RUBY
+ s.write "plugins.rb", <<-RUBY
module Mah
- class Plugin < Bundler::Plugin::Api
+ class Plugin < Bundler::Plugin::API
command "mahcommand" # declares the command
def exec(command, args)
@@ -29,11 +29,11 @@ describe "command plugins" do
it "accepts the arguments" do
build_repo2 do
build_plugin "the-echoer" do |s|
- s.write "plugin.rb", <<-RUBY
+ s.write "plugins.rb", <<-RUBY
module Resonance
class Echoer
# Another method to declare the command
- Bundler::Plugin::Api.command "echo", self
+ Bundler::Plugin::API.command "echo", self
def exec(command, args)
puts "You gave me \#{args.join(", ")}"
diff --git a/spec/plugins/install.rb b/spec/plugins/install.rb
index c5d0937d05..971b11a298 100644
--- a/spec/plugins/install.rb
+++ b/spec/plugins/install.rb
@@ -29,24 +29,24 @@ describe "bundler plugin install" do
end
context "malformatted plugin" do
- it "fails when plugin.rb is missing" do
+ it "fails when plugins.rb is missing" do
build_repo2 do
build_gem "charlie"
end
bundle "plugin install charlie --source file://#{gem_repo2}"
- expect(out).to include("plugin.rb was not found")
+ expect(out).to include("plugins.rb was not found")
expect(out).not_to include("Installed plugin")
expect(plugin_gems("charlie-1.0")).not_to be_directory
end
- it "fails when plugin.rb throws exception on load" do
+ it "fails when plugins.rb throws exception on load" do
build_repo2 do
build_plugin "chaplin" do |s|
- s.write "plugin.rb", <<-RUBY
+ s.write "plugins.rb", <<-RUBY
raise "I got you man"
RUBY
end
@@ -63,7 +63,7 @@ describe "bundler plugin install" do
context "git plugins" do
it "installs form a git source" do
build_git "foo" do |s|
- s.write "plugin.rb"
+ s.write "plugins.rb"
end
bundle "plugin install foo --git file://#{lib_path("foo-1.0")}"
@@ -110,7 +110,7 @@ describe "bundler plugin install" do
it "accepts git sources" do
build_git "ga-plugin" do |s|
- s.write "plugin.rb"
+ s.write "plugins.rb"
end
install_gemfile <<-G
diff --git a/spec/support/builders.rb b/spec/support/builders.rb
index feabdc0e47..8e19f9ae94 100644
--- a/spec/support/builders.rb
+++ b/spec/support/builders.rb
@@ -707,7 +707,7 @@ module Spec
class PluginBuilder < GemBuilder
def _default_files
- @_default_files ||= super.merge("plugin.rb" => "")
+ @_default_files ||= super.merge("plugins.rb" => "")
end
end