sugarcube 0.20.20 → 0.20.21
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/README.md +2 -2
- data/app/uicontrol_controller.rb +4 -4
- data/lib/sugarcube/activesupport.rb +7 -6
- data/lib/sugarcube/uicontrol.rb +1 -1
- data/lib/sugarcube/uiview.rb +0 -2
- data/lib/sugarcube/version.rb +1 -1
- data/spec/activesupport_spec.rb +27 -10
- data/spec/nsurl_spec.rb +4 -0
- data/spec/uicontrol_spec.rb +68 -0
- metadata +2 -2
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1757,7 +1757,8 @@ Quick wrapper for `CFUUIDCreate()` and `CFUUIDCreateString()`. Identical to the
|
|
1757
1757
|
Ruby on Rails Ripoffs (RoR-R?)
|
1758
1758
|
---------------
|
1759
1759
|
|
1760
|
-
aka `ActiveSupport`.
|
1760
|
+
aka `ActiveSupport`. Now that Thomas Kadauke has released [motion-support][],
|
1761
|
+
consider these extensions deprecated. They will be removed in version 1.0.
|
1761
1762
|
|
1762
1763
|
```ruby
|
1763
1764
|
# truthiness with `blank?`
|
@@ -1775,7 +1776,6 @@ true.blank? # => false
|
|
1775
1776
|
|
1776
1777
|
# and my favorite
|
1777
1778
|
1.in? [1,2,3] # => true
|
1778
|
-
1.in? 1,2,3 # => true
|
1779
1779
|
1.in? 4..5 # => false
|
1780
1780
|
```
|
1781
1781
|
|
data/app/uicontrol_controller.rb
CHANGED
@@ -30,17 +30,17 @@ class UIControlController < UIViewController
|
|
30
30
|
@button1.center = [@button1.center.x, @button1.center.y - 30]
|
31
31
|
self.view << @button2
|
32
32
|
|
33
|
-
@button1.on :touch
|
33
|
+
@button1.on :touch do |sender,event|
|
34
34
|
@touched_1 = true
|
35
35
|
@touched = sender
|
36
36
|
@touched_count += 1
|
37
|
-
|
37
|
+
end
|
38
38
|
|
39
|
-
@button2.on :touch
|
39
|
+
@button2.on :touch do |sender,event|
|
40
40
|
@touched_2 = true
|
41
41
|
@touched = sender
|
42
42
|
@touched_count += 1
|
43
|
-
|
43
|
+
end
|
44
44
|
|
45
45
|
reset
|
46
46
|
end
|
@@ -16,13 +16,14 @@ class Object
|
|
16
16
|
# okay, this is strange, but `rake spec` fails if I define the method as `in?`
|
17
17
|
# but passes if I alias it, as I do below. weird, but I don't want to fight
|
18
18
|
# it.
|
19
|
-
def
|
20
|
-
if
|
21
|
-
|
22
|
-
else
|
23
|
-
return list.include?(self)
|
19
|
+
def __in_workaround(args, *other_args)
|
20
|
+
if other_args.length > 0
|
21
|
+
raise "The varargs form of `Object#in?` has been removed. Use an array instead."
|
24
22
|
end
|
23
|
+
args.include?(self)
|
24
|
+
rescue NoMethodError
|
25
|
+
raise ArgumentError.new("The parameter passed to #in? must respond to #include?")
|
25
26
|
end
|
26
|
-
alias
|
27
|
+
alias in? __in_workaround
|
27
28
|
|
28
29
|
end
|
data/lib/sugarcube/uicontrol.rb
CHANGED
@@ -61,7 +61,7 @@ class UIControl
|
|
61
61
|
sendActionsForControlEvents(event_mask)
|
62
62
|
end
|
63
63
|
|
64
|
-
|
64
|
+
private
|
65
65
|
# event blocks need to be retained, and the addTarget method explicitly does
|
66
66
|
# *not* retain `target`. This makes sure that callbacks are retained by
|
67
67
|
# pushing the block onto a stack.
|
data/lib/sugarcube/uiview.rb
CHANGED
@@ -426,7 +426,6 @@ class UIView
|
|
426
426
|
subviews.each do |subview|
|
427
427
|
CGContextSaveGState(context)
|
428
428
|
CGContextTranslateCTM(context, subview.frame.origin.x, subview.frame.origin.y)
|
429
|
-
# CGContextConcatCTM(subview.layer.affineTransform)
|
430
429
|
subview.layer.renderInContext(context)
|
431
430
|
CGContextRestoreGState(context)
|
432
431
|
end
|
@@ -434,7 +433,6 @@ class UIView
|
|
434
433
|
UIGraphicsEndImageContext()
|
435
434
|
else
|
436
435
|
UIGraphicsBeginImageContextWithOptions(bounds.size, false, scale)
|
437
|
-
# CGContextConcatCTM(layer.affineTransform)
|
438
436
|
layer.renderInContext(UIGraphicsGetCurrentContext())
|
439
437
|
image = UIGraphicsGetImageFromCurrentImageContext()
|
440
438
|
UIGraphicsEndImageContext()
|
data/lib/sugarcube/version.rb
CHANGED
data/spec/activesupport_spec.rb
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
class LifeUniverseAndEverything
|
2
|
+
def include?(obj)
|
3
|
+
obj == 42
|
4
|
+
end
|
5
|
+
end
|
6
|
+
|
7
|
+
|
1
8
|
describe 'ActiveSupport' do
|
2
9
|
|
3
10
|
describe "should have a blank? method" do
|
@@ -60,20 +67,30 @@ describe 'ActiveSupport' do
|
|
60
67
|
end
|
61
68
|
end
|
62
69
|
|
63
|
-
|
64
|
-
|
65
|
-
|
70
|
+
describe "in?" do
|
71
|
+
it "should support arrays" do
|
72
|
+
1.in?([1,2,3]).should == true
|
73
|
+
0.in?([1,2,3]).should == false
|
74
|
+
end
|
66
75
|
|
67
|
-
|
68
|
-
|
76
|
+
it "should support hashes" do
|
77
|
+
:a.in?({a:1,b:2,c:3}).should == true
|
78
|
+
1.in?({a:1,b:2,c:3}).should == false
|
79
|
+
end
|
69
80
|
|
70
|
-
|
71
|
-
|
81
|
+
it "should support ranges" do
|
82
|
+
1.in?(1..3).should == true
|
83
|
+
0.in?(1..3).should == false
|
84
|
+
end
|
72
85
|
|
73
|
-
|
74
|
-
|
86
|
+
it "should support strings" do
|
87
|
+
'a'.in?("apple").should == true
|
88
|
+
end
|
75
89
|
|
76
|
-
|
90
|
+
it "should support anything that implements `include?`" do
|
91
|
+
42.in?(LifeUniverseAndEverything.new).should == true
|
92
|
+
0.in?(LifeUniverseAndEverything.new).should == false
|
93
|
+
end
|
77
94
|
end
|
78
95
|
|
79
96
|
end
|
data/spec/nsurl_spec.rb
CHANGED
data/spec/uicontrol_spec.rb
CHANGED
@@ -1,3 +1,71 @@
|
|
1
|
+
describe 'UIControl' do
|
2
|
+
describe 'should have sugarcube_callbacks' do
|
3
|
+
before do
|
4
|
+
@ctrl = UIButton.new
|
5
|
+
end
|
6
|
+
after do
|
7
|
+
@ctrl.off
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should start off empty' do
|
11
|
+
@ctrl.send(:sugarcube_callbacks).should == {}
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should add a touch handler' do
|
15
|
+
@ctrl.on(:touch) {}
|
16
|
+
@ctrl.send(:sugarcube_callbacks).length.should == 1
|
17
|
+
@ctrl.send(:sugarcube_callbacks)[UIControlEventTouchUpInside].length.should == 1
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'should remove the touch handler' do
|
21
|
+
@ctrl.on(:touch) {}
|
22
|
+
@ctrl.off
|
23
|
+
@ctrl.send(:sugarcube_callbacks).length.should == 0
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should add two touch handlers' do
|
27
|
+
@ctrl.on(:touch) {}
|
28
|
+
@ctrl.on(:touch) {}
|
29
|
+
@ctrl.send(:sugarcube_callbacks)[UIControlEventTouchUpInside].length.should == 2
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should remove both touch handlers' do
|
33
|
+
@ctrl.on(:touch) {}
|
34
|
+
@ctrl.on(:touch) {}
|
35
|
+
@ctrl.off
|
36
|
+
@ctrl.send(:sugarcube_callbacks).length.should == 0
|
37
|
+
end
|
38
|
+
|
39
|
+
it 'should add multiple control events' do
|
40
|
+
@ctrl.on(:touch_start, :touch_stop) {}
|
41
|
+
@ctrl.send(:sugarcube_callbacks)[UIControlEventTouchDown | UIControlEventTouchDragEnter].length.should == 1
|
42
|
+
@ctrl.send(:sugarcube_callbacks)[UIControlEventTouchUpInside | UIControlEventTouchCancel | UIControlEventTouchDragExit].length.should == 1
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should remove some events' do
|
46
|
+
@ctrl.on(:touch_start, :touch_stop) {}
|
47
|
+
@ctrl.off(:touch_start)
|
48
|
+
@ctrl.send(:sugarcube_callbacks)[UIControlEventTouchUpInside | UIControlEventTouchCancel | UIControlEventTouchDragExit].length.should == 1
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should distinguish events' do
|
52
|
+
@ctrl.on(:touch) {}
|
53
|
+
@ctrl.on(:touch_start, :touch_stop) {}
|
54
|
+
@ctrl.off(:touch_start)
|
55
|
+
@ctrl.send(:sugarcube_callbacks)[UIControlEventTouchUpInside].length.should == 1
|
56
|
+
@ctrl.send(:sugarcube_callbacks)[UIControlEventTouchUpInside | UIControlEventTouchCancel | UIControlEventTouchDragExit].length.should == 1
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should remove all events' do
|
60
|
+
@ctrl.on(:touch_start, :touch_stop) {}
|
61
|
+
@ctrl.off(:touch_start)
|
62
|
+
@ctrl.off(:touch_stop)
|
63
|
+
@ctrl.send(:sugarcube_callbacks).should == {}
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
1
69
|
describe 'UIControl' do
|
2
70
|
tests UIControlController
|
3
71
|
|
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.21
|
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-
|
16
|
+
date: 2013-05-14 00:00:00.000000000 Z
|
17
17
|
dependencies: []
|
18
18
|
description: ! '== Description
|
19
19
|
|