Commit 5474e0e5f0186971be9129d8708d449128df7d38
- Date: Mon Jul 02 20:14:21 +0000 2007
- Committer: fbos (fbos@d6c2ea82-c31b-0410-8381-e9c44f9824c5)
- Author: fbos (fbos@d6c2ea82-c31b-0410-8381-e9c44f9824c5)
- Commit SHA1: 5474e0e5f0186971be9129d8708d449128df7d38
- Tree SHA1: 7a8987914173ab486f5d1a1dd2bcc72b8416122b
WorkingCopy#propget returns a #to_i version of the value, or nil, depending on circumstances.
git-svn-id: svn+ssh://rubyforge.org/var/svn/piston/trunk@123 d6c2ea82-c31b-0410-8381-e9c44f9824c5
Commit diff
| |   |
| 51 | 51 | end |
| 52 | 52 | |
| 53 | 53 | def propget(propname, target=self.dir) |
| 54 | | svn(:propget, propname, wc_path(target)).chomp |
| 54 | value = svn(:propget, propname, wc_path(target)).chomp |
| 55 | return nil if value.empty? |
| 56 | value.to_i.to_s == value ? value.to_i : value |
| 55 | 57 | end |
| 56 | 58 | |
| 57 | 59 | alias_method :[], :propget |
| toggle raw diff |
--- a/lib/piston/working_copy.rb
+++ b/lib/piston/working_copy.rb
@@ -51,7 +51,9 @@ module Piston
end
def propget(propname, target=self.dir)
- svn(:propget, propname, wc_path(target)).chomp
+ value = svn(:propget, propname, wc_path(target)).chomp
+ return nil if value.empty?
+ value.to_i.to_s == value ? value.to_i : value
end
alias_method :[], :propget
|
| |   |
| 102 | 102 | @wc["piston:temp"] = "new value" |
| 103 | 103 | @wc.propget("piston:temp").should == "new value" |
| 104 | 104 | end |
| 105 | |
| 106 | it "should return a Fixnum when the property value is an Integer" do |
| 107 | @wc.propset "piston:some-property", 24 |
| 108 | @wc.propget("piston:some-property").should == 24 |
| 109 | end |
| 110 | |
| 111 | it "should return nil when the property doesn't exist" do |
| 112 | @wc.propget("piston:some-property").should be_nil |
| 113 | end |
| 105 | 114 | end |
| 106 | 115 | |
| 107 | 116 | describe Piston::WorkingCopy, "against a repository with 1 revision" do |
| toggle raw diff |
--- a/spec/working_copy_spec.rb
+++ b/spec/working_copy_spec.rb
@@ -102,6 +102,15 @@ describe Piston::WorkingCopy, "with properties on the root WC dir" do
@wc["piston:temp"] = "new value"
@wc.propget("piston:temp").should == "new value"
end
+
+ it "should return a Fixnum when the property value is an Integer" do
+ @wc.propset "piston:some-property", 24
+ @wc.propget("piston:some-property").should == 24
+ end
+
+ it "should return nil when the property doesn't exist" do
+ @wc.propget("piston:some-property").should be_nil
+ end
end
describe Piston::WorkingCopy, "against a repository with 1 revision" do
|