sugarcube 0.19.2 → 0.19.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -3,7 +3,7 @@ class NSDate
3
3
  # a string using string_with_format's templating, and strings are concatenated
4
4
  # as-is
5
5
  SugarCubeFormats = {
6
- iso8601: [:yyyy, '-', :MM, '-', :dd, ' ', :HH, ':', :mm, ':', :ss, '.', :SSS]
6
+ iso8601: [:yyyy, '-', :MM, '-', :dd, ' ', :'HH:mm:ss.SSS']
7
7
  }
8
8
 
9
9
  def self.from_components(components)
@@ -0,0 +1,7 @@
1
+ class NSError
2
+ def to_s
3
+ "#<#{self.class.name}:0x#{self.object_id.to_s(16)}, "+
4
+ "URL=#{self.absoluteString.inspect}"+
5
+ ">"
6
+ end
7
+ end
@@ -1,16 +1,14 @@
1
1
  class UIColor
2
2
 
3
3
  def to_s
4
+ alpha_s = ((alpha || 1) < 1 ? "(#{alpha})" : '')
4
5
  system_color = system_name
5
- return system_color if system_color
6
+ return "UIColor.#{system_color}#{alpha_s}" if system_color
6
7
 
7
- inside = self.css_name || self.hex
8
+ alpha_s = ((alpha || 1) < 1 ? ", alpha: #{alpha}" : '')
9
+ inside = (css_name && ":#{css_name}") || (hex && "'#{hex}'")
8
10
  if inside
9
- if self.alpha < 1
10
- return "UIColor.color(#{inside}, #{alpha})"
11
- else
12
- return "UIColor.color(#{inside})"
13
- end
11
+ return "UIColor.color(#{inside}#{alpha_s})"
14
12
  else
15
13
  super
16
14
  end
@@ -120,13 +120,14 @@ class UIColor
120
120
 
121
121
  def system_name
122
122
  system_color = nil
123
+ without_alpha = self.uicolor(1)
123
124
  Symbol.uicolors.each_pair do |color, method|
124
- if UIColor.send(method) == self
125
+ if UIColor.send(method) == without_alpha
125
126
  system_color = method
126
127
  break
127
128
  end
128
129
  end
129
- return system_color.to_s
130
+ return system_color
130
131
  end
131
132
 
132
133
  private
@@ -321,8 +321,8 @@ class UIImage
321
321
  def darken(options={})
322
322
  filter_name = 'CIColorControls'
323
323
  filter_options = {
324
- inputBrightness: options[:brightness] || -0.5,
325
- inputSaturation: options[:saturation] || -0.2,
324
+ inputBrightness: options[:brightness] || 0,
325
+ inputSaturation: options[:saturation] || 0,
326
326
  }
327
327
 
328
328
  cg_input_image = CIImage.alloc.initWithImage(self)
@@ -1,3 +1,3 @@
1
1
  module SugarCube
2
- Version = '0.19.2'
2
+ Version = '0.19.4'
3
3
  end
@@ -16,8 +16,8 @@ describe 'UIColor (CSS)' do
16
16
  end
17
17
 
18
18
  it "should have a #system_name method" do
19
- UIColor.whiteColor.system_name.should == 'whiteColor'
20
- UIColor.blackColor.system_name.should == 'blackColor'
19
+ UIColor.whiteColor.system_name.should == :whiteColor
20
+ UIColor.blackColor.system_name.should == :blackColor
21
21
  end
22
22
 
23
23
  it "should return css color names" do
@@ -34,6 +34,15 @@ describe 'UIColor (CSS)' do
34
34
  end
35
35
  end
36
36
 
37
+ it "should have good to_s return values" do
38
+ UIColor.whiteColor.to_s.should == 'UIColor.whiteColor'
39
+ UIColor.whiteColor.uicolor(0.5).to_s.should == 'UIColor.whiteColor(0.5)'
40
+ :indianred.uicolor.to_s.should == 'UIColor.color(:indianred)'
41
+ :indianred.uicolor(0.5).to_s.should == 'UIColor.color(:indianred, alpha: 0.5)'
42
+ '#12be3f'.uicolor.to_s.should == "UIColor.color('#12be3f')"
43
+ '#12be3f'.uicolor(0.5).to_s.should == "UIColor.color('#12be3f', alpha: 0.5)"
44
+ end
45
+
37
46
  it "should return UIColor objects" do
38
47
  Symbol.uicolors.each do |name, method|
39
48
  name.uicolor.should == UIColor.send(method)
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.19.2
4
+ version: 0.19.4
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-03-19 00:00:00.000000000 Z
16
+ date: 2013-03-20 00:00:00.000000000 Z
17
17
  dependencies: []
18
18
  description: ! '== Description
19
19
 
@@ -89,6 +89,7 @@ files:
89
89
  - lib/sugarcube/to_s/nserror.rb
90
90
  - lib/sugarcube/to_s/nslayoutconstraint.rb
91
91
  - lib/sugarcube/to_s/nsset.rb
92
+ - lib/sugarcube/to_s/nsurl.rb
92
93
  - lib/sugarcube/to_s/uicolor.rb
93
94
  - lib/sugarcube/to_s/uievent.rb
94
95
  - lib/sugarcube/to_s/uilabel.rb