sugarcube 2.7.1 → 2.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 887111adcadfc5e64dc1f50f649651c2283f052c
4
- data.tar.gz: 102dbe9925b7c723a8b23a3711a3ec03d99421dc
3
+ metadata.gz: d92ca8801aa6ce45f836070a494cc25f9d474c6a
4
+ data.tar.gz: a99bc4acf26ba266d12f27151f909369956fb0f4
5
5
  SHA512:
6
- metadata.gz: 63cd5a6ba9a81639b8caa2c80a860ffa290693cbeb87339f144584de8c92301e99f8a9f7f24ed385ea183f4c2d8ce8b722a91346a9dad2f65a8b68ed75dbe60d
7
- data.tar.gz: 815c0a979776d4f2f1cb316f9ddc94d428f4a1db78e2abe3babc4995dfd7061c3952ebbb869c061d393bc1cd33336a0d962e8109b658b7b9c3597e82071d31a5
6
+ metadata.gz: df7aeb2713c85ccea53e7525942f724825ffde89b524ac8511c0b01cf2a786da80f26b2ea76a8ecbb289b02bdb5513b9d5d333265a96084daa5d9cf205970c65
7
+ data.tar.gz: 8ec64c92acadd1293ee94549f6450ed32f629017ede4ca931f9e629cfa3ad4c4fd2f0cce2a74eda3287143f34870fe3de1cf61cd9f809f95b1c204650e15b3ea
data/README.md CHANGED
@@ -779,6 +779,7 @@ UIButton.buttonWithType(:custom.uibuttontype)
779
779
  # =>
780
780
  UIButton.custom
781
781
 
782
+ # many of these are obsolete since iOS 7
782
783
  UIButton.custom => UIButton.buttonWithType(:custom.uibuttontype)
783
784
  UIButton.rounded => UIButton.buttonWithType(:rounded.uibuttontype)
784
785
  UIButton.rounded_rect => UIButton.buttonWithType(:rounded_rect.uibuttontype)
@@ -9,6 +9,15 @@ module Kernel
9
9
  end
10
10
  alias a adjust
11
11
 
12
+ def collapse(*args)
13
+ if self.nil?
14
+ super
15
+ else
16
+ SugarCube::Repl.collapse(*args)
17
+ end
18
+ end
19
+ alias coll collapse
20
+
12
21
  def tree(*args)
13
22
  if self.nil?
14
23
  super
@@ -4,6 +4,7 @@ module SugarCube
4
4
 
5
5
  @sugarcube_view = nil
6
6
  @sugarcube_items = nil
7
+ @sugarcube_collapsed_items = nil
7
8
  @sugarcube_restore = nil
8
9
 
9
10
  def adjust(view=nil)
@@ -23,6 +24,29 @@ module SugarCube
23
24
  end
24
25
  alias a adjust
25
26
 
27
+ def collapse(view)
28
+ if view.is_a? Fixnum
29
+ @sugarcube_items ||= SugarCube::Repl::build_tree(window, :subviews)
30
+ view = @sugarcube_items[view]
31
+ end
32
+
33
+ @sugarcube_collapsed_items ||= []
34
+ if @sugarcube_collapsed_items.include?(view)
35
+ @sugarcube_collapsed_items.delete(view)
36
+ else
37
+ @sugarcube_collapsed_items << view
38
+ end
39
+
40
+ retval = tree
41
+
42
+ if @sugarcube_collapsed_items
43
+ @sugarcube_collapsed_items.keep_if { |v| @sugarcube_items.include? v }
44
+ end
45
+
46
+ retval
47
+ end
48
+ alias coll collapse
49
+
26
50
  ##| FRAME
27
51
  def frame(f=nil)
28
52
  return unless check_sugarcube_view
@@ -237,6 +261,9 @@ module SugarCube
237
261
  end
238
262
 
239
263
  @sugarcube_items = SugarCube::Repl::build_tree(item, selector)
264
+ if @sugarcube_collapsed_items
265
+ @sugarcube_collapsed_items.keep_if { |v| @sugarcube_items.include? v }
266
+ end
240
267
  if self.respond_to? :draw_tree
241
268
  draw_tree(item, selector)
242
269
  else
@@ -261,12 +288,16 @@ module SugarCube
261
288
 
262
289
  if tab
263
290
  print tab
264
- if is_last
265
- print '`-- '
266
- tab += ' '
291
+ if @sugarcube_collapsed_items && @sugarcube_collapsed_items.include?(item)
292
+ print '<<< '
267
293
  else
268
- print '+-- '
269
- tab += '| '
294
+ if is_last
295
+ print '`-- '
296
+ tab += ' '
297
+ else
298
+ print '+-- '
299
+ tab += '| '
300
+ end
270
301
  end
271
302
  else
272
303
  print '. '
@@ -289,19 +320,22 @@ module SugarCube
289
320
  end
290
321
  items ||= []
291
322
 
