sugarcube 0.16.2 → 0.16.5

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1320,6 +1320,8 @@ Quick wrapper for `CFUUIDCreate()` and `CFUUIDCreateString()`. Identical to the
1320
1320
  Ruby on Rails Ripoffs (RoR-R?)
1321
1321
  ---------------
1322
1322
 
1323
+ aka `ActiveSupport`.
1324
+
1323
1325
  ```ruby
1324
1326
  # truthiness with `blank?`
1325
1327
  nil.blank? # => true
@@ -1333,6 +1335,11 @@ true.blank? # => false
1333
1335
  'a'.blank? # => false
1334
1336
  ['a'].blank? # => false
1335
1337
  {a: 'a'}.blank? # => false
1338
+
1339
+ # and my favorite
1340
+ 1.in? [1,2,3] # => true
1341
+ 1.in? 1,2,3 # => true
1342
+ 1.in? 4..5 # => false
1336
1343
  ```
1337
1344
 
1338
1345
  Gestures
@@ -0,0 +1,28 @@
1
+ # Thanks ruby on rails!
2
+ #
3
+ # These are all blatent, unapologetic rip offs of RoR extensions, and they
4
+ # behave in exactly the same way.
5
+
6
+ class Object
7
+
8
+ def blank?
9
+ respond_to?(:empty?) ? empty? : !self
10
+ end
11
+
12
+ def present?
13
+ !blank?
14
+ end
15
+
16
+ # okay, this is strange, but `rake spec` fails if I define the method as `in?`
17
+ # but passes if I alias it, as I do below. weird, but I don't want to fight
18
+ # it.
19
+ def in(*list)
20
+ if list.length == 1
21
+ return list[0].include?(self)
22
+ else
23
+ return list.include?(self)
24
+ end
25
+ end
26
+ alias :in? :in
27
+
28
+ end
@@ -32,6 +32,10 @@ class Fixnum
32
32
  return "th"
33
33
  end
34
34
 
35
+ def ordinalize
36
+ return "#{self}#{nth}"
37
+ end
38
+
35
39
  def before(date)
36
40
  date - self
37
41
  end
@@ -54,6 +54,42 @@ class Numeric
54
54
  self / 1.foot
55
55
  end
56
56
 
57
+ def bytes
58
+ self
59
+ end
60
+ alias byte bytes
61
+
62
+ def kilobytes
63
+ self * 1024**1
64
+ end
65
+ alias kilobyte kilobytes
66
+
67
+ def megabytes
68
+ self * 1024**2
69
+ end
70
+ alias megabyte megabytes
71
+
72
+ def gigabytes
73
+ self * 1024**3
74
+ end
75
+ alias gigabyte gigabytes
76
+
77
+ def terabytes
78
+ self * 1024**4
79
+ end
80
+ alias terabyte terabytes
81
+
82
+ def petabytes
83
+ self * 1024**5
84
+ end
85
+ alias petabyte petabytes
86
+
87
+ def exabytes
88
+ self * 1024**6
89
+ end
90
+ alias exabyte exabytes
91
+
92
+
57
93
  def string_with_style(style=NSNumberFormatterDecimalStyle)
58
94
  if style.is_a? Symbol
59
95
  style = style.nsnumberstyle
@@ -1,14 +1,20 @@
1
1
  class UIColor
2
- def uicolor ; self ; end
3
-
4
- def red
5
- _sugarcube_colors && _sugarcube_colors[:red]
2
+ def uicolor(alpha=nil)
3
+ if alpha
4
+ self.colorWithAlphaComponent(alpha.to_f)
5
+ else
6
+ self
7
+ end
6
8
  end
7
9
 
8
10
  def cgcolor
9
11
  self.CGColor
10
12
  end
11
13
 
14
+ def red
15
+ _sugarcube_colors && _sugarcube_colors[:red]
16
+ end
17
+
12
18
  def green
13
19
  _sugarcube_colors && _sugarcube_colors[:green]
14
20
  end
@@ -1,3 +1,3 @@
1
1
  module SugarCube
2
- Version = '0.16.2'
2
+ Version = '0.16.5'
3
3
  end
