Author: boisvert Date: Sun Feb 28 16:49:17 2010 New Revision: 917200 URL: http://svn.apache.org/viewvc?rev=917200&view=rev Log: BUILDR-183 Can't define root artifact namespace outside of project (Ittay Dror)
Modified: buildr/trunk/CHANGELOG buildr/trunk/lib/buildr/packaging/artifact_namespace.rb buildr/trunk/spec/packaging/artifact_namespace_spec.rb Modified: buildr/trunk/CHANGELOG URL: http://svn.apache.org/viewvc/buildr/trunk/CHANGELOG?rev=917200&r1=917199&r2=917200&view=diff ============================================================================== --- buildr/trunk/CHANGELOG (original) +++ buildr/trunk/CHANGELOG Sun Feb 28 16:49:17 2010 @@ -28,6 +28,8 @@ * Change: Updated to JMock 2.5.1 (Antoine Toulme) * Change: Load buildr.rb from $HOME/.buildr instead of $HOME ($HOME/buildr.rb is still loaded with deprecation warning) +* Fixed: BUILDR-183 Can't define root artifact namespace outside of project + (Ittay Dror) * Fixed: BUILDR-223 Release Task: customizable commit message (Alexis Midon) * Fixed: BUILDR-327 Specifying :plugin eclipse nature explicitly fails * Fixed: BUILDR-330 Install task should re-install artifact even if they Modified: buildr/trunk/lib/buildr/packaging/artifact_namespace.rb URL: http://svn.apache.org/viewvc/buildr/trunk/lib/buildr/packaging/artifact_namespace.rb?rev=917200&r1=917199&r2=917200&view=diff ============================================================================== --- buildr/trunk/lib/buildr/packaging/artifact_namespace.rb (original) +++ buildr/trunk/lib/buildr/packaging/artifact_namespace.rb Sun Feb 28 16:49:17 2010 @@ -274,10 +274,13 @@ end end name = name.to_s - return ROOT if name.size == 0 - name = name.to_s - @instances ||= Hash.new { |h, k| h[k] = new(k) } - instance = @instances[name] + if name.size == 0 + instance = ROOT + else + name = name.to_s + @instances ||= Hash.new { |h, k| h[k] = new(k) } + instance = @instances[name] + end yield(instance) if block_given? instance end @@ -529,6 +532,7 @@ clear def root + yield ROOT if block_given? ROOT end Modified: buildr/trunk/spec/packaging/artifact_namespace_spec.rb URL: http://svn.apache.org/viewvc/buildr/trunk/spec/packaging/artifact_namespace_spec.rb?rev=917200&r1=917199&r2=917200&view=diff ============================================================================== --- buildr/trunk/spec/packaging/artifact_namespace_spec.rb (original) +++ buildr/trunk/spec/packaging/artifact_namespace_spec.rb Sun Feb 28 16:49:17 2010 @@ -32,7 +32,19 @@ end it 'should yield the namespace if a block is given' do - Buildr::ArtifactNamespace.root { |ns| ns.should be_root } + flag = false + Buildr::ArtifactNamespace.root { |ns| flag = true; ns.should be_root } + flag.should == true + end + + it 'should return the root when used outside of a project definition' do + artifact_ns.should be_root + end + + it 'should yield to a block when used outside of a project definition' do + flag = false + artifact_ns {|ns| flag = true; ns.should be_root} + flag.should == true end end