sugarcube 0.18.16 → 0.18.17

Sign up to get free protection for your applications and to get access to all the features.
@@ -173,6 +173,22 @@ class Symbol
173
173
  wheat: 0xf5deb3,
174
174
  whitesmoke: 0xf5f5f5,
175
175
  yellowgreen: 0x9acd32,
176
+
177
+ # for to_s to pick up on these colors, they need to be defined here
178
+ black: 0x000000,
179
+ blue: 0x0000ff,
180
+ brown: 0x996633,
181
+ cyan: 0x00ffff,
182
+ darkgray: 0x555555,
183
+ gray: 0x808080,
184
+ green: 0x00ff00,
185
+ lightgray: 0xaaaaaa,
186
+ magenta: 0xff00ff,
187
+ orange: 0xff8000,
188
+ purple: 0x800080,
189
+ red: 0xff0000,
190
+ yellow: 0xffff00,
191
+ white: 0xffffff,
176
192
  }
177
193
 
178
194
  end
@@ -1,4 +1,5 @@
1
1
  class UIColor
2
+
2
3
  def uicolor(alpha=nil)
3
4
  if alpha
4
5
  self.colorWithAlphaComponent(alpha.to_f)
@@ -11,6 +12,17 @@ class UIColor
11
12
  self.CGColor
12
13
  end
13
14
 
15
+ # blends two colors by averaging the RGB and alpha components.
16
+ # @example
17
+ # :white.uicolor + :black.uicolor == :gray.uicolor
18
+ def +(color)
19
+ r = (self.red + color.red) / 2
20
+ g = (self.green + color.green) / 2
21
+ b = (self.blue + color.blue) / 2
22
+ a = (self.alpha + color.alpha) / 2
23
+ UIColor.colorWithRed(r, green:g, blue:b, alpha:a)
24
+ end
25
+
14
26
  def red
15
27
  _sugarcube_colors && _sugarcube_colors[:red]
16
28
  end
@@ -1,3 +1,3 @@
1
1
  module SugarCube
2
- Version = '0.18.16'
2
+ Version = '0.18.17'
3
3
  end
@@ -117,6 +117,11 @@ describe "SugarCube::AnimationChain" do
117
117
  f = controller.view.frame
118
118
  f.origin.x -= 20
119
119
  controller.view.frame = f
120
+ }.and_then {
121
+ @variable_a += 1
122
+ f = controller.view.frame
123
+ f.origin.x += 20
124
+ controller.view.frame = f
120
125
  }.loop
121
126
  SugarCube::AnimationChain.chains.length.should == 1
122
127
 
@@ -127,12 +132,10 @@ describe "SugarCube::AnimationChain" do
127
132
 
128
133
  wait 0.31 {
129
134
  @chain.abort
130
- SugarCube::AnimationChain.chains.length.should == 0
131
- @variable_a.should > 1
132
- @variable_a.should < 4
133
135
  @num_loops = @variable_a
134
136
  }
135
137
  wait 0.51 {
138
+ SugarCube::AnimationChain.chains.length.should == 0
136
139
  @variable_a.should == @num_loops
137
140
  }
138
141
  end
@@ -85,25 +85,48 @@ describe "NSDate#delta" do
85
85
  feb_28_2012.delta(years:4).should == NSDate.from_components(year:2016, month: 2, day: 28)
86
86
  end
87
87
 
88
- it "should handle daylight savings logically" do
88
+ it "should handle daylight savings (lose an hour) logically" do
89
89
  # early hours
90
- mar_9_2012 = NSDate.from_components(year:2013, month: 3, day: 9, hour: 1)
91
- mar_9_2012.delta(days:1).should == NSDate.from_components(year:2013, month: 3, day: 10, hour: 1)
90
+ mar_9_2013 = NSDate.from_components(year:2013, month: 3, day: 9, hour: 1)
91
+ mar_9_2013.delta(days:1).should == NSDate.from_components(year:2013, month: 3, day: 10, hour: 1)
92
92
 
93
93
  # late hours
94
- mar_9_2012 = NSDate.from_components(year:2013, month: 3, day: 9, hour: 13)
95
- mar_9_2012.delta(days:1).should == NSDate.from_components(year:2013, month: 3, day: 10, hour: 13)
94
+ mar_9_2013 = NSDate.from_components(year:2013, month: 3, day: 9, hour: 13)
95
+ mar_9_2013.delta(days:1).should == NSDate.from_components(year:2013, month: 3, day: 10, hour: 13)
96
96
  end
