sugarcube 2.4.0 → 2.4.1
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/lib/ios/sugarcube-to_s/uicolor.rb +1 -17
- data/lib/ios/sugarcube-to_s/uiview.rb +13 -2
- data/lib/osx/sugarcube-to_s/nscolor.rb +3 -19
- data/lib/version.rb +1 -1
- data/spec/ios/color_other_representations_spec.rb +5 -5
- data/spec/ios/color_spec.rb +4 -1
- data/spec/ios/nsstring_files_spec.rb +12 -13
- data/spec/osx/color_other_representations_spec.rb +5 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5199a43eb183b24f64f8dad92396624560961df
|
4
|
+
data.tar.gz: f933938827851ae363a5be7182db0193de43a4ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 273a39aa060c9bce9caa6df076a199655b24a993385e2512b8726d3289b67387a2d22973e0a9cf2325bde332413a16791ac0abeb824e82a6df3794e8d201f805
|
7
|
+
data.tar.gz: 4c81bdce9927a97b40a842b5a9576540db7dbc03e5ed194a177c98019e873237a6bf8bbaf88a34295906ec2e52cd66f06299e8153af4ae0d6d8fc4104d335b65
|
@@ -3,25 +3,9 @@ class UIColor
|
|
3
3
|
def to_s
|
4
4
|
return super unless self.respond_to?(:alpha)
|
5
5
|
|
6
|
-
alpha_s = ((alpha || 1) < 1 ? "(#{alpha})" : '')
|
7
|
-
system_color = system_name
|
8
|
-
return "UIColor.#{system_color}#{alpha_s}" if system_color
|
9
|
-
|
10
|
-
alpha_s = ((alpha || 1) < 1 ? ", alpha: #{alpha}" : '')
|
11
|
-
inside = (css_name && ":#{css_name}") || (hex && "'#{hex}'")
|
12
|
-
if inside
|
13
|
-
return "UIColor.color(#{inside}#{alpha_s})"
|
14
|
-
else
|
15
|
-
super
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def inspect
|
20
|
-
return super unless self.respond_to?(:alpha)
|
21
|
-
|
22
6
|
alpha_s = ((alpha || 1) < 1 ? "(#{alpha})" : '')
|
23
7
|
if system_name
|
24
|
-
return "UIColor.#{system_name}#{alpha_s}"
|
8
|
+
return "UIColor.#{system_name}#{alpha_s.length > 0 ? '.colorWithAlphaComponent' + alpha_s : ''}"
|
25
9
|
elsif css_name
|
26
10
|
return ":#{css_name}.uicolor#{alpha_s}"
|
27
11
|
elsif hex
|
@@ -2,8 +2,19 @@ class UIView
|
|
2
2
|
|
3
3
|
def sugarcube_to_s(options={})
|
4
4
|
suffix = ''
|
5
|
-
|
6
|
-
|
5
|
+
# teacup
|
6
|
+
if self.respond_to?(:stylename) && self.stylename && self.stylename.length > 0
|
7
|
+
suffix += " stylename: #{self.stylename.inspect}"
|
8
|
+
end
|
9
|
+
# motionkit
|
10
|
+
if self.respond_to?(:motion_kit_ids) && self.motion_kit_ids && self.motion_kit_ids.length > 0
|
11
|
+
if motion_kit_ids.length == 1
|
12
|
+
suffix += " motion_kit_id: #{self.motion_kit_id.inspect}"
|
13
|
+
else
|
14
|
+
suffix += " motion_kit_ids: #{self.motion_kit_ids.inspect}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
# rmq?
|
7
18
|
|
8
19
|
if options[:inner].is_a? Hash
|
9
20
|
inner = ''
|
@@ -3,29 +3,13 @@ class NSColor
|
|
3
3
|
def to_s
|
4
4
|
return super unless self.respond_to?(:alpha)
|
5
5
|
|
6
|
-
alpha_s = ((alpha || 1) < 1 ? "(#{alpha})" : '')
|
7
|
-
system_color = system_name
|
8
|
-
return "NSColor.#{system_color}#{alpha_s}" if system_color
|
9
|
-
|
10
|
-
alpha_s = ((alpha || 1) < 1 ? ", alpha: #{alpha}" : '')
|
11
|
-
inside = (css_name && ":#{css_name}") || (hex && "'#{hex}'")
|
12
|
-
if inside
|
13
|
-
return "NSColor.color(#{inside}#{alpha_s})"
|
14
|
-
else
|
15
|
-
super
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def inspect
|
20
|
-
return super unless self.respond_to?(:alpha)
|
21
|
-
|
22
6
|
alpha_s = ((alpha || 1) < 1 ? "(#{alpha})" : '')
|
23
7
|
if system_name
|
24
|
-
return "NSColor.#{system_name}#{alpha_s}"
|
8
|
+
return "NSColor.#{system_name}#{alpha_s.length > 0 ? '.colorWithAlphaComponent' + alpha_s : ''}"
|
25
9
|
elsif css_name
|
26
|
-
return ":#{css_name}.
|
10
|
+
return ":#{css_name}.nscolor#{alpha_s}"
|
27
11
|
elsif hex
|
28
|
-
return "'#{hex}'.
|
12
|
+
return "'#{hex}'.nscolor#{alpha_s}"
|
29
13
|
else
|
30
14
|
super
|
31
15
|
end
|
data/lib/version.rb
CHANGED
@@ -37,11 +37,11 @@ describe 'UIColor (CSS)' do
|
|
37
37
|
|
38
38
|
it "should have good to_s return values" do
|
39
39
|
UIColor.whiteColor.to_s.should == 'UIColor.whiteColor'
|
40
|
-
UIColor.whiteColor.uicolor(0.5).to_s.should == 'UIColor.whiteColor(0.5)'
|
41
|
-
:indianred.uicolor.to_s.should == '
|
42
|
-
:indianred.uicolor(0.5).to_s.should == '
|
43
|
-
'#12be3f'.uicolor.to_s.should == "
|
44
|
-
'#12be3f'.uicolor(0.5).to_s.should == "
|
40
|
+
UIColor.whiteColor.uicolor(0.5).to_s.should == 'UIColor.whiteColor.colorWithAlphaComponent(0.5)'
|
41
|
+
:indianred.uicolor.to_s.should == ':indianred.uicolor'
|
42
|
+
:indianred.uicolor(0.5).to_s.should == ':indianred.uicolor(0.5)'
|
43
|
+
'#12be3f'.uicolor.to_s.should == "'#12be3f'.uicolor"
|
44
|
+
'#12be3f'.uicolor(0.5).to_s.should == "'#12be3f'.uicolor(0.5)"
|
45
45
|
end
|
46
46
|
|
47
47
|
it "should return UIColor objects" do
|
data/spec/ios/color_spec.rb
CHANGED
@@ -225,7 +225,10 @@ describe 'NSString UIColor extensions' do
|
|
225
225
|
end
|
226
226
|
|
227
227
|
it "that supports image names" do
|
228
|
-
|
228
|
+
a = 'little_square'.uicolor
|
229
|
+
b = 'little_square'.uiimage.uicolor
|
230
|
+
a.should.be.kind_of(UIColor)
|
231
|
+
b.should.be.kind_of(UIColor)
|
229
232
|
end
|
230
233
|
|
231
234
|
it "that supports non-existant image names" do
|
@@ -16,8 +16,12 @@ describe 'NSString' do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
it "should have a #temporary_path method" do
|
19
|
-
'foo'.temporary_path.
|
20
|
-
|
19
|
+
if 'foo'.temporary_path.start_with?('/Users')
|
20
|
+
'foo'.temporary_path.should.start_with?('/Users')
|
21
|
+
else
|
22
|
+
'foo'.temporary_path.should.start_with?('/var/folders')
|
23
|
+
end
|
24
|
+
'foo'.temporary_path.should.end_with?('/foo')
|
21
25
|
end
|
22
26
|
|
23
27
|
it "should have a resource_path method" do
|
@@ -216,32 +220,27 @@ describe 'NSString deprecated methods' do
|
|
216
220
|
end
|
217
221
|
|
218
222
|
it "should have a #document method" do
|
219
|
-
'foo'.document.should
|
220
|
-
'foo'.document.should.end_with?('Documents/foo')
|
223
|
+
'foo'.document.should == 'foo'.document_path.should
|
221
224
|
end
|
222
225
|
|
223
226
|
it "should have a #cache method" do
|
224
|
-
'foo'.cache.should
|
225
|
-
'foo'.cache.should.end_with?('Library/Caches/foo')
|
227
|
+
'foo'.cache.should == 'foo'.cache_path
|
226
228
|
end
|
227
229
|
|
228
230
|
it "should have a #app_support method" do
|
229
|
-
'foo'.app_support.should
|
230
|
-
'foo'.app_support.should.end_with?('Library/Application Support/foo')
|
231
|
+
'foo'.app_support.should == 'foo'.app_support_path
|
231
232
|
end
|
232
233
|
|
233
234
|
it "should have a #temporary method" do
|
234
|
-
'foo'.temporary.should
|
235
|
-
'foo'.temporary.should.end_with?('tmp/foo')
|
235
|
+
'foo'.temporary.should == 'foo'.temporary_path
|
236
236
|
end
|
237
237
|
|
238
238
|
it "should have a resource method" do
|
239
|
-
'little_square.png'.resource.should.
|
240
|
-
'little_square.png'.resource.should.end_with?("SugarCube_spec.app/little_square.png")
|
239
|
+
'little_square.png'.resource.should == 'little_square.png'.resource_path
|
241
240
|
end
|
242
241
|
|
243
242
|
it "should have an #exists? method" do
|
244
|
-
'foo'.document_path.exists?.should ==
|
243
|
+
'foo'.document_path.exists?.should == 'foo'.document_path.file_exists?
|
245
244
|
end
|
246
245
|
|
247
246
|
it "should have a remove! method" do
|
@@ -37,11 +37,11 @@ describe 'NSColor (CSS)' do
|
|
37
37
|
|
38
38
|
it "should have good to_s return values" do
|
39
39
|
NSColor.whiteColor.to_s.should == 'NSColor.whiteColor'
|
40
|
-
NSColor.whiteColor.nscolor(0.5).to_s.should == 'NSColor.whiteColor(0.5)'
|
41
|
-
:indianred.nscolor.to_s.should == '
|
42
|
-
:indianred.nscolor(0.5).to_s.should == '
|
43
|
-
'#12be3f'.nscolor.to_s.should == "
|
44
|
-
'#12be3f'.nscolor(0.5).to_s.should == "
|
40
|
+
NSColor.whiteColor.nscolor(0.5).to_s.should == 'NSColor.whiteColor.colorWithAlphaComponent(0.5)'
|
41
|
+
:indianred.nscolor.to_s.should == ':indianred.nscolor'
|
42
|
+
:indianred.nscolor(0.5).to_s.should == ':indianred.nscolor(0.5)'
|
43
|
+
'#12be3f'.nscolor.to_s.should == "'#12be3f'.nscolor"
|
44
|
+
'#12be3f'.nscolor(0.5).to_s.should == "'#12be3f'.nscolor(0.5)"
|
45
45
|
end
|
46
46
|
|
47
47
|
Symbol.nscolors.each do |name, method|
|