summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Arko <andre@arko.net>2011-09-17 17:50:21 -0700
committerAndre Arko <andre@arko.net>2011-09-17 17:50:23 -0700
commitba7e1b082a45460cacefe0eb5c67b2632c4ee498 (patch)
tree545a8f978d3c927d9614cae9b59376dab09d4130
parentf4307761cf8b25f5ab300331bb7ab03025c4db86 (diff)
downloadbundler-ba7e1b082a45460cacefe0eb5c67b2632c4ee498.tar.gz
String#capitalize downcases the rest of the string :(
fixes #1303
-rw-r--r--lib/bundler/cli.rb4
-rw-r--r--spec/bundler/gem_helper_spec.rb7
2 files changed, 9 insertions, 2 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index 4ed5b7ab1c..8839c8c430 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -475,8 +475,8 @@ module Bundler
def gem(name)
name = name.chomp("/") # remove trailing slash if present
target = File.join(Dir.pwd, name)
- constant_name = name.split('_').map{|p| p.capitalize}.join
- constant_name = constant_name.split('-').map{|q| q.capitalize}.join('::') if constant_name =~ /-/
+ constant_name = name.split('_').map{|p| p[0..0].upcase + p[1..-1] }.join
+ constant_name = constant_name.split('-').map{|q| q[0..0].upcase + q[1..-1] }.join('::') if constant_name =~ /-/
constant_array = constant_name.split('::')
git_author_name = `git config user.name`.chomp
git_author_email = `git config user.email`.chomp
diff --git a/spec/bundler/gem_helper_spec.rb b/spec/bundler/gem_helper_spec.rb
index bb21b60ced..ad2bb32792 100644
--- a/spec/bundler/gem_helper_spec.rb
+++ b/spec/bundler/gem_helper_spec.rb
@@ -31,6 +31,13 @@ describe "Bundler::GemHelper tasks" do
File.open(File.join(app.to_s, 'test2.gemspec'), 'w') {|f| f << ''}
proc { Bundler::GemHelper.new(app.to_s) }.should raise_error(/Unable to determine name/)
end
+
+ it "handles namespaces and converting to CamelCase" do
+ bundle 'gem test-foo_bar'
+ lib = bundled_app('test-foo_bar').join('lib/test-foo_bar.rb').read
+ lib.should include("module Test")
+ lib.should include("module FooBar")
+ end
end
context "gem management" do