diff --git a/lib/jenkins/filepath.rb b/lib/jenkins/filepath.rb index a3c5598..511f9fc 100644 --- a/lib/jenkins/filepath.rb +++ b/lib/jenkins/filepath.rb @@ -16,6 +16,10 @@ module Jenkins FilePath.new(@native.child(name)) end + def join(*names) + FilePath.new names.inject(@native) {|native, name| native.child(name) } + end + def to_s @native.getRemote() end diff --git a/spec/jenkins/filepath_spec.rb b/spec/jenkins/filepath_spec.rb index 82e8d04..6e142a5 100644 --- a/spec/jenkins/filepath_spec.rb +++ b/spec/jenkins/filepath_spec.rb @@ -17,6 +17,12 @@ describe Jenkins::FilePath do (create(".") + "foo" + "bar").to_s.should == "foo/bar" end + it "returns child for join" do + create('.').join('foo').to_s.should == "foo" + create('.').join('foo', 'bar').to_s.should == "foo/bar" + create('.').join('foo', 'bar', 'baz').to_s.should == "foo/bar/baz" + end + it "returns path for to_s" do create(".").to_s.should == "." end