Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Make all paths be relative to Gemfile during evaluation.
Browse files Browse the repository at this point in the history
  • Loading branch information
cstrahan committed Jan 16, 2015
1 parent ea3ded9 commit b233205
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lib/bundler/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@ def gemspec(opts = nil)
path = opts && opts[:path] || '.'
name = opts && opts[:name] || '{,*}'
development_group = opts && opts[:development_group] || :development
gemfile = @gemfile || Bundler.default_gemfile
expanded_path = File.expand_path(path, gemfile.dirname)
expanded_path = path_relative_to_gemfile(path)

gemspecs = Dir[File.join(expanded_path, "#{name}.gemspec")]

Expand Down Expand Up @@ -133,7 +132,7 @@ def git_source(name, &block)
end

def path(path, options = {}, &blk)
with_source(@sources.add_path_source(normalize_hash(options).merge("path" => Pathname.new(path))), &blk)
with_source(@sources.add_path_source(normalize_hash(options).merge("path" => path_relative_to_gemfile(path))), &blk)
end

def git(uri, options = {}, &blk)
Expand Down Expand Up @@ -287,6 +286,10 @@ def normalize_options(name, version, opts)
opts["git"] = @git_sources[git_name].call(opts[git_name])
end

if opts.key?("path")
opts["path"] = path_relative_to_gemfile(opts["path"])
end

["git", "path", "svn"].each do |type|
if param = opts[type]
if version.first && version.first =~ /^\s*=?\s*(\d[^\s]*)\s*$/
Expand Down Expand Up @@ -318,5 +321,10 @@ def normalize_source(source)
raise GemfileError, "Unknown source '#{source}'"
end
end

def path_relative_to_gemfile(path)
@gemfile ||= Bundler.default_gemfile
@gemfile.dirname + path
end
end
end

0 comments on commit b233205

Please sign in to comment.