@@ -0,0 +1,79 @@
1
+ describe 'ActiveSupport' do
2
+
3
+ describe "should have a blank? method" do
4
+ it "should be false for #{true.inspect}" do
5
+ true.blank?.should == false
6
+ end
7
+ it "should be false for #{false.inspect}" do
8
+ false.blank?.should == true
9
+ end
10
+ it "should be false for #{[].inspect}" do
11
+ [].blank?.should == true
12
+ end
13
+ it "should be false for #{[1].inspect}" do
14
+ [1].blank?.should == false
15
+ end
16
+ it "should be false for #{{}.inspect}" do
17
+ {}.blank?.should == true
18
+ end
19
+ it "should be false for #{{a:1}.inspect}" do
20
+ {a:1}.blank?.should == false
21
+ end
22
+ it "should be false for #{''.inspect}" do
23
+ ''.blank?.should == true
24
+ end
25
+ it "should be false for #{'a'.inspect}" do
26
+ 'a'.blank?.should == false
27
+ end
28
+ it "should be false for #{' '.inspect}" do
29
+ ' '.blank?.should == false
30
+ end
31
+ end
32
+
33
+ describe "should have a present? method" do
34
+ it "should be false for #{true.inspect}" do
35
+ true.present?.should == true
36
+ end
37
+ it "should be false for #{false.inspect}" do
38
+ false.present?.should == false
39
+ end
40
+ it "should be false for #{[].inspect}" do
41
+ [].present?.should == false
42
+ end
43
+ it "should be false for #{[1].inspect}" do
44
+ [1].present?.should == true
45
+ end
46
+ it "should be false for #{{}.inspect}" do
47
+ {}.present?.should == false
48
+ end
49
+ it "should be false for #{{a:1}.inspect}" do
50
+ {a:1}.present?.should == true
51
+ end
52
+ it "should be false for #{''.inspect}" do
53
+ ''.present?.should == false
54
+ end
55
+ it "should be false for #{'a'.inspect}" do
56
+ 'a'.present?.should == true
57
+ end
58
+ it "should be false for #{' '.inspect}" do
59
+ ' '.present?.should == true
60
+ end
61
+ end
62
+
63
+ it "should have an in? method" do
64
+ 1.in?(1,2,3).should == true
65
+ 0.in?(1,2,3).should == false
66
+
67
+ 1.in?([1,2,3]).should == true
68
+ 0.in?([1,2,3]).should == false
69
+
70
+ :a.in?({a:1,b:2,c:3}).should == true
71
+ 1.in?({a:1,b:2,c:3}).should == false
72
+
73
+ 1.in?(1..3).should == true
74
+ 0.in?(1..3).should == false
75
+
76
+ :anything.in?().should == false
77
+ end
78
+
79
+ end
@@ -85,6 +85,7 @@ describe "Fixnum" do
85
85
  2003 => 'rd',
86
86
  }.each do |num, expected|
87
87
  num.nth.should == "#{expected}"
88
+ num.ordinalize.should == "#{num}#{expected}"
88
89
  end
89
90
  end
90
91
 
@@ -0,0 +1,11 @@
1
+ describe "NSURL" do
2
+
3
+ it "should have a method #open" do
4
+ 'test'.nsurl.respond_to?(:open).should == true
5
+ end
6
+
7
+ it "should have a method #can_open?" do
8
+ 'https://github.com'.nsurl.can_open?.should == true
9
+ end
10
+
11
+ end
@@ -74,6 +74,42 @@ describe "Numeric" do
74
74
  2.meters.in_feet.round.should == 7
75
75
  end
76
76
 
77
+ it "should have a #byte method" do
78
+ 1.byte.should == 1
79
+ 2.bytes.should == 2
80
+ end
81
+
82
+ it "should have a #kilobyte method" do
83
+ 1.kilobyte.should == 1 * 1024**1
84
+ 2.kilobytes.should == 2 * 1024**1
85
+ end
86
+
87
+ it "should have a #megabyte method" do
88
+ 1.megabyte.should == 1 * 1024**2
89
+ 2.megabytes.should == 2 * 1024**2
90
+ end
91
+
92
+ it "should have a #gigabyte method" do
93
+ 1.gigabyte.should == 1 * 1024**3
94
+ 2.gigabytes.should == 2 * 1024**3
95
+ end
96
+
97
+ it "should have a #terabyte method" do
98
+ 1.terabyte.should == 1 * 1024**4
99
+ 2.terabytes.should == 2 * 1024**4
100
+ end
101
+
102
+ it "should have a #petabyte method" do
103
+ 1.petabyte.should == 1 * 1024**5
104
+ 2.petabytes.should == 2 * 1024**5
105
+ end
106
+
107
+ it "should have a #exabyte method" do
108
+ 1.exabyte.should == 1 * 1024**6
109
+ 2.exabytes.should == 2 * 1024**6
110
+ end
111
+
112
+
77
113
  it "should have a #string_with_style method" do
78
114
  1000.string_with_style.should == NSNumberFormatter.localizedStringFromNumber(1000, numberStyle:NSNumberFormatterDecimalStyle)
79
115
  1000.string_with_style(:decimal).should == NSNumberFormatter.localizedStringFromNumber(1000, numberStyle:NSNumberFormatterDecimalStyle)
@@ -1,4 +1,4 @@
1
- describe 'Symbol#uicolor' do
1
+ describe 'UIColor (CSS)' do
2
2
 
3
3
  it "should return css color names" do
4
4
  except_for = [:aqua, :fuchsia, :lime]
@@ -6,6 +6,7 @@ describe 'Symbol#uicolor' do
6
6
  next if except_for.include? name
7
7
 
8
8
  color = val.uicolor
9
+ color.css_name.should == name
9
10
  color.to_s.should == "UIColor.color(#{name.inspect})"
10
11
  end
11
12
  end
