[macruby-changes] [360] MacRuby/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Thu Jul 10 12:39:10 PDT 2008
Revision: 360
http://trac.macosforge.org/projects/ruby/changeset/360
Author: lsansonetti at apple.com
Date: 2008-07-10 12:39:10 -0700 (Thu, 10 Jul 2008)
Log Message:
-----------
adding NSData#rubyString
Modified Paths:
--------------
MacRuby/trunk/lib/osx/rubycocoa.rb
MacRuby/trunk/test-macruby/rubycocoa_test.rb
Modified: MacRuby/trunk/lib/osx/rubycocoa.rb
===================================================================
--- MacRuby/trunk/lib/osx/rubycocoa.rb 2008-07-10 19:14:47 UTC (rev 359)
+++ MacRuby/trunk/lib/osx/rubycocoa.rb 2008-07-10 19:39:10 UTC (rev 360)
@@ -105,6 +105,12 @@
end
include OSX
+class NSData
+ def rubyString
+ NSString.alloc.initWithData(self, encoding:NSASCIIStringEncoding).mutableCopy
+ end
+end
+
class NSUserDefaults
def [](key)
objectForKey(key)
Modified: MacRuby/trunk/test-macruby/rubycocoa_test.rb
===================================================================
--- MacRuby/trunk/test-macruby/rubycocoa_test.rb 2008-07-10 19:14:47 UTC (rev 359)
+++ MacRuby/trunk/test-macruby/rubycocoa_test.rb 2008-07-10 19:39:10 UTC (rev 360)
@@ -182,6 +182,19 @@
end
end
+describe 'NSData additions' do
+ before do
+ path = '/System/Library/DTDs/BridgeSupport.dtd'
+ @obj = NSData.dataWithContentsOfFile(path)
+ @ruby_data = File.read(path)
+ end
+
+ it "should respond to rubyString" do
+ @obj.respond_to?(:rubyString).should.be true
+ @obj.rubyString.should.equal @ruby_data
+ end
+end
+
describe 'NSUserDefaults additions' do
before do
@obj = NSUserDefaults.alloc.init
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macruby-changes/attachments/20080710/faef31aa/attachment.html
More information about the macruby-changes
mailing list