292
- items.each_with_index { |subview, index|
293
- items_index += 1
294
- if self.respond_to? :draw_tree
295
- items_index = draw_tree(subview, selector, tab, index == items.length - 1, items_index)
296
- else
297
- items_index = SugarCube::Repl::draw_tree(subview, selector, tab, index == items.length - 1, items_index)
323
+ unless @sugarcube_collapsed_items && @sugarcube_collapsed_items.include?(item)
324
+ items.each_with_index do |subview, index|
325
+ items_index += 1
326
+ if self.respond_to? :draw_tree
327
+ items_index = draw_tree(subview, selector, tab, index == items.length - 1, items_index)
328
+ else
329
+ items_index = SugarCube::Repl::draw_tree(subview, selector, tab, index == items.length - 1, items_index)
330
+ end
298
331
  end
299
- }
332
+ end
300
333
 
301
334
  return items_index
302
335
  end
303
336
 
304
337
  def build_tree(item, selector)
338
+
305
339
  if selector.is_a? Proc
306
340
  items = selector.call(item)
307
341
  else
@@ -310,9 +344,11 @@ module SugarCube
310
344
  items ||= []
311
345
 
312
346
  ret = [item]
313
- items.each_with_index { |subview, index|
347
+ return ret if @sugarcube_collapsed_items && @sugarcube_collapsed_items.include?(item)
348
+
349
+ items.each_with_index do |subview, index|
314
350
  ret.concat SugarCube::Repl::build_tree(subview, selector)
315
- }
351
+ end
316
352
  ret
317
353
  end
318
354
 
@@ -8,12 +8,25 @@ class UIButton
8
8
  setTitle(value, forState: UIControlStateNormal)
9
9
  end
10
10
 
11
+ def titleColor
12
+ titleColorForState(UIControlStateNormal)
13
+ end
14
+ alias title_color titleColor
15
+
16
+ def setTitleColor(value)
17
+ value = value.uicolor if value.respond_to?(:uicolor)
18
+ setTitleColor(value, forState: UIControlStateNormal)
19
+ end
20
+ alias title_color= setTitleColor
21
+
11
22
  def attributedTitle
12
23
  attributedTitleForState(UIControlStateNormal)
13
24
  end
25
+ alias attributed_title attributedTitle
14
26
 
15
27
  def setAttributedTitle(value)
16
28
  setAttributedTitle(value, forState: UIControlStateNormal)
17
29
  end
30
+ alias attributed_title= setAttributedTitle
18
31
 
19
32
  end
@@ -1,3 +1,3 @@
1
1
  module SugarCube
2
- Version = '2.7.1'
2
+ Version = '2.8.0'
3
3
  end
@@ -19,11 +19,41 @@ describe UIButton do
19
19
  @subject.title.should == 'foo'
20
20
  end
21
21
 
22
+ it 'should set the titleColor using `titleColor=`' do
23
+ @subject.titleColor = UIColor.whiteColor
24
+ @subject.titleColorForState(UIControlStateNormal).should == UIColor.whiteColor
25
+ end
26
+
27
+ it 'should set the titleColor using `title_color=`' do
28
+ @subject.title_color = UIColor.whiteColor
29
+ @subject.titleColorForState(UIControlStateNormal).should == UIColor.whiteColor
30
+ end
31
+
32
+ it 'should set the titleColor using `setTitleColor()`' do
33
+ @subject.setTitleColor(UIColor.whiteColor)
34
+ @subject.titleColorForState(UIControlStateNormal).should == UIColor.whiteColor
35
+ end
36
+
37
+ it 'should get the titleColor' do
38
+ @subject.setTitleColor(UIColor.whiteColor, forState: UIControlStateNormal)
39
+ @subject.titleColor.should == UIColor.whiteColor
40
+ end
41
+
42
+ it 'should get the title_color' do
43
+ @subject.setTitleColor(UIColor.whiteColor, forState: UIControlStateNormal)
44
+ @subject.title_color.should == UIColor.whiteColor
45
+ end
46
+
22
47
  it 'should set the attributedTitle using `attributedTitle=`' do
23
48
  @subject.attributedTitle = 'foo'.attrd
24
49
  @subject.attributedTitleForState(UIControlStateNormal).should == 'foo'.attrd
25
50
  end
26
51
 
52
+ it 'should set the attributedTitle using `attributed_title=`' do
53
+ @subject.attributed_title = 'foo'.attrd
54
+ @subject.attributedTitleForState(UIControlStateNormal).should == 'foo'.attrd
55
+ end
56
+
27
57
  it 'should set the attributedTitle using `setAttributedTitle()`' do
28
58
  @subject.setAttributedTitle('foo'.attrd)
29
59
  @subject.attributedTitleForState(UIControlStateNormal).should == 'foo'.attrd
@@ -34,4 +64,9 @@ describe UIButton do
34
64
  @subject.attributedTitle.should == 'foo'.attrd
35
65
  end
36
66
 
67
+ it 'should get the attributed_title' do
68
+ @subject.setAttributedTitle('foo'.attrd, forState: UIControlStateNormal)
69
+ @subject.attributed_title.should == 'foo'.attrd
70
+ end
71
+
37
72
  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: 2.7.1
4
+ version: 2.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Colin T.A. Gray
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2014-09-30 00:00:00.000000000 Z
14
+ date: 2014-10-01 00:00:00.000000000 Z
15
15
  dependencies: []
16
16
  description: |
17
17
  == Description