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

Commit

Permalink
Merge pull request #3424 from BM5k/pr3123
Browse files Browse the repository at this point in the history
prevent naming mistake
  • Loading branch information
indirect committed Feb 21, 2015
2 parents 6989472 + 17a4fc4 commit e583753
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/bundler/cli/gem.rb
Expand Up @@ -40,6 +40,7 @@ def run
:bin => options[:bin],
:bundler_version => bundler_dependency_version
}
ensure_safe_gem_name(opts[:name], opts[:constant_array])

templates = {
"Gemfile.tt" => "Gemfile",
Expand Down Expand Up @@ -170,5 +171,15 @@ def bundler_dependency_version
req.join(".")
end

def ensure_safe_gem_name name, constant_array
if name =~ /^\d/
Bundler.ui.error "Invalid gem name #{name} Please give a name which does not start with numbers."
exit 1
elsif Object.const_defined?(constant_array.first)
Bundler.ui.error "Invalid gem name #{name} constant #{constant_array.join("::")} is already in use. Please choose another gem name."
exit 1
end
end

end
end

0 comments on commit e583753

Please sign in to comment.