97
97
 
98
- it "should handle daylight savings logically unless you assign an hour" do
99
- mar_9_2012 = NSDate.from_components(year:2013, month: 3, day: 9, hour: 13)
98
+ it "should handle daylight savings (lose an hour) logically unless you assign an hour" do
99
+ mar_9_2013 = NSDate.from_components(year:2013, month: 3, day: 9, hour: 13)
100
100
 
101
- tz = mar_9_2012.timezone
102
- mar_11_2012 = NSDate.from_components(year:2013, month: 3, day: 11)
103
- if tz.isDaylightSavingTimeForDate(mar_11_2012)
104
- mar_9_2012.delta(days:1, hours: 1).should == NSDate.from_components(year:2013, month: 3, day: 10, hour: 15)
101
+ # @TODO this should use a fixed timezone, not the user's timezone
102
+ mar_11_2013 = NSDate.from_components(year:2013, month: 3, day: 11)
103
+ tz = mar_11_2013.timezone
104
+ if tz.isDaylightSavingTimeForDate(mar_11_2013)
105
+ mar_9_2013.delta(days:1, hours: 1).should == NSDate.from_components(year:2013, month: 3, day: 10, hour: 15)
105
106
  else
106
- mar_9_2012.delta(days:1, hours: 1).should == NSDate.from_components(year:2013, month: 3, day: 10, hour: 14)
107
+ mar_9_2013.delta(days:1, hours: 1).should == NSDate.from_components(year:2013, month: 3, day: 10, hour: 14)
108
+ end
109
+ end
110
+
111
+ it "should handle daylight savings (gain an hour) logically" do
112
+ # early hours
113
+ nov_2_2013 = NSDate.from_components(year:2013, month: 11, day: 2, hour: 1)
114
+ nov_2_2013.delta(days:1).should == NSDate.from_components(year:2013, month: 11, day: 3, hour: 1)
115
+
116
+ # late hours
117
+ nov_2_2013 = NSDate.from_components(year:2013, month: 11, day: 2, hour: 13)
118
+ nov_2_2013.delta(days:1).should == NSDate.from_components(year:2013, month: 11, day: 3, hour: 13)
119
+ end
120
+
121
+ it "should handle daylight savings (gain an hour) logically unless you assign an hour" do
122
+ nov_2_2013 = NSDate.from_components(year:2013, month: 11, day: 2, hour: 13)
123
+
124
+ # @TODO this should use a fixed timezone, not the user's timezone
125
+ tz = nov_2_2013.timezone
126
+ if tz.isDaylightSavingTimeForDate(nov_2_2013)
127
+ nov_2_2013.delta(days:1, hours: 1).should == NSDate.from_components(year:2013, month: 11, day: 3, hour: 13)
128
+ else
129
+ nov_2_2013.delta(days:1, hours: 1).should == NSDate.from_components(year:2013, month: 11, day: 3, hour: 14)
107
130
  end
108
131
  end
109
132
 
@@ -1,7 +1,7 @@
1
1
  describe 'UIColor (CSS)' do
2
2
 
3
3
  it "should return css color names" do
4
- except_for = [:aqua, :fuchsia, :lime]
4
+ except_for = [:aqua, :fuchsia, :lime, :black, :blue, :brown, :cyan, :darkgray, :gray, :green, :lightgray, :magenta, :orange, :purple, :red, :yellow, :white]
5
5
  Symbol.css_colors.each do |name, val|
6
6
  next if except_for.include? name
7
7
 
data/spec/uicolor_spec.rb CHANGED
@@ -8,4 +8,11 @@ describe 'UIColor' do
8
8
  UIColor.redColor.uicolor(0.5).alpha.should == 0.5
9
9
  end
10
10
 
11
+ it "should have a #+(color) method" do
12
+ new_color = UIColor.whiteColor + UIColor.blackColor
13
+ new_color.red.should == 0.5
14
+ new_color.green.should == 0.5
15
+ new_color.blue.should == 0.5
16
+ end
17
+
11
18
  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: 0.18.16
4
+ version: 0.18.17
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-02-26 00:00:00.000000000 Z
16
+ date: 2013-02-27 00:00:00.000000000 Z
17
17
  dependencies: []
18
18
  description: ! '== Description
19
19
 
@@ -210,3 +210,4 @@ test_files:
210
210
  - spec/uiview_attr_updates_spec.rb
211
211
  - spec/uiview_spec.rb
212
212
  - spec/unholy_spec.rb
213
+ has_rdoc: