sugarcube 3.3.2 → 3.3.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b93b8cbedc130c019d2eaf293a07337b5a041b10
4
- data.tar.gz: 04d121961d44ba27a8258fc3844d9dd2a47cfd72
3
+ metadata.gz: 59c8482c83573e42f64f42c9aa90718298be515d
4
+ data.tar.gz: 58b279d2a997169e4ef3bb3582376c581257d484
5
5
  SHA512:
6
- metadata.gz: 372c7d62dcd616471d92ff970278060813113569faf9a34040dea78631f39fccaa48d8b9b13ec0e3de1e035f81435f4e7c42134da90cf7e496456f693eb98efb
7
- data.tar.gz: 496c37d5f0760e84024e6c5d3a84b79cf586e21bb93c005a6205df5c2d10b1f3309387ec8ef727a5efdf74d9af47c78259ebe3696dd4eb15aeb4daf632e787bb
6
+ metadata.gz: 1f199aad09635d42e99d6a352f813f3db32d64c1d01cdec9da5e3878f0b1462d3648a92dc78519936fdc49a7dd6ebcc8610c457e97d8799bb0c844b805bee5a9
7
+ data.tar.gz: c5a175dcf6a9c5502bc3d6757f9290b868ce52836aaafda2b4eba12cf5e79723d2a2b5f4dc034e59f4d214ccdc04a6b3eeb657e10be4ae14ff5ae510b8183eba
@@ -1,7 +1,7 @@
1
1
  class NSArray
2
2
 
3
3
  # [160, 210, 242].uicolor => 0xA0D2F2.uicolor
4
- def uicolor(alpha=1.0)
4
+ def nscolor(alpha=1.0)
5
5
  red = self[0] / 255.0
6
6
  green = self[1] / 255.0
7
7
  blue = self[2] / 255.0
@@ -1,3 +1,3 @@
1
1
  module SugarCube
2
- Version = '3.3.2'
2
+ Version = '3.3.3'
3
3
  end
@@ -4,6 +4,10 @@ describe UIColor do
4
4
  UIColor.redColor.uicolor.should == UIColor.redColor
5
5
  end
6
6
 
7
+ it "should have a #uicolor(alpha) method" do
8
+ UIColor.redColor.uicolor(0.5).alpha.should == 0.5
9
+ end
10
+
7
11
  it "should support #cgcolor" do
8
12
  -> do
9
13
  UIColor.redColor.cgcolor.should == UIColor.redColor.CGColor
@@ -14,10 +18,6 @@ describe UIColor do
14
18
  UIColor.redColor.skcolor.should == UIColor.redColor
15
19
  end
16
20
 
17
- it "should have a #uicolor(alpha) method" do
18
- UIColor.redColor.uicolor(0.5).alpha.should == 0.5
19
- end
20
-
21
21
  it "should have a #skcolor(alpha) method" do
22
22
  UIColor.redColor.skcolor(0.5).alpha.should == 0.5
23
23
  end
@@ -1,9 +1,13 @@
1
- describe 'NSColor' do
1
+ describe NSColor do
2
2
 
3
3
  it "should support #nscolor" do
4
4
  NSColor.redColor.nscolor.should == NSColor.redColor
5
5
  end
6
6
 
7
+ it "should support #nscolor(alpha) method" do
8
+ NSColor.redColor.nscolor(0.5).alpha.should == 0.5
9
+ end
10
+
7
11
  it "should support #cgcolor" do
8
12
  -> do
9
13
  NSColor.redColor.cgcolor.should == NSColor.redColor.CGColor
@@ -14,8 +18,8 @@ describe 'NSColor' do
14
18
  NSColor.redColor.skcolor.should == NSColor.redColor
15
19
  end
16
20
 
17
- it "should support #nscolor(alpha) method" do
18
- NSColor.redColor.nscolor(0.5).alpha.should == 0.5
21
+ it "should have a #skcolor(alpha) method" do
22
+ NSColor.redColor.skcolor(0.5).alpha.should == 0.5
19
23
  end
20
24
 
21
25
  describe "should have a #+(color) method" do
@@ -86,23 +90,23 @@ describe 'NSColor' do
86
90
  end
87
91
 
88
92
  it "should have a #invert method" do
89
- :white.nscolor.invert.red.should == 0
90
- :white.nscolor.invert.green.should == 0
91
- :white.nscolor.invert.blue.should == 0
93
+ NSColor.redColor.invert.should == NSColor.cyanColor
94
+ NSColor.greenColor.invert.should == NSColor.magentaColor
95
+ NSColor.blueColor.invert.should == NSColor.yellowColor
92
96
 
93
- :black.nscolor.invert.red.should == 1
94
- :black.nscolor.invert.green.should == 1
95
- :black.nscolor.invert.blue.should == 1
96
- end
97
+ NSColor.whiteColor.invert.red.should == 0
98
+ NSColor.whiteColor.invert.green.should == 0
99
+ NSColor.whiteColor.invert.blue.should == 0
97
100
 
98
- it "should process system colors with a NSNamedColorSpace correctly" do
99
- NSColor.controlTextColor.invert.should.not.raise(StandardError)
101
+ NSColor.blackColor.invert.red.should == 1
102
+ NSColor.blackColor.invert.green.should == 1
103
+ NSColor.blackColor.invert.blue.should == 1
100
104
  end
101
105
 
102
106
  it "should have a #mix_with method" do
103
- white = :white.nscolor
104
- black = :black.nscolor
105
- gray = :gray.nscolor
107
+ white = NSColor.whiteColor
108
+ black = NSColor.blackColor
109
+ gray = NSColor.grayColor
106
110
  white.mix_with(black, 0).red.should == 1
107
111
  white.mix_with(black, 0).green.should == 1
108
112
  white.mix_with(black, 0).blue.should == 1
@@ -124,4 +128,141 @@ describe 'NSColor' do
124
128
  white.mix_with(black, 0.75).blue.should == 0.25
125
129
  end
126
130
 
131
+ it "should process system colors with a NSNamedColorSpace correctly" do
132
+ NSColor.controlTextColor.invert.should.not.raise(StandardError)
133
+ end
134
+
135
+ end
136
+
137
+
138
+ describe 'Fixnum NSColor extensions' do
139
+ it "should support #nscolor" do
140
+ color = 0xffffff.nscolor
141
+ color.red.should == 1
142
+ color.green.should == 1
143
+ color.blue.should == 1
144
+ color.alpha.should == 1
145
+ end
146
+
147
+ it "should support #cgcolor" do
148
+ -> do
149
+ 0xffffff.cgcolor.class.should == NSColor.redColor.CGColor.class
150
+ end.should.not.raise
151
+ end
152
+
153
+ it "should support #skcolor" do
154
+ 0xffffff.skcolor.should.be.kind_of(NSColor)
155
+ end
156
+
157
+ it "should have a 0x000000#nscolor(0.5) method" do
158
+ color = 0.nscolor(0.5)
159
+ color.red.should == 0
160
+ color.green.should == 0
161
+ color.blue.should == 0
162
+ color.alpha.should == 0.5
163
+ end
164
+ end
165
+
166
+
167
+ describe 'NSArray NSColor extensions' do
168
+ it "should support #nscolor" do
169
+ color = [255, 255, 255].nscolor
170
+ color.red.should == 1
171
+ color.green.should == 1
172
+ color.blue.should == 1
173
+ color.alpha.should == 1
174
+ end
175
+
176
+ it "should support #cgcolor" do
177
+ -> do
178
+ [255, 255, 255].cgcolor.class.should == NSColor.redColor.CGColor.class
179
+ end.should.not.raise
180
+ end
181
+
182
+ it "should support #skcolor" do
183
+ [255, 255, 255].skcolor.should.be.kind_of(NSColor)
184
+ end
185
+
186
+ it "should have a [0, 0, 0]#nscolor(0.5) method" do
187
+ color = [0, 0, 0].nscolor(0.5)
188
+ color.red.should == 0
189
+ color.green.should == 0
190
+ color.blue.should == 0
191
+ color.alpha.should == 0.5
192
+ end
193
+ end
194
+
195
+
196
+ describe 'NSString NSColor extensions' do
197
+
198
+ it "should support #nscolor" do
199
+ color = '#ffffff'.nscolor
200
+ color.should.be.kind_of(NSColor)
201
+ color.red.should == 1.0
202
+ color.green.should == 1.0
203
+ color.blue.should == 1.0
204
+
205
+ color = '#808080'.nscolor
206
+ color.should.be.kind_of(NSColor)
207
+ ((color.red * 2).round / 2.0).should == 0.5
208
+ ((color.green * 2).round / 2.0).should == 0.5
209
+ ((color.blue * 2).round / 2.0).should == 0.5
210
+ end
211
+
212
+ it "should support #cgcolor" do
213
+ -> do
214
+ '#ffffff'.cgcolor.class.should == NSColor.redColor.CGColor.class
215
+ end.should.not.raise
216
+ end
217
+
218
+ it "should support #skcolor" do
219
+ '#ffffff'.skcolor.should.be.kind_of(NSColor)
220
+ end
221
+
222
+ it "should have '#000000'.nscolor(0.5) method" do
223
+ color = '#000000'.nscolor(0.5)
224
+ color.should.be.kind_of(NSColor)
225
+ color.red.should == 0
226
+ color.green.should == 0
227
+ color.blue.should == 0
228
+ color.alpha.should == 0.5
229
+ end
230
+
231
+ it "that supports image names" do
232
+ a = 'little_square'.nscolor
233
+ b = 'little_square'.nsimage.nscolor
234
+ a.should.be.kind_of(NSColor)
235
+ b.should.be.kind_of(NSColor)
236
+ end
237
+
238
+ it "that supports non-existant image names" do
239
+ 'this is not my beautiful house!'.nscolor.should == nil
240
+ end
241
+
242
+ end
243
+
244
+
245
+ describe 'NSImage NSColor extensions' do
246
+ it 'should support #nscolor' do
247
+ color = NSImage.imageNamed('little_square').nscolor
248
+ color.should.be.kind_of(NSColor)
249
+ end
250
+
251
+ it 'should support #cgcolor' do
252
+ -> do
253
+ NSImage.imageNamed('little_square').cgcolor.class.should == NSColor.redColor.CGColor.class
254
+ end.should.not.raise
255
+ end
256
+
257
+ it "should support #skcolor" do
258
+ NSImage.imageNamed('little_square').skcolor.should.be.kind_of(NSColor)
259
+ end
260
+
261
+ it 'should support #nscolor(0.5)' do
262
+ -> do
263
+ NSImage.imageNamed('little_square').nscolor(0.5)
264
+ # unfortunately, this doesn't work:
265
+ # image.alpha.should == 0.5 # alpha returns 0 because this is not an RGB or HSB color
266
+ end.should.not.raise
267
+ end
127
268
  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: 3.3.2
4
+ version: 3.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colin T.A. Gray
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2015-02-25 00:00:00.000000000 Z
15
+ date: 2015-03-12 00:00:00.000000000 Z
16
16
  dependencies: []
17
17
  description: |
18
18
  == Description
@@ -306,12 +306,12 @@ require_paths:
306
306
  - lib
307
307
  required_ruby_version: !ruby/object:Gem::Requirement
308
308
  requirements:
309
- - - '>='
309
+ - - ">="
310
310
  - !ruby/object:Gem::Version
311
311
  version: '0'
312
312
  required_rubygems_version: !ruby/object:Gem::Requirement
313
313
  requirements:
314
- - - '>='
314
+ - - ">="
315
315
  - !ruby/object:Gem::Version
316
316
  version: '0'
317
317
  requirements: []