lib/bundler/cli/gem.rb in bundler-1.9.5 vs lib/bundler/cli/gem.rb in bundler-1.9.6
- old
+ new
@@ -18,13 +18,13 @@
def run
Bundler.ui.confirm "Creating gem '#{name}'..."
underscored_name = name.tr('-', '_')
namespaced_path = name.tr('-', '/')
- constant_name = name.split('_').map{|p| p[0..0].upcase + p[1..-1] unless p.empty?}.join
- constant_name = constant_name.split('-').map{|q| q[0..0].upcase + q[1..-1] }.join('::') if constant_name =~ /-/
+ constant_name = name.gsub(/-[_-]*(?![_-]|$)/){ '::' }.gsub(/([_-]+|(::)|^)(.|$)/){ $2.to_s + $3.upcase }
constant_array = constant_name.split('::')
+
git_user_name = `git config user.name`.chomp
git_user_email = `git config user.email`.chomp
config = {
:name => name,
@@ -183,10 +183,10 @@
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)
+ elsif constant_array.inject(Object) {|c, s| (c.const_defined?(s) && c.const_get(s)) || break }
Bundler.ui.error "Invalid gem name #{name} constant #{constant_array.join("::")} is already in use. Please choose another gem name."
exit 1
end
end