sugarcube 1.5.9 → 1.6.0
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/sugarcube-animations/caanimation.rb +35 -13
- data/lib/sugarcube-animations/calayer.rb +38 -1
- data/lib/sugarcube-animations/uiview.rb +28 -16
- data/lib/sugarcube-color/fixnum.rb +5 -1
- data/lib/sugarcube-color/nsarray.rb +8 -2
- data/lib/sugarcube-color/nsstring.rb +4 -0
- data/lib/sugarcube-color/symbol.rb +4 -0
- data/lib/sugarcube-color/uicolor.rb +6 -2
- data/lib/sugarcube-color/uiimage.rb +5 -1
- data/lib/sugarcube-constants/symbol.rb +35 -0
- data/lib/sugarcube-factories/uiactionsheet.rb +8 -11
- data/lib/sugarcube-factories/uialertview.rb +5 -12
- data/lib/sugarcube-nsdate/nsdate.rb +8 -3
- data/lib/sugarcube-repl/{object.rb → kernel.rb} +0 -0
- data/lib/sugarcube/version.rb +1 -1
- data/spec/caanimation_spec.rb +73 -0
- data/spec/calayer_spec.rb +1 -1
- data/spec/color_spec.rb +133 -13
- data/spec/fixnum_spec.rb +0 -16
- data/spec/nsarray_spec.rb +0 -16
- data/spec/nsdate_spec.rb +13 -0
- data/spec/nsstring_spec.rb +0 -24
- data/spec/pipes_spec.rb +15 -15
- data/spec/symbol_constants_spec.rb +29 -0
- data/spec/symbol_uicolor_spec.rb +6 -0
- data/spec/uiview_animation_spec.rb +31 -0
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1e1417a3329f05a87872dd59e8472640896a337c
|
4
|
+
data.tar.gz: 0e5f00b2c3c673b4ba29f3661ffd3bc5c27f1f58
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 47cbe203746a7c8cee85d0382542e72175fab5e8e9d61230b2decff908cb2a34abda874df732bdd770edcfcb02fe67778b4aea5ce70a5f248f8c96f6d317e2a9
|
7
|
+
data.tar.gz: 9d5506c2fb6b8dfe7b3ec64538c8cdee291e77be03305d017010222e1515305d2d1bad5a44289574c7fd6fb94ba0182ecd0bf001c4e1d91854a875dee4b3d4a0
|
data/Gemfile.lock
CHANGED
@@ -2,27 +2,49 @@ class CAAnimation
|
|
2
2
|
|
3
3
|
class << self
|
4
4
|
|
5
|
-
def
|
5
|
+
private def _sugarcube_apply_animation_options(animation, options)
|
6
|
+
animation.duration = options[:duration] if options.key?(:duration)
|
7
|
+
animation.delegate = options[:delegate] if options.key?(:delegate)
|
8
|
+
animation.speed = options[:speed] if options.key?(:speed)
|
9
|
+
animation.repeatCount = options[:repeat] if options.key?(:repeat)
|
10
|
+
animation.repeatCount = options[:repeat_count] if options.key?(:repeat_count)
|
11
|
+
animation.repeatDuration = options[:repeat_duration] if options.key?(:repeat_duration)
|
12
|
+
animation.removedOnCompletion = options.fetch(:remove, true)
|
13
|
+
end
|
14
|
+
|
15
|
+
# If you pass a block, that block will be called at the end of the
|
16
|
+
# animation.
|
17
|
+
def basic(key_path, options={}, &block)
|
6
18
|
animation = CABasicAnimation.animationWithKeyPath(key_path)
|
7
|
-
animation
|
8
|
-
animation.delegate = options[:delegate] if options[:delegate]
|
19
|
+
_sugarcube_apply_animation_options(animation, options)
|
9
20
|
|
10
21
|
if options.key?(:from) || options.key?(:to) || options.key?(:by)
|
11
|
-
|
22
|
+
animation.fromValue = options[:from] if options.key?(:from)
|
23
|
+
animation.toValue = options[:to] if options.key?(:to)
|
24
|
+
animation.byValue = options[:by] if options.key?(:by)
|
25
|
+
end
|
12
26
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
27
|
+
return animation
|
28
|
+
end
|
29
|
+
|
30
|
+
def keyframe(key_path, options={}, &block)
|
31
|
+
timing_function = options.fetch(:timing, KCAMediaTimingFunctionDefault)
|
32
|
+
if timing_function.is_a?(NSString)
|
33
|
+
timing_function = CAMediaTimingFunction.functionWithName(timing_function)
|
18
34
|
end
|
35
|
+
fill_mode = options.fetch(:fill_mode, KCAFillModeForwards)
|
36
|
+
|
37
|
+
animation = CAKeyframeAnimation.animationWithKeyPath(key_path)
|
38
|
+
_sugarcube_apply_animation_options(animation, options)
|
39
|
+
animation.timingFunction = timing_function
|
40
|
+
animation.fillMode = fill_mode
|
19
41
|
|
20
|
-
if
|
21
|
-
|
22
|
-
|
42
|
+
if options.key?(:values)
|
43
|
+
animation.values = options[:values]
|
44
|
+
elsif options.key?(:path)
|
45
|
+
animation.path = options[:path]
|
23
46
|
end
|
24
47
|
|
25
|
-
block.call(animation) if block
|
26
48
|
return animation
|
27
49
|
end
|
28
50
|
|
@@ -1,7 +1,44 @@
|
|
1
1
|
class CALayer
|
2
2
|
|
3
3
|
def basic_animation(key_path, options={})
|
4
|
-
CAAnimation.basic(
|
4
|
+
animation = CAAnimation.basic(key_path, options)
|
5
|
+
|
6
|
+
should_add = options.fetch(:add, true)
|
7
|
+
if should_add
|
8
|
+
if should_add.is_a?(NSString)
|
9
|
+
name = should_add
|
10
|
+
else
|
11
|
+
name = key_path
|
12
|
+
end
|
13
|
+
|
14
|
+
self.addAnimation(animation, forKey: name)
|
15
|
+
end
|
16
|
+
|
17
|
+
if options.key?(:to)
|
18
|
+
self.setValue(options[:to], forKeyPath: key_path)
|
19
|
+
end
|
20
|
+
|
21
|
+
return animation
|
22
|
+
end
|
23
|
+
|
24
|
+
def keyframe_animation(key_path, options={})
|
25
|
+
animation = CAAnimation.keyframe(key_path, options)
|
26
|
+
|
27
|
+
should_add = options.fetch(:add, true)
|
28
|
+
if should_add
|
29
|
+
if should_add.is_a?(NSString)
|
30
|
+
name = should_add
|
31
|
+
else
|
32
|
+
name = key_path
|
33
|
+
end
|
34
|
+
self.addAnimation(animation, forKey: name)
|
35
|
+
end
|
36
|
+
|
37
|
+
if options.key?(:values)
|
38
|
+
self.setValue(options[:values].last, forKeyPath: key_path)
|
39
|
+
end
|
40
|
+
|
41
|
+
return animation
|
5
42
|
end
|
6
43
|
|
7
44
|
end
|
@@ -2,6 +2,22 @@ class UIView
|
|
2
2
|
|
3
3
|
class << self
|
4
4
|
|
5
|
+
# This is an internal helper method to determine the animation options.
|
6
|
+
def sugarcube_animation_options(options)
|
7
|
+
animation_options = options[:options]
|
8
|
+
animation_options = animation_options.uianimationoption if animation_options.respond_to?(:uianimationoption)
|
9
|
+
unless animation_options
|
10
|
+
curve = options.fetch(:curve, UIViewAnimationOptionCurveEaseInOut)
|
11
|
+
curve = curve.uianimationoption if curve.respond_to?(:uianimationoption)
|
12
|
+
|
13
|
+
from_current = options.fetch(:from_current, true) ? UIViewAnimationOptionBeginFromCurrentState : 0
|
14
|
+
allow_interaction = options.fetch(:allow_interaction, false) ? UIViewAnimationOptionAllowUserInteraction : 0
|
15
|
+
|
16
|
+
animation_options = curve | from_current | allow_interaction
|
17
|
+
end
|
18
|
+
return animation_options
|
19
|
+
end
|
20
|
+
|
5
21
|
# If options is a Numeric, it is used as the duration. Otherwise, duration
|
6
22
|
# is an option, and defaults to 0.3. All the transition methods work this
|
7
23
|
# way.
|
@@ -10,10 +26,10 @@ class UIView
|
|
10
26
|
# @option options [Float] :damping Enables the "spring" animation. Value of 1.0 is a stiff spring.
|
11
27
|
# @option options [Float] :velocity Used in a spring animation to set the initial velocity
|
12
28
|
# @option options [Proc] :after A block that is executed when the animation is complete, useful for chaining (though the `animation_chain` method is better!)
|
13
|
-
# @option options [Fixnum] :options The options parameter that is passed to the UIView.animateWithDuration(...) method. You can also use the more
|
14
|
-
# @option options [Fixnum] :curve The animation curve option. default:
|
15
|
-
# @option options [Boolean] :from_current Whether or not to have animations start from their current position (aka UIViewAnimationOptionBeginFromCurrentState)
|
16
|
-
# @option options [Boolean] :allow_interaction aka UIViewAnimationOptionAllowUserInteraction
|
29
|
+
# @option options [Fixnum,Symbol] :options The options parameter that is passed to the UIView.animateWithDuration(...) method. You can also use the more intuitive options `:curve`, `:from_current`, and `:allow_interaction`. `uianimationcurve` symbols (e.g. :ease_in_out) are converted to Fixnum.
|
30
|
+
# @option options [Fixnum,Symbol] :curve The animation curve option. `uianimationcurve` symbols (e.g. :ease_in_out) are converted to Fixnum. default: UIViewAnimationOptionCurveEaseInOut
|
31
|
+
# @option options [Boolean] :from_current Whether or not to have animations start from their current position. default: true (aka UIViewAnimationOptionBeginFromCurrentState)
|
32
|
+
# @option options [Boolean] :allow_interaction default: false (aka UIViewAnimationOptionAllowUserInteraction)
|
17
33
|
def animate(options={}, more_options={}, &animations)
|
18
34
|
raise "animation block is required" unless animations
|
19
35
|
|
@@ -48,16 +64,7 @@ class UIView
|
|
48
64
|
after_adjusted = nil
|
49
65
|
end
|
50
66
|
|
51
|
-
animation_options = options
|
52
|
-
unless animation_options
|
53
|
-
curve = options.fetch(:curve, UIViewAnimationOptionCurveEaseInOut)
|
54
|
-
curve = curve.uianimationcurve if curve.is_a?(Symbol)
|
55
|
-
|
56
|
-
from_current = options.fetch(:from_current, true) ? UIViewAnimationOptionBeginFromCurrentState : 0
|
57
|
-
allow_interaction = options.fetch(:allow_interaction, false) ? UIViewAnimationOptionAllowUserInteraction : 0
|
58
|
-
|
59
|
-
animation_options = curve | from_current
|
60
|
-
end
|
67
|
+
animation_options = sugarcube_animation_options(options)
|
61
68
|
|
62
69
|
if duration == 0 && delay == 0
|
63
70
|
animations.call
|
@@ -443,7 +450,10 @@ class UIView
|
|
443
450
|
end
|
444
451
|
|
445
452
|
options[:duration] ||= default_duration
|
446
|
-
options
|
453
|
+
unless options.key?(:options) || options.key?(:curve)
|
454
|
+
options[:options] = UIView.sugarcube_animation_options(curve: UIViewAnimationOptionCurveEaseIn)
|
455
|
+
end
|
456
|
+
|
447
457
|
reset_transform = self.transform
|
448
458
|
reset_after = ->(finished) do
|
449
459
|
self.transform = reset_transform
|
@@ -504,7 +514,9 @@ class UIView
|
|
504
514
|
reset_center = self.center
|
505
515
|
|
506
516
|
options[:duration] ||= default_duration
|
507
|
-
options
|
517
|
+
unless options.key?(:options) || options.key?(:curve)
|
518
|
+
options[:options] = UIView.sugarcube_animation_options(curve: UIViewAnimationOptionCurveEaseOut)
|
519
|
+
end
|
508
520
|
options[:after] = after
|
509
521
|
|
510
522
|
window = UIApplication.sharedApplication.windows[0]
|
@@ -6,7 +6,7 @@ class Fixnum
|
|
6
6
|
# UIColor.colorWithRed(1.0, green:1.0, blue: 1.0, alpha:1.0)
|
7
7
|
# UIColor.colorWithRed(1.0, green:1.0, blue: 1.0, alpha:0.33)
|
8
8
|
def uicolor(alpha=nil)
|
9
|
-
alpha
|
9
|
+
alpha ||= 1.0
|
10
10
|
|
11
11
|
red = ((self & 0xFF0000) >> 16).to_f / 255.0
|
12
12
|
green = ((self & 0xFF00) >> 8).to_f / 255.0
|
@@ -15,4 +15,8 @@ class Fixnum
|
|
15
15
|
UIColor.colorWithRed(red, green:green, blue:blue, alpha:alpha.to_f)
|
16
16
|
end
|
17
17
|
|
18
|
+
def cgcolor(alpha=nil)
|
19
|
+
self.uicolor(alpha).CGColor
|
20
|
+
end
|
21
|
+
|
18
22
|
end
|
@@ -1,14 +1,20 @@
|
|
1
1
|
class NSArray
|
2
2
|
|
3
3
|
# [160, 210, 242].uicolor => 0xA0D2F2.uicolor
|
4
|
-
|
4
|
+
# [160, 210, 242, 0.5].uicolor => 0xA0D2F2.uicolor(0.5)
|
5
|
+
def uicolor(alpha=nil)
|
5
6
|
red = self[0] / 255.0
|
6
7
|
green = self[1] / 255.0
|
7
8
|
blue = self[2] / 255.0
|
8
9
|
if self[3]
|
9
10
|
alpha = self[3]
|
10
11
|
end
|
11
|
-
|
12
|
+
alpha ||= 1.0
|
13
|
+
UIColor.colorWithRed(red, green: green, blue: blue, alpha: alpha.to_f)
|
14
|
+
end
|
15
|
+
|
16
|
+
def cgcolor(alpha=nil)
|
17
|
+
self.uicolor(alpha).CGColor
|
12
18
|
end
|
13
19
|
|
14
20
|
end
|
@@ -3,11 +3,15 @@ class UIImage
|
|
3
3
|
# @return [UIColor]
|
4
4
|
def uicolor(alpha=nil)
|
5
5
|
color = UIColor.colorWithPatternImage(self)
|
6
|
-
if
|
6
|
+
if alpha
|
7
7
|
color = color.colorWithAlphaComponent(alpha.to_f)
|
8
8
|
end
|
9
9
|
|
10
10
|
color
|
11
11
|
end
|
12
12
|
|
13
|
+
def cgcolor(alpha=nil)
|
14
|
+
self.uicolor(alpha).CGColor
|
15
|
+
end
|
16
|
+
|
13
17
|
end
|
@@ -149,6 +149,11 @@ class Symbol
|
|
149
149
|
end
|
150
150
|
alias uiviewanimationcurve uianimationcurve
|
151
151
|
|
152
|
+
def uianimationoption
|
153
|
+
SugarCube.look_in(self, Symbol.uianimationoption)
|
154
|
+
end
|
155
|
+
alias uiviewanimationoption uianimationoption
|
156
|
+
|
152
157
|
def uitablestyle
|
153
158
|
SugarCube.look_in(self, Symbol.uitablestyle)
|
154
159
|
end
|
@@ -271,6 +276,7 @@ class Symbol
|
|
271
276
|
attr :uicontentmode
|
272
277
|
attr :uicontentmode__deprecated
|
273
278
|
attr :uianimationcurve
|
279
|
+
attr :uianimationoption
|
274
280
|
|
275
281
|
attr :uitablestyle
|
276
282
|
attr :uitablerowanimation
|
@@ -657,6 +663,35 @@ class Symbol
|
|
657
663
|
linear: UIViewAnimationCurveLinear
|
658
664
|
}
|
659
665
|
|
666
|
+
@uianimationoption = {
|
667
|
+
layout_subviews: UIViewAnimationOptionLayoutSubviews,
|
668
|
+
allow_user_interaction: UIViewAnimationOptionAllowUserInteraction,
|
669
|
+
begin_from_current_state: UIViewAnimationOptionBeginFromCurrentState,
|
670
|
+
repeat: UIViewAnimationOptionRepeat,
|
671
|
+
autoreverse: UIViewAnimationOptionAutoreverse,
|
672
|
+
override_inherited_duration: UIViewAnimationOptionOverrideInheritedDuration,
|
673
|
+
override_inherited_curve: UIViewAnimationOptionOverrideInheritedCurve,
|
674
|
+
allow_animated_content: UIViewAnimationOptionAllowAnimatedContent,
|
675
|
+
show_hide_transition_views: UIViewAnimationOptionShowHideTransitionViews,
|
676
|
+
override_inherited_options: UIViewAnimationOptionOverrideInheritedOptions,
|
677
|
+
curve_ease_in_out: UIViewAnimationOptionCurveEaseInOut,
|
678
|
+
ease_in_out: UIViewAnimationOptionCurveEaseInOut,
|
679
|
+
curve_ease_in: UIViewAnimationOptionCurveEaseIn,
|
680
|
+
ease_in: UIViewAnimationOptionCurveEaseIn,
|
681
|
+
curve_ease_out: UIViewAnimationOptionCurveEaseOut,
|
682
|
+
ease_out: UIViewAnimationOptionCurveEaseOut,
|
683
|
+
curve_linear: UIViewAnimationOptionCurveLinear,
|
684
|
+
linear: UIViewAnimationOptionCurveLinear,
|
685
|
+
transition_none: UIViewAnimationOptionTransitionNone,
|
686
|
+
transition_flip_from_left: UIViewAnimationOptionTransitionFlipFromLeft,
|
687
|
+
transition_flip_from_right: UIViewAnimationOptionTransitionFlipFromRight,
|
688
|
+
transition_curl_up: UIViewAnimationOptionTransitionCurlUp,
|
689
|
+
transition_curl_down: UIViewAnimationOptionTransitionCurlDown,
|
690
|
+
transition_cross_dissolve: UIViewAnimationOptionTransitionCrossDissolve,
|
691
|
+
transition_flip_from_top: UIViewAnimationOptionTransitionFlipFromTop,
|
692
|
+
transition_flip_from_bottom: UIViewAnimationOptionTransitionFlipFromBottom,
|
693
|
+
}
|
694
|
+
|
660
695
|
@uitablestyle = {
|
661
696
|
plain: UITableViewStylePlain,
|
662
697
|
grouped: UITableViewStyleGrouped,
|
@@ -17,7 +17,7 @@ class UIActionSheet
|
|
17
17
|
# # use one handler for all buttons
|
18
18
|
# UIActionSheet.alert("title", buttons: [...]) { |button| }
|
19
19
|
def self.alert(title, options={}, &block)
|
20
|
-
if title.is_a?(
|
20
|
+
if title.is_a?(NSDictionary)
|
21
21
|
options = title
|
22
22
|
title = options[:title]
|
23
23
|
end
|
@@ -49,9 +49,14 @@ class UIActionSheet
|
|
49
49
|
raise 'If you only have one button, use a :success handler, not :cancel or :destructive'
|
50
50
|
end
|
51
51
|
|
52
|
+
# the button titles, mapped to how UIActionSheet orders them. These are
|
53
|
+
# passed to the success handler.
|
54
|
+
buttons_mapped = {}
|
55
|
+
|
52
56
|
# cancelButtonTitle:destructiveButtonTitle:otherButtonTitles:
|
53
57
|
# uses localized buttons in the actual alert
|
54
|
-
if buttons.is_a?(
|
58
|
+
if buttons.is_a?(NSDictionary)
|
59
|
+
button_titles = buttons.keys
|
55
60
|
if buttons.key?(:cancel)
|
56
61
|
args << (buttons[:cancel] && buttons[:cancel].localized)
|
57
62
|
else
|
@@ -64,19 +69,11 @@ class UIActionSheet
|
|
64
69
|
end
|
65
70
|
args.concat(buttons.select { |k, m| k != :cancel && k != :destructive }.map { |k, m| m && m.localized })
|
66
71
|
else
|
72
|
+
button_titles = buttons
|
67
73
|
args.concat(buttons.map { |m| m && m.localized })
|
68
74
|
end
|
69
75
|
args << nil # otherButtonTitles:..., nil
|
70
76
|
|
71
|
-
# the button titles, mapped to how UIActionSheet orders them. These are
|
72
|
-
# passed to the success handler.
|
73
|
-
buttons_mapped = {}
|
74
|
-
if buttons.is_a?(Hash)
|
75
|
-
button_titles = buttons.keys
|
76
|
-
else
|
77
|
-
button_titles = buttons
|
78
|
-
end
|
79
|
-
|
80
77
|
if args[2] && args[3] # cancel && destructive buttons
|
81
78
|
buttons_mapped[0] = button_titles[1] # destructiveIndex == 0, button == 1
|
82
79
|
buttons_mapped[button_titles.length - 1] = button_titles[0] # cancelIndex == last, button == 0
|
@@ -19,7 +19,7 @@ class UIAlertView
|
|
19
19
|
# success: proc{ |pressed| puts "pressed: #{pressed.inspect}" },
|
20
20
|
# ) # pressed will be :ok or :no_way
|
21
21
|
def self.alert(title, options={}, more_options={}, &block)
|
22
|
-
if title.is_a?(
|
22
|
+
if title.is_a?(NSDictionary)
|
23
23
|
options = title
|
24
24
|
title = options[:title]
|
25
25
|
message = options[:message]
|
@@ -59,22 +59,13 @@ class UIAlertView
|
|
59
59
|
elsif options[:success]
|
60
60
|
buttons << "OK"
|
61
61
|
end
|
62
|
-
elsif buttons.is_a?(Hash)
|
63
|
-
|
64
62
|
elsif buttons.length == 1 && options[:cancel]
|
65
63
|
raise "If you only have one button, use a :success handler, not :cancel (and definitely not BOTH)"
|
66
64
|
end
|
67
65
|
|
68
|
-
# the button titles. These are passed to the success handler.
|
69
|
-
if buttons.is_a?(Hash)
|
70
|
-
button_titles = buttons.keys
|
71
|
-
else
|
72
|
-
button_titles = buttons
|
73
|
-
end
|
74
|
-
delegate.buttons = button_titles
|
75
|
-
|
76
66
|
# uses localized buttons in the actual alert
|
77
|
-
if buttons.is_a?(
|
67
|
+
if buttons.is_a?(NSDictionary)
|
68
|
+
button_titles = buttons.keys
|
78
69
|
if buttons.key?(:cancel)
|
79
70
|
args << (buttons[:cancel] && buttons[:cancel].localized)
|
80
71
|
else
|
@@ -82,8 +73,10 @@ class UIAlertView
|
|
82
73
|
end
|
83
74
|
args.concat(buttons.select { |k, m| k != :cancel }.map { |k, m| m && m.localized })
|
84
75
|
else
|
76
|
+
button_titles = buttons
|
85
77
|
args.concat(buttons.map { |m| m && m.localized })
|
86
78
|
end
|
79
|
+
delegate.buttons = button_titles
|
87
80
|
args << nil # otherButtonTitles:..., nil
|
88
81
|
|
89
82
|
alert = self.alloc
|
@@ -51,15 +51,19 @@ class NSDate
|
|
51
51
|
# and
|
52
52
|
# <http://www.unicode.org/reports/tr35/tr35-19.html#Date_Field_Symbol_Table>
|
53
53
|
# for more information about date format strings.
|
54
|
-
def string_with_format(format)
|
54
|
+
def string_with_format(format, options={})
|
55
|
+
locale = options[:locale] || NSLocale.currentLocale
|
56
|
+
timezone = options[:timezone] || NSTimeZone.defaultTimeZone
|
57
|
+
|
55
58
|
if format.is_a?(Symbol)
|
56
59
|
formatters = SugarCubeFormats[format]
|
57
60
|
raise "No format found for #{format.inspect}" unless formatters
|
61
|
+
locale = NSLocale.localeWithLocaleIdentifier "en_US"
|
58
62
|
retval = ''
|
59
63
|
formatters.each do |formatter|
|
60
64
|
case formatter
|
61
65
|
when Symbol
|
62
|
-
retval << string_with_format(formatter.to_s)
|
66
|
+
retval << string_with_format(formatter.to_s, locale:locale, timezone:timezone)
|
63
67
|
when String
|
64
68
|
retval << formatter
|
65
69
|
end
|
@@ -67,9 +71,10 @@ class NSDate
|
|
67
71
|
return retval
|
68
72
|
else
|
69
73
|
format_template = NSDateFormatter.dateFormatFromTemplate(format, options:0,
|
70
|
-
locale:
|
74
|
+
locale:locale)
|
71
75
|
date_formatter = NSDateFormatter.new
|
72
76
|
date_formatter.setDateFormat(format_template)
|
77
|
+
date_formatter.setTimeZone(timezone)
|
73
78
|
return date_formatter.stringFromDate(self)
|
74
79
|
end
|
75
80
|
end
|
File without changes
|
data/lib/sugarcube/version.rb
CHANGED
@@ -0,0 +1,73 @@
|
|
1
|
+
describe CAAnimation do
|
2
|
+
|
3
|
+
describe "should have `basic` animation" do
|
4
|
+
|
5
|
+
it "should accept keypath" do
|
6
|
+
animation = CAAnimation.basic('opacity')
|
7
|
+
animation.keyPath.should == 'opacity'
|
8
|
+
end
|
9
|
+
|
10
|
+
it "should assign :to value" do
|
11
|
+
animation = CAAnimation.basic('opacity', to: 0)
|
12
|
+
animation.toValue.should == 0
|
13
|
+
end
|
14
|
+
|
15
|
+
it "should assign :from value" do
|
16
|
+
animation = CAAnimation.basic('opacity', from: 1)
|
17
|
+
animation.fromValue.should == 1
|
18
|
+
end
|
19
|
+
|
20
|
+
it "should assign :by value" do
|
21
|
+
animation = CAAnimation.basic('opacity', by: -1)
|
22
|
+
animation.byValue.should == -1
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
describe "should have `keyframe` animation" do
|
28
|
+
|
29
|
+
it "should accept keypath" do
|
30
|
+
animation = CAAnimation.keyframe('opacity')
|
31
|
+
animation.keyPath.should == 'opacity'
|
32
|
+
end
|
33
|
+
|
34
|
+
it "should assign :values" do
|
35
|
+
animation = CAAnimation.keyframe('opacity', values: [0, 0.5, 1])
|
36
|
+
animation.values.should == [0, 0.5, 1]
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should assign :timing value" do
|
40
|
+
animation = CAAnimation.keyframe('opacity', timing: KCAMediaTimingFunctionLinear)
|
41
|
+
animation.timingFunction.should == CAMediaTimingFunction.functionWithName(KCAMediaTimingFunctionLinear)
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
describe "should have `CALayer#basic_animation` helper" do
|
47
|
+
|
48
|
+
it 'should create and add an animation' do
|
49
|
+
layer = CALayer.layer
|
50
|
+
animation = layer.basic_animation('opacity', to: 1, add: 'spec')
|
51
|
+
layer.animationForKey('spec').should.not == nil
|
52
|
+
# cannot compare animations because addAnimation creates a copy of the CAAnimation
|
53
|
+
# don't do this:
|
54
|
+
# layer.animationForKey('spec').should == animation
|
55
|
+
layer.animationForKey('spec').keyPath.should == 'opacity'
|
56
|
+
layer.animationForKey('spec').toValue.should == 1
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
|
61
|
+
describe "should have `CALayer#keyframe_animation` helper" do
|
62
|
+
|
63
|
+
it 'should create and add an animation' do
|
64
|
+
layer = CALayer.layer
|
65
|
+
animation = layer.keyframe_animation('opacity', values: [0, 1], add: 'spec')
|
66
|
+
layer.animationForKey('spec').should.not == nil
|
67
|
+
layer.animationForKey('spec').keyPath.should == 'opacity'
|
68
|
+
layer.animationForKey('spec').values.should == [0, 1]
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
data/spec/calayer_spec.rb
CHANGED
data/spec/color_spec.rb
CHANGED
@@ -1,9 +1,15 @@
|
|
1
|
-
describe
|
1
|
+
describe UIColor do
|
2
2
|
|
3
3
|
it "should have a #uicolor method" do
|
4
4
|
UIColor.redColor.uicolor.should == UIColor.redColor
|
5
5
|
end
|
6
6
|
|
7
|
+
it "should have a #cgcolor method" do
|
8
|
+
-> do
|
9
|
+
UIColor.redColor.cgcolor.should == UIColor.redColor.CGColor
|
10
|
+
end.should.not.raise
|
11
|
+
end
|
12
|
+
|
7
13
|
it "should have a #uicolor(alpha) method" do
|
8
14
|
UIColor.redColor.uicolor(0.5).alpha.should == 0.5
|
9
15
|
end
|
@@ -76,23 +82,23 @@ describe 'UIColor' do
|
|
76
82
|
end
|
77
83
|
|
78
84
|
it "should have a #invert method" do
|
79
|
-
|
80
|
-
|
81
|
-
|
85
|
+
UIColor.redColor.invert.should == UIColor.cyanColor
|
86
|
+
UIColor.greenColor.invert.should == UIColor.magentaColor
|
87
|
+
UIColor.blueColor.invert.should == UIColor.yellowColor
|
82
88
|
|
83
|
-
|
84
|
-
|
85
|
-
|
89
|
+
UIColor.whiteColor.invert.red.should == 0
|
90
|
+
UIColor.whiteColor.invert.green.should == 0
|
91
|
+
UIColor.whiteColor.invert.blue.should == 0
|
86
92
|
|
87
|
-
|
88
|
-
|
89
|
-
|
93
|
+
UIColor.blackColor.invert.red.should == 1
|
94
|
+
UIColor.blackColor.invert.green.should == 1
|
95
|
+
UIColor.blackColor.invert.blue.should == 1
|
90
96
|
end
|
91
97
|
|
92
98
|
it "should have a #mix_with method" do
|
93
|
-
white =
|
94
|
-
black =
|
95
|
-
gray =
|
99
|
+
white = UIColor.whiteColor
|
100
|
+
black = UIColor.blackColor
|
101
|
+
gray = UIColor.grayColor
|
96
102
|
white.mix_with(black, 0).red.should == 1
|
97
103
|
white.mix_with(black, 0).green.should == 1
|
98
104
|
white.mix_with(black, 0).blue.should == 1
|
@@ -115,3 +121,117 @@ describe 'UIColor' do
|
|
115
121
|
end
|
116
122
|
|
117
123
|
end
|
124
|
+
|
125
|
+
|
126
|
+
describe 'Fixnum UIColor extensions' do
|
127
|
+
it "should have a 0xffffff#uicolor method" do
|
128
|
+
color = 0xffffff.uicolor
|
129
|
+
color.red.should == 1
|
130
|
+
color.green.should == 1
|
131
|
+
color.blue.should == 1
|
132
|
+
color.alpha.should == 1
|
133
|
+
end
|
134
|
+
|
135
|
+
it "should have a 0xffffff#cgcolor method" do
|
136
|
+
-> do
|
137
|
+
0xffffff.cgcolor.should.not == nil
|
138
|
+
end.should.not.raise
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should have a 0x000000#uicolor(0.5) method" do
|
142
|
+
color = 0.uicolor(0.5)
|
143
|
+
color.red.should == 0
|
144
|
+
color.green.should == 0
|
145
|
+
color.blue.should == 0
|
146
|
+
color.alpha.should == 0.5
|
147
|
+
end
|
148
|
+
end
|
149
|
+
|
150
|
+
|
151
|
+
describe 'NSArray UIColor extensions' do
|
152
|
+
it "should have a [255, 255, 255]#uicolor method" do
|
153
|
+
color = [255, 255, 255].uicolor
|
154
|
+
color.red.should == 1
|
155
|
+
color.green.should == 1
|
156
|
+
color.blue.should == 1
|
157
|
+
color.alpha.should == 1
|
158
|
+
end
|
159
|
+
|
160
|
+
it "should have a [255, 255, 255]#cgcolor method" do
|
161
|
+
-> do
|
162
|
+
[255, 255, 255].cgcolor.should.not == nil
|
163
|
+
end.should.not.raise
|
164
|
+
end
|
165
|
+
|
166
|
+
it "should have a [0, 0, 0]#uicolor(0.5) method" do
|
167
|
+
color = [0, 0, 0].uicolor(0.5)
|
168
|
+
color.red.should == 0
|
169
|
+
color.green.should == 0
|
170
|
+
color.blue.should == 0
|
171
|
+
color.alpha.should == 0.5
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
|
176
|
+
describe 'NSString UIColor extensions' do
|
177
|
+
it "should have '#ffffff'.uicolor method" do
|
178
|
+
color = '#ffffff'.uicolor
|
179
|
+
color.should.be.kind_of(UIColor)
|
180
|
+
color.red.should == 1.0
|
181
|
+
color.green.should == 1.0
|
182
|
+
color.blue.should == 1.0
|
183
|
+
|
184
|
+
color = '#808080'.uicolor
|
185
|
+
color.should.be.kind_of(UIColor)
|
186
|
+
((color.red * 2).round / 2.0).should == 0.5
|
187
|
+
((color.green * 2).round / 2.0).should == 0.5
|
188
|
+
((color.blue * 2).round / 2.0).should == 0.5
|
189
|
+
end
|
190
|
+
|
191
|
+
it "should have '#ffffff'.cgcolor method" do
|
192
|
+
-> do
|
193
|
+
'#ffffff'.cgcolor.should.not == nil
|
194
|
+
end.should.not.raise
|
195
|
+
end
|
196
|
+
|
197
|
+
it "should have '#000000'.uicolor(0.5) method" do
|
198
|
+
color = '#000000'.uicolor(0.5)
|
199
|
+
color.should.be.kind_of(UIColor)
|
200
|
+
color.red.should == 0
|
201
|
+
color.green.should == 0
|
202
|
+
color.blue.should == 0
|
203
|
+
color.alpha.should == 0.5
|
204
|
+
end
|
205
|
+
|
206
|
+
it "that supports image names" do
|
207
|
+
'little_square'.uicolor.should == 'little_square'.uiimage.uicolor
|
208
|
+
end
|
209
|
+
|
210
|
+
it "that supports non-existant image names" do
|
211
|
+
'this is not my beautiful house!'.uicolor.should == nil
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
|
216
|
+
describe 'UIImage UIColor extensions' do
|
217
|
+
it 'should support #uicolor' do
|
218
|
+
color = UIImage.imageNamed('little_square').uicolor
|
219
|
+
color.should.be.kind_of(UIColor)
|
220
|
+
end
|
221
|
+
|
222
|
+
it 'should support #cgcolor' do
|
223
|
+
-> do
|
224
|
+
UIImage.imageNamed('little_square').cgcolor
|
225
|
+
end.should.not.raise
|
226
|
+
end
|
227
|
+
|
228
|
+
it 'should support #uicolor(0.5)' do
|
229
|
+
-> do
|
230
|
+
UIImage.imageNamed('little_square').uicolor(0.5)
|
231
|
+
# unfortunately, this doesn't work:
|
232
|
+
# image.alpha.should == 0.5 # alpha returns 0 because this is not an RGB or HSB color
|
233
|
+
end.should.not.raise
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
|
data/spec/fixnum_spec.rb
CHANGED
@@ -1,21 +1,5 @@
|
|
1
1
|
describe "Fixnum" do
|
2
2
|
|
3
|
-
it "should have a 0xffffff#uicolor method" do
|
4
|
-
color = 0xffffff.uicolor
|
5
|
-
color.red.should == 1
|
6
|
-
color.green.should == 1
|
7
|
-
color.blue.should == 1
|
8
|
-
color.alpha.should == 1
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should have a 0x000000#uicolor(0.5) method" do
|
12
|
-
color = 0.uicolor(0.5)
|
13
|
-
color.red.should == 0
|
14
|
-
color.green.should == 0
|
15
|
-
color.blue.should == 0
|
16
|
-
color.alpha.should == 0.5
|
17
|
-
end
|
18
|
-
|
19
3
|
it "should have a #nth method" do
|
20
4
|
{
|
21
5
|
0 => 'th',
|
data/spec/nsarray_spec.rb
CHANGED
@@ -27,22 +27,6 @@ describe "NSArray" do
|
|
27
27
|
set.containsIndex(4).should == false
|
28
28
|
end
|
29
29
|
|
30
|
-
it "should have a [255,255,255]#uicolor method" do
|
31
|
-
color = [255,255,255].uicolor
|
32
|
-
color.red.should == 1
|
33
|
-
color.green.should == 1
|
34
|
-
color.blue.should == 1
|
35
|
-
color.alpha.should == 1
|
36
|
-
end
|
37
|
-
|
38
|
-
it "should have a [0, 0, 0]#uicolor(0.5) method" do
|
39
|
-
color = [0, 0, 0].uicolor(0.5)
|
40
|
-
color.red.should == 0
|
41
|
-
color.green.should == 0
|
42
|
-
color.blue.should == 0
|
43
|
-
color.alpha.should == 0.5
|
44
|
-
end
|
45
|
-
|
46
30
|
it "should have a method #nsset" do
|
47
31
|
set = [0,1,0].nsset
|
48
32
|
set.count.should == 2
|
data/spec/nsdate_spec.rb
CHANGED
@@ -101,6 +101,19 @@ describe "NSDate" do
|
|
101
101
|
@date.string_with_format(:iso8601).should == '2013-01-02 12:15:30.000'
|
102
102
|
end
|
103
103
|
|
104
|
+
it "should have an NSDate#string_with_format method (:iso8601) and timezone" do
|
105
|
+
date = @date + @date.utc_offset
|
106
|
+
date.string_with_format(:iso8601, timezone:"UTC".nstimezone).should == '2013-01-02 12:15:30.000'
|
107
|
+
end
|
108
|
+
|
109
|
+
it "should have an NSDate#string_with_format method (:ymd)" do
|
110
|
+
@date.string_with_format(:ymd).should == '2013-01-02'
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should have an NSDate#string_with_format method (:hms)" do
|
114
|
+
@date.string_with_format(:hms).should == '12:15:30.000'
|
115
|
+
end
|
116
|
+
|
104
117
|
it "should have an NSDate#timezone method" do
|
105
118
|
String.should === @date.timezone.name
|
106
119
|
end
|
data/spec/nsstring_spec.rb
CHANGED
@@ -34,30 +34,6 @@ describe "NSString" do
|
|
34
34
|
font.pointSize.should == UIFont.systemFontSize
|
35
35
|
end
|
36
36
|
|
37
|
-
describe "should have a #uicolor method" do
|
38
|
-
it "that supports hex" do
|
39
|
-
color = '#ffffff'.uicolor
|
40
|
-
UIColor.should === color
|
41
|
-
color.red.should == 1.0
|
42
|
-
color.green.should == 1.0
|
43
|
-
color.blue.should == 1.0
|
44
|
-
|
45
|
-
color = '#808080'.uicolor
|
46
|
-
UIColor.should === color
|
47
|
-
((color.red * 2).round / 2.0).should == 0.5
|
48
|
-
((color.green * 2).round / 2.0).should == 0.5
|
49
|
-
((color.blue * 2).round / 2.0).should == 0.5
|
50
|
-
end
|
51
|
-
|
52
|
-
it "that supports image names" do
|
53
|
-
'little_square'.uicolor.should == 'little_square'.uiimage.uicolor
|
54
|
-
end
|
55
|
-
|
56
|
-
it "that supports non-existant image names" do
|
57
|
-
'this is not my beautiful house!'.uicolor.should == nil
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
37
|
it "should have a #uilabel method" do
|
62
38
|
str = 'test'
|
63
39
|
str_size = str.sizeWithFont(UIFont.systemFontOfSize(UIFont.labelFontSize))
|
data/spec/pipes_spec.rb
CHANGED
@@ -10,27 +10,27 @@ describe "Pipes" do
|
|
10
10
|
end
|
11
11
|
|
12
12
|
it "should coerce into UIImage" do
|
13
|
-
(@image | UIImage).should.
|
13
|
+
(@image | UIImage).should.be.kind_of(UIImage)
|
14
14
|
end
|
15
15
|
|
16
16
|
it "should coerce into UIView" do
|
17
|
-
(@image | UIView).should.
|
17
|
+
(@image | UIView).should.be.kind_of(UIView)
|
18
18
|
end
|
19
19
|
|
20
20
|
it "should coerce into UIImageView" do
|
21
|
-
(@image | UIImageView).should.
|
21
|
+
(@image | UIImageView).should.be.kind_of(UIImageView)
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should coerce into CIImage" do
|
25
|
-
(@image | CIImage).should.
|
25
|
+
(@image | CIImage).should.be.kind_of(CIImage)
|
26
26
|
end
|
27
27
|
|
28
28
|
it "should coerce into UIColor" do
|
29
|
-
(@image | UIColor).should.
|
29
|
+
(@image | UIColor).should.be.kind_of(UIColor)
|
30
30
|
end
|
31
31
|
|
32
32
|
it "should coerce into NSData" do
|
33
|
-
(@image | NSData).should.
|
33
|
+
(@image | NSData).should.be.kind_of(NSData)
|
34
34
|
end
|
35
35
|
|
36
36
|
it "should not support arbitrary coercions" do
|
@@ -41,13 +41,13 @@ describe "Pipes" do
|
|
41
41
|
|
42
42
|
it "should apply CIFilter" do
|
43
43
|
filter = CIFilter.gaussian_blur
|
44
|
-
(@image | filter).should.
|
44
|
+
(@image | filter).should.be.kind_of(CIImage)
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should apply multiple CIFilters" do
|
48
48
|
filter1 = CIFilter.gaussian_blur(1)
|
49
49
|
filter2 = CIFilter.gaussian_blur(2)
|
50
|
-
(@image | filter1 | filter2).should.
|
50
|
+
(@image | filter1 | filter2).should.be.kind_of(CIImage)
|
51
51
|
end
|
52
52
|
|
53
53
|
end
|
@@ -58,7 +58,7 @@ describe "Pipes" do
|
|
58
58
|
end
|
59
59
|
|
60
60
|
it "should coerce into UIImage" do
|
61
|
-
(@view | UIImage).should.
|
61
|
+
(@view | UIImage).should.be.kind_of(UIImage)
|
62
62
|
end
|
63
63
|
|
64
64
|
it "should not support arbitrary coercions" do
|
@@ -75,19 +75,19 @@ describe "Pipes" do
|
|
75
75
|
end
|
76
76
|
|
77
77
|
it "should coerce into UIImage" do
|
78
|
-
(@image | UIImage).should.
|
78
|
+
(@image | UIImage).should.be.kind_of(UIImage)
|
79
79
|
end
|
80
80
|
|
81
81
|
it "should coerce into UIView" do
|
82
|
-
(@image | UIView).should.
|
82
|
+
(@image | UIView).should.be.kind_of(UIView)
|
83
83
|
end
|
84
84
|
|
85
85
|
it "should coerce into UIImageView" do
|
86
|
-
(@image | UIImageView).should.
|
86
|
+
(@image | UIImageView).should.be.kind_of(UIImageView)
|
87
87
|
end
|
88
88
|
|
89
89
|
it "should coerce into CIImage" do
|
90
|
-
(@image | CIImage).should.
|
90
|
+
(@image | CIImage).should.be.kind_of(CIImage)
|
91
91
|
end
|
92
92
|
|
93
93
|
it "should not support arbitrary coercions" do
|
@@ -98,13 +98,13 @@ describe "Pipes" do
|
|
98
98
|
|
99
99
|
it "should apply CIFilter" do
|
100
100
|
filter = CIFilter.gaussian_blur
|
101
|
-
(@image | filter).should.
|
101
|
+
(@image | filter).should.be.kind_of(CIImage)
|
102
102
|
end
|
103
103
|
|
104
104
|
it "should apply multiple CIFilters" do
|
105
105
|
filter1 = CIFilter.gaussian_blur(1)
|
106
106
|
filter2 = CIFilter.gaussian_blur(2)
|
107
|
-
(@image | filter1 | filter2).should.
|
107
|
+
(@image | filter1 | filter2).should.be.kind_of(CIImage)
|
108
108
|
end
|
109
109
|
|
110
110
|
end
|
@@ -310,6 +310,35 @@ describe "Symbol - constants" do
|
|
310
310
|
:linear.uianimationcurve.should == UIViewAnimationCurveLinear
|
311
311
|
end
|
312
312
|
|
313
|
+
it 'should support `uianimationoption`' do
|
314
|
+
:layout_subviews.uianimationoption.should == UIViewAnimationOptionLayoutSubviews
|
315
|
+
:allow_user_interaction.uianimationoption.should == UIViewAnimationOptionAllowUserInteraction
|
316
|
+
:begin_from_current_state.uianimationoption.should == UIViewAnimationOptionBeginFromCurrentState
|
317
|
+
:repeat.uianimationoption.should == UIViewAnimationOptionRepeat
|
318
|
+
:autoreverse.uianimationoption.should == UIViewAnimationOptionAutoreverse
|
319
|
+
:override_inherited_duration.uianimationoption.should == UIViewAnimationOptionOverrideInheritedDuration
|
320
|
+
:override_inherited_curve.uianimationoption.should == UIViewAnimationOptionOverrideInheritedCurve
|
321
|
+
:allow_animated_content.uianimationoption.should == UIViewAnimationOptionAllowAnimatedContent
|
322
|
+
:show_hide_transition_views.uianimationoption.should == UIViewAnimationOptionShowHideTransitionViews
|
323
|
+
:override_inherited_options.uianimationoption.should == UIViewAnimationOptionOverrideInheritedOptions
|
324
|
+
:curve_ease_in_out.uianimationoption.should == UIViewAnimationOptionCurveEaseInOut
|
325
|
+
:ease_in_out.uianimationoption.should == UIViewAnimationOptionCurveEaseInOut
|
326
|
+
:curve_ease_in.uianimationoption.should == UIViewAnimationOptionCurveEaseIn
|
327
|
+
:ease_in.uianimationoption.should == UIViewAnimationOptionCurveEaseIn
|
328
|
+
:curve_ease_out.uianimationoption.should == UIViewAnimationOptionCurveEaseOut
|
329
|
+
:ease_out.uianimationoption.should == UIViewAnimationOptionCurveEaseOut
|
330
|
+
:curve_linear.uianimationoption.should == UIViewAnimationOptionCurveLinear
|
331
|
+
:linear.uianimationoption.should == UIViewAnimationOptionCurveLinear
|
332
|
+
:transition_none.uianimationoption.should == UIViewAnimationOptionTransitionNone
|
333
|
+
:transition_flip_from_left.uianimationoption.should == UIViewAnimationOptionTransitionFlipFromLeft
|
334
|
+
:transition_flip_from_right.uianimationoption.should == UIViewAnimationOptionTransitionFlipFromRight
|
335
|
+
:transition_curl_up.uianimationoption.should == UIViewAnimationOptionTransitionCurlUp
|
336
|
+
:transition_curl_down.uianimationoption.should == UIViewAnimationOptionTransitionCurlDown
|
337
|
+
:transition_cross_dissolve.uianimationoption.should == UIViewAnimationOptionTransitionCrossDissolve
|
338
|
+
:transition_flip_from_top.uianimationoption.should == UIViewAnimationOptionTransitionFlipFromTop
|
339
|
+
:transition_flip_from_bottom.uianimationoption.should == UIViewAnimationOptionTransitionFlipFromBottom
|
340
|
+
end
|
341
|
+
|
313
342
|
it 'should support `uitablestyle`' do
|
314
343
|
:plain.uitablestyle.should == UITableViewStylePlain
|
315
344
|
:grouped.uitablestyle.should == UITableViewStyleGrouped
|
data/spec/symbol_uicolor_spec.rb
CHANGED
@@ -14,6 +14,12 @@ describe "Symbol uicolor" do
|
|
14
14
|
:black.uicolor.should.be.kind_of(UIColor)
|
15
15
|
end
|
16
16
|
|
17
|
+
it 'should have cgcolor method' do
|
18
|
+
-> do
|
19
|
+
:black.cgcolor.should.not == nil
|
20
|
+
end.should.not.raise
|
21
|
+
end
|
22
|
+
|
17
23
|
it 'should have blue color' do
|
18
24
|
@colors[:blue].should == :blueColor
|
19
25
|
:blue.uicolor.should.be.kind_of(UIColor)
|
@@ -109,4 +109,35 @@ describe "UIView animation methods" do
|
|
109
109
|
@after_called.should == true
|
110
110
|
end
|
111
111
|
|
112
|
+
it 'should have sugarcube_animation_options helper' do
|
113
|
+
UIView.sugarcube_animation_options({}).should == (UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionBeginFromCurrentState)
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'should handle accept :options' do
|
117
|
+
UIView.sugarcube_animation_options(options: UIViewAnimationOptionCurveLinear).should == UIViewAnimationOptionCurveLinear
|
118
|
+
UIView.sugarcube_animation_options(options: UIViewAnimationOptionCurveLinear | UIViewAnimationOptionCurveEaseInOut).should == UIViewAnimationOptionCurveLinear | UIViewAnimationOptionCurveEaseInOut
|
119
|
+
end
|
120
|
+
|
121
|
+
it 'should accept :curve' do
|
122
|
+
opts = UIView.sugarcube_animation_options(curve: UIViewAnimationOptionCurveLinear)
|
123
|
+
(opts & UIViewAnimationOptionCurveLinear).should == UIViewAnimationOptionCurveLinear
|
124
|
+
|
125
|
+
opts = UIView.sugarcube_animation_options(curve: :linear)
|
126
|
+
(opts & UIViewAnimationOptionCurveLinear).should == UIViewAnimationOptionCurveLinear
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'should accept :from_current' do
|
130
|
+
opts = UIView.sugarcube_animation_options(from_current: true)
|
131
|
+
(opts & UIViewAnimationOptionBeginFromCurrentState).should == UIViewAnimationOptionBeginFromCurrentState
|
132
|
+
opts = UIView.sugarcube_animation_options(from_current: false)
|
133
|
+
(opts & UIViewAnimationOptionBeginFromCurrentState).should == 0
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'should accept :allow_interaction' do
|
137
|
+
opts = UIView.sugarcube_animation_options(allow_interaction: true)
|
138
|
+
(opts & UIViewAnimationOptionAllowUserInteraction).should == UIViewAnimationOptionAllowUserInteraction
|
139
|
+
opts = UIView.sugarcube_animation_options(allow_interaction: false)
|
140
|
+
(opts & UIViewAnimationOptionAllowUserInteraction).should == 0
|
141
|
+
end
|
142
|
+
|
112
143
|
end
|
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: 1.
|
4
|
+
version: 1.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Colin T.A. Gray
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2014-04-
|
14
|
+
date: 2014-04-23 00:00:00.000000000 Z
|
15
15
|
dependencies: []
|
16
16
|
description: |
|
17
17
|
== Description
|
@@ -145,7 +145,7 @@ files:
|
|
145
145
|
- lib/sugarcube-pointer.rb
|
146
146
|
- lib/sugarcube-pointer/nsarray.rb
|
147
147
|
- lib/sugarcube-repl.rb
|
148
|
-
- lib/sugarcube-repl/
|
148
|
+
- lib/sugarcube-repl/kernel.rb
|
149
149
|
- lib/sugarcube-resources.rb
|
150
150
|
- lib/sugarcube-timer.rb
|
151
151
|
- lib/sugarcube-timer/timer.rb
|
@@ -198,6 +198,7 @@ files:
|
|
198
198
|
- spec/568_spec.rb
|
199
199
|
- spec/animation_chain_spec.rb
|
200
200
|
- spec/anonymous_spec.rb
|
201
|
+
- spec/caanimation_spec.rb
|
201
202
|
- spec/calayer_spec.rb
|
202
203
|
- spec/color_components_spec.rb
|
203
204
|
- spec/color_other_representations_spec.rb
|
@@ -268,7 +269,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
268
269
|
version: '0'
|
269
270
|
requirements: []
|
270
271
|
rubyforge_project:
|
271
|
-
rubygems_version: 2.0.
|
272
|
+
rubygems_version: 2.0.14
|
272
273
|
signing_key:
|
273
274
|
specification_version: 4
|
274
275
|
summary: Extensions for Ruby to make Rubymotion development more enjoyable, and hopefully
|
@@ -277,6 +278,7 @@ test_files:
|
|
277
278
|
- spec/568_spec.rb
|
278
279
|
- spec/animation_chain_spec.rb
|
279
280
|
- spec/anonymous_spec.rb
|
281
|
+
- spec/caanimation_spec.rb
|
280
282
|
- spec/calayer_spec.rb
|
281
283
|
- spec/color_components_spec.rb
|
282
284
|
- spec/color_other_representations_spec.rb
|