@@ -0,0 +1,11 @@
1
+ describe 'UIColor' do
2
+
3
+ it "should have a #uicolor method" do
4
+ UIColor.redColor.uicolor.should == UIColor.redColor
5
+ end
6
+
7
+ it "should have a #uicolor(alpha) method" do
8
+ UIColor.redColor.uicolor(0.5).alpha.should == 0.5
9
+ end
10
+
11
+ end
@@ -40,12 +40,20 @@ describe "UIImage scale methods" do
40
40
 
41
41
  it 'should scale_to_fill a wider size' do
42
42
  scaled = @image.scale_to_fill([20, 10])
43
- scaled.nsdata.writeToFile('scale_to_fill.png'.document, atomically: true)
43
+ scaled.nsdata.writeToFile('scale_to_fill_wider.png'.document, atomically: true)
44
44
  scaled.size.width.should == 20
45
45
  scaled.size.height.should == 10
46
46
  scaled.scale.should == @image.scale
47
47
  end
48
48
 
49
+ it 'should scale_to_fill a smaller size' do
50
+ scaled = @image.scale_to_fill([5, 5])
51
+ scaled.nsdata.writeToFile('scale_to_fill_smaller.png'.document, atomically: true)
52
+ scaled.size.width.should == 5
53
+ scaled.size.height.should == 5
54
+ scaled.scale.should == @image.scale
55
+ end
56
+
49
57
  it 'scale_to_fill should support position' do
50
58
  scaled = @image.scale_to_fill([10, 20], position: :top_left)
51
59
  scaled.nsdata.writeToFile('scale_to_fill_position_top_left.png'.document, atomically: true)
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.16.2
4
+ version: 0.16.5
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-07 00:00:00.000000000 Z
16
+ date: 2013-02-08 00:00:00.000000000 Z
17
17
  dependencies: []
18
18
  description: ! '== Description
19
19
 
@@ -55,6 +55,7 @@ files:
55
55
  - lib/sugarcube-unholy.rb
56
56
  - lib/sugarcube-unholy/ivar.rb
57
57
  - lib/sugarcube.rb
58
+ - lib/sugarcube/activesupport.rb
58
59
  - lib/sugarcube/adjust.rb
59
60
  - lib/sugarcube/calayer.rb
60
61
  - lib/sugarcube/core_graphics.rb
@@ -76,7 +77,6 @@ files:
76
77
  - lib/sugarcube/nsurl.rb
77
78
  - lib/sugarcube/nsuserdefaults.rb
78
79
  - lib/sugarcube/numeric.rb
79
- - lib/sugarcube/ror.rb
80
80
  - lib/sugarcube/symbol.rb
81
81
  - lib/sugarcube/symbol/symbol_uicolor.rb
82
82
  - lib/sugarcube/timer.rb
@@ -117,6 +117,7 @@ files:
117
117
  - resources/tall@2x.png
118
118
  - runtests
119
119
  - spec/568_spec.rb
120
+ - spec/activesupport_spec.rb
120
121
  - spec/calayer_spec.rb
121
122
  - spec/core_graphics_spec.rb
122
123
  - spec/core_location_spec.rb
@@ -130,9 +131,11 @@ files:
130
131
  - spec/nsdate_upto_spec.rb
131
132
  - spec/nsstring_files_spec.rb
132
133
  - spec/nsstring_spec.rb
134
+ - spec/nsurl_spec.rb
133
135
  - spec/numeric_spec.rb
134
- - spec/symbol_uicolor_spec.rb
135
136
  - spec/uicolor_components_spec.rb
137
+ - spec/uicolor_css_spec.rb
138
+ - spec/uicolor_spec.rb
136
139
  - spec/uiimage_color_at_spec.rb
137
140
  - spec/uiimage_scale_spec.rb
138
141
  - spec/uiview_animation_spec.rb
@@ -166,6 +169,7 @@ summary: Extensions for Ruby to make Rubymotion development more enjoyable, and
166
169
  more rubyesque!
167
170
  test_files:
168
171
  - spec/568_spec.rb
172
+ - spec/activesupport_spec.rb
169
173
  - spec/calayer_spec.rb
170
174
  - spec/core_graphics_spec.rb
171
175
  - spec/core_location_spec.rb
@@ -179,9 +183,11 @@ test_files:
179
183
  - spec/nsdate_upto_spec.rb
180
184
  - spec/nsstring_files_spec.rb
181
185
  - spec/nsstring_spec.rb
186
+ - spec/nsurl_spec.rb
182
187
  - spec/numeric_spec.rb
183
- - spec/symbol_uicolor_spec.rb
184
188
  - spec/uicolor_components_spec.rb
189
+ - spec/uicolor_css_spec.rb
190
+ - spec/uicolor_spec.rb
185
191
  - spec/uiimage_color_at_spec.rb
186
192
  - spec/uiimage_scale_spec.rb
187
193
  - spec/uiview_animation_spec.rb
@@ -1,13 +0,0 @@
1
- # thanks ruby on rails!
2
- #
3
- # these are all blatent, unapologetic rip offs of RoR extensions.
4
-
5
- class Object
6
- def blank?
7
- respond_to?(:empty?) ? empty? : !self
8
- end
9
-
10
- def present?
11
- !blank?
12
- end
13
- end