sugarcube 0.20.5 → 0.20.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/sugarcube/nsdata.rb +11 -0
- data/lib/sugarcube/nsstring.rb +5 -0
- data/lib/sugarcube/nsstring_files.rb +2 -1
- data/lib/sugarcube/uiview.rb +7 -4
- data/lib/sugarcube/version.rb +1 -1
- data/spec/nsdata_spec.rb +25 -0
- data/spec/nsstring_files_spec.rb +33 -0
- metadata +2 -2
data/lib/sugarcube/nsdata.rb
CHANGED
@@ -20,4 +20,15 @@ class NSData
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
|
+
def write_to(path_or_url, atomically=true)
|
24
|
+
case path_or_url
|
25
|
+
when NSURL
|
26
|
+
self.writeToURL(path_or_url, atomically:atomically)
|
27
|
+
when NSString
|
28
|
+
self.writeToFile(path_or_url, atomically:atomically)
|
29
|
+
else
|
30
|
+
false
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
23
34
|
end
|
data/lib/sugarcube/nsstring.rb
CHANGED
@@ -21,7 +21,8 @@ class NSString
|
|
21
21
|
|
22
22
|
def remove!
|
23
23
|
ptr = Pointer.new(:id)
|
24
|
-
|
24
|
+
path = self.hasPrefix('/') ? self : self.document
|
25
|
+
NSFileManager.defaultManager.removeItemAtPath(path, error:ptr)
|
25
26
|
ptr[0]
|
26
27
|
end
|
27
28
|
|
data/lib/sugarcube/uiview.rb
CHANGED
@@ -351,10 +351,13 @@ class UIView
|
|
351
351
|
end
|
352
352
|
|
353
353
|
self.animate(options) {
|
354
|
-
|
355
|
-
|
356
|
-
|
357
|
-
|
354
|
+
window = UIApplication.sharedApplication.keyWindow || UIApplication.sharedApplication.windows[0]
|
355
|
+
top = self.convertPoint([0, 0], toView:nil).y
|
356
|
+
height = window.frame.size.height - top
|
357
|
+
offset = CGPoint.new(0, height * 1.5)
|
358
|
+
offset = CGPointApplyAffineTransform(offset, self.transform)
|
359
|
+
self.transform = CGAffineTransformConcat(self.transform, CGAffineTransformMakeRotation(-Math::PI/4))
|
360
|
+
self.center = CGPointMake(self.center.x + offset.x, self.center.y + offset.y)
|
358
361
|
}
|
359
362
|
end
|
360
363
|
|
data/lib/sugarcube/version.rb
CHANGED
data/spec/nsdata_spec.rb
CHANGED
@@ -26,5 +26,30 @@ describe "NSData" do
|
|
26
26
|
it "should be able to create a turkey string from data" do
|
27
27
|
"\u00ab\u03c4\u03b1\u0411\u042c\u2113\u03c3\u00bb".nsdata.nsstring.should == "\u00ab\u03c4\u03b1\u0411\u042c\u2113\u03c3\u00bb"
|
28
28
|
end
|
29
|
+
|
30
|
+
describe "write_to" do
|
31
|
+
|
32
|
+
after do
|
33
|
+
"a-z".document.remove!
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should write data to spcified path" do
|
37
|
+
path = "a-z".document
|
38
|
+
contents = (:a..:z).to_a.join
|
39
|
+
contents.nsdata.write_to(path).should == true
|
40
|
+
path.exists?.should == true
|
41
|
+
path.fileurl.nsdata.nsstring.should == contents
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should write data to spcified url" do
|
45
|
+
url = NSURL.alloc.initFileURLWithPath "a-z".document
|
46
|
+
contents = (:a..:z).to_a.join
|
47
|
+
contents.nsdata.write_to(url).should == true
|
48
|
+
path = "a-z".document
|
49
|
+
path.exists?.should == true
|
50
|
+
url.nsdata.nsstring.should == contents
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
29
54
|
|
30
55
|
end
|
data/spec/nsstring_files_spec.rb
CHANGED
@@ -74,6 +74,39 @@ describe 'NSString' do
|
|
74
74
|
end
|
75
75
|
|
76
76
|
end
|
77
|
+
|
78
|
+
describe "remove!" do
|
79
|
+
|
80
|
+
describe "in document" do
|
81
|
+
before do
|
82
|
+
"abc".writeToFile "abc".document, atomically:true
|
83
|
+
end
|
84
|
+
after do
|
85
|
+
NSFileManager.defaultManager.removeItemAtPath "abc".document, error:nil
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should remove" do
|
89
|
+
"abc".remove!.should == nil
|
90
|
+
"abc".exists?.should == false
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
describe "in cache" do
|
95
|
+
before do
|
96
|
+
"abc".writeToFile "abc".cache, atomically:true
|
97
|
+
end
|
98
|
+
after do
|
99
|
+
NSFileManager.defaultManager.removeItemAtPath "abc".cache, error:nil
|
100
|
+
end
|
101
|
+
|
102
|
+
it "should remove" do
|
103
|
+
path = "abc".cache
|
104
|
+
path.remove!.should == nil
|
105
|
+
path.exists?.should == false
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
end
|
77
110
|
|
78
111
|
describe 'resource()' do
|
79
112
|
describe '"info.plist".resource' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sugarcube
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.20.
|
4
|
+
version: 0.20.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ authors:
|
|
13
13
|
autorequire:
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
|
-
date: 2013-04-
|
16
|
+
date: 2013-04-04 00:00:00.000000000 Z
|
17
17
|
dependencies: []
|
18
18
|
description: ! '== Description
|
19
19
|
|