sugarcube 3.3.1 → 3.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/lib/cocoa/sugarcube-nsdate/nsdate_delta.rb +13 -13
- data/lib/ios/sugarcube-factories/uitableviewcell.rb +53 -24
- data/lib/ios/sugarcube-image/uiimage.rb +1 -1
- data/lib/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b93b8cbedc130c019d2eaf293a07337b5a041b10
|
4
|
+
data.tar.gz: 04d121961d44ba27a8258fc3844d9dd2a47cfd72
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 372c7d62dcd616471d92ff970278060813113569faf9a34040dea78631f39fccaa48d8b9b13ec0e3de1e035f81435f4e7c42134da90cf7e496456f693eb98efb
|
7
|
+
data.tar.gz: 496c37d5f0760e84024e6c5d3a84b79cf586e21bb93c005a6205df5c2d10b1f3309387ec8ef727a5efdf74d9af47c78259ebe3696dd4eb15aeb4daf632e787bb
|
data/README.md
CHANGED
@@ -52,6 +52,15 @@ diligent about adding Yard documentation, which is available here:
|
|
52
52
|
|
53
53
|
[documentation]: http://rubydoc.info/gems/sugarcube/latest
|
54
54
|
|
55
|
+
Versioning
|
56
|
+
==========
|
57
|
+
|
58
|
+
SugarCube uses FerVer: https://github.com/jonathanong/ferver. This means that
|
59
|
+
minor breaking changes occur in minor version bumps, and sometimes a
|
60
|
+
non-breaking change occures in the major version (like when we added OS X
|
61
|
+
support).
|
62
|
+
|
63
|
+
|
55
64
|
Installation
|
56
65
|
============
|
57
66
|
|
@@ -19,8 +19,8 @@ class NSDate
|
|
19
19
|
|
20
20
|
delta = s
|
21
21
|
# todo: leap second adjustment? can leap seconds be detected?
|
22
|
-
delta += mi
|
23
|
-
delta += h
|
22
|
+
delta += mi * 60
|
23
|
+
delta += h * 3600
|
24
24
|
|
25
25
|
return_date = self + delta
|
26
26
|
|
@@ -42,17 +42,17 @@ class NSDate
|
|
42
42
|
if mo > 0
|
43
43
|
mo.times do
|
44
44
|
delta = return_date.days_in_month
|
45
|
-
return_date += delta
|
45
|
+
return_date += delta * 3600 * 24
|
46
46
|
|
47
47
|
# if the day_of_month is wrong, it must be because we either added PAST
|
48
48
|
# the correct month (so roll back), or because we WERE rolled back and
|
49
49
|
# when we moved forward a month, we were left back at the smaller day.
|
50
50
|
if correct_day_of_month
|
51
51
|
if return_date.day < 28
|
52
|
-
return_date -= return_date.day
|
52
|
+
return_date -= return_date.day * 3600 * 24
|
53
53
|
elsif return_date.day < correct_day_of_month
|
54
54
|
fix = correct_day_of_month > return_date.days_in_month ? return_date.days_in_month : correct_day_of_month
|
55
|
-
return_date += (fix - return_date.day)
|
55
|
+
return_date += (fix - return_date.day) * 3600 * 24
|
56
56
|
end
|
57
57
|
end
|
58
58
|
end
|
@@ -63,15 +63,15 @@ class NSDate
|
|
63
63
|
# hour short of "last month" and so you end up with THIS month. there
|
64
64
|
# is NEVER a case when subtracting return_date.day+1 days is NOT
|
65
65
|
# "previous month". dates. :-| f-em.
|
66
|
-
delta = (return_date - (return_date.day+1)
|
67
|
-
return_date -= delta
|
66
|
+
delta = (return_date - (return_date.day+1) * 3600 * 24).days_in_month
|
67
|
+
return_date -= delta * 3600 * 24
|
68
68
|
# same correction as above
|
69
69
|
if correct_day_of_month
|
70
70
|
if return_date.day < 28
|
71
|
-
return_date -= return_date.day
|
71
|
+
return_date -= return_date.day * 3600 * 24
|
72
72
|
elsif return_date.day < correct_day_of_month
|
73
73
|
fix = correct_day_of_month > return_date.days_in_month ? return_date.days_in_month : correct_day_of_month
|
74
|
-
return_date += (fix - return_date.day)
|
74
|
+
return_date += (fix - return_date.day) * 3600 * 24
|
75
75
|
end
|
76
76
|
end
|
77
77
|
end
|
@@ -79,8 +79,8 @@ class NSDate
|
|
79
79
|
end
|
80
80
|
|
81
81
|
delta = 0
|
82
|
-
delta += d
|
83
|
-
delta += w
|
82
|
+
delta += d * 3600 * 24
|
83
|
+
delta += w * 3600 * 24 * 7
|
84
84
|
return_date += delta
|
85
85
|
|
86
86
|
# DST adjustment, unless minutes, hours, or seconds were specified.
|
@@ -98,9 +98,9 @@ class NSDate
|
|
98
98
|
# Time.at(3/10/2012).delta(hours:25) # => 2012-03-11 18:00:00 -0600
|
99
99
|
unless return_date.dst? == is_dst or is_very_specific
|
100
100
|
if is_dst
|
101
|
-
return_date +=
|
101
|
+
return_date += 3600
|
102
102
|
else
|
103
|
-
return_date -=
|
103
|
+
return_date -= 3600
|
104
104
|
end
|
105
105
|
end
|
106
106
|
|
@@ -4,31 +4,59 @@ class UITableViewCell
|
|
4
4
|
class << self
|
5
5
|
|
6
6
|
# returns a cell in the default style, with reuse identifier
|
7
|
-
# `
|
8
|
-
#
|
9
|
-
|
10
|
-
|
7
|
+
# `reuse_identifier`. Supported options are :accessory, :text, :detail,
|
8
|
+
# :image, and :selection_style.
|
9
|
+
# Valid values for `:accessory`:
|
10
|
+
# :none, :disclosure, :disclosureindicator, :detail,
|
11
|
+
# :detaildisclosurebutton, :checkmark
|
12
|
+
# or any UITableViewCellAccessory constant
|
13
|
+
# Valid values for `:selection_style`:
|
14
|
+
# :none, :blue, :gray
|
15
|
+
# or any UITableViewCellSelectionStyle constant
|
16
|
+
def default(reuse_identifier, options={})
|
17
|
+
return sugarcube_cell_factory(reuse_identifier, :default, options)
|
11
18
|
end
|
12
19
|
|
13
20
|
# returns a cell in the value1 style, with reuse identifier
|
14
|
-
# `
|
15
|
-
#
|
16
|
-
|
17
|
-
|
21
|
+
# `reuse_identifier`. Supported options are :accessory, :text, :detail,
|
22
|
+
# :image, and :selection_style.
|
23
|
+
# Valid values for `:accessory`:
|
24
|
+
# :none, :disclosure, :disclosureindicator, :detail,
|
25
|
+
# :detaildisclosurebutton, :checkmark
|
26
|
+
# or any UITableViewCellAccessory constant
|
27
|
+
# Valid values for `:selection_style`:
|
28
|
+
# :none, :blue, :gray
|
29
|
+
# or any UITableViewCellSelectionStyle constant
|
30
|
+
def value1(reuse_identifier, options={})
|
31
|
+
return sugarcube_cell_factory(reuse_identifier, :value1, options)
|
18
32
|
end
|
19
33
|
|
20
34
|
# returns a cell in the value2 style, with reuse identifier
|
21
|
-
# `
|
22
|
-
#
|
23
|
-
|
24
|
-
|
35
|
+
# `reuse_identifier`. Supported options are :accessory, :text, :detail,
|
36
|
+
# :image, and :selection_style.
|
37
|
+
# Valid values for `:accessory`:
|
38
|
+
# :none, :disclosure, :disclosureindicator, :detail,
|
39
|
+
# :detaildisclosurebutton, :checkmark
|
40
|
+
# or any UITableViewCellAccessory constant
|
41
|
+
# Valid values for `:selection_style`:
|
42
|
+
# :none, :blue, :gray
|
43
|
+
# or any UITableViewCellSelectionStyle constant
|
44
|
+
def value2(reuse_identifier, options={})
|
45
|
+
return sugarcube_cell_factory(reuse_identifier, :value2, options)
|
25
46
|
end
|
26
47
|
|
27
48
|
# returns a cell in the subtitle style, with reuse identifier
|
28
|
-
# `
|
29
|
-
#
|
30
|
-
|
31
|
-
|
49
|
+
# `reuse_identifier`. Supported options are :accessory, :text, :detail,
|
50
|
+
# :image, and :selection_style.
|
51
|
+
# Valid values for `:accessory`:
|
52
|
+
# :none, :disclosure, :disclosureindicator, :detail,
|
53
|
+
# :detaildisclosurebutton, :checkmark
|
54
|
+
# or any UITableViewCellAccessory constant
|
55
|
+
# Valid values for `:selection_style`:
|
56
|
+
# :none, :blue, :gray
|
57
|
+
# or any UITableViewCellSelectionStyle constant
|
58
|
+
def subtitle(reuse_identifier, options={})
|
59
|
+
return sugarcube_cell_factory(reuse_identifier, :subtitle, options)
|
32
60
|
end
|
33
61
|
|
34
62
|
private
|
@@ -41,9 +69,10 @@ private
|
|
41
69
|
# text - textLabel.text content
|
42
70
|
# detail - detailTextLabel.text content
|
43
71
|
# selection - selectionStyle
|
44
|
-
def sugarcube_cell_factory(
|
72
|
+
def sugarcube_cell_factory(reuse_identifier, cell_style, options)
|
73
|
+
cell_style_name = cell_style
|
45
74
|
cell_style = cell_style.uitablecellstyle if cell_style.respond_to?(:uitablecellstyle)
|
46
|
-
cell = UITableViewCell.alloc.initWithStyle(cell_style, reuseIdentifier:
|
75
|
+
cell = UITableViewCell.alloc.initWithStyle(cell_style, reuseIdentifier: reuse_identifier)
|
47
76
|
|
48
77
|
if options[:accessory]
|
49
78
|
accessory = options[:accessory]
|
@@ -51,14 +80,14 @@ private
|
|
51
80
|
cell.accessoryType = accessory
|
52
81
|
end
|
53
82
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
cell.selectionStyle =
|
83
|
+
selection_style = options[:selection] || options[:selection_style]
|
84
|
+
if selection_style
|
85
|
+
selection_style = selection_style.uitablecellselectionstyle if selection_style.respond_to?(:uitablecellselectionstyle)
|
86
|
+
cell.selectionStyle = selection_style
|
58
87
|
end
|
59
88
|
|
60
89
|
if options[:image]
|
61
|
-
raise "cell type #{
|
90
|
+
raise "cell type #{cell_style_name} does not support imageView" unless cell.imageView
|
62
91
|
image = options[:image]
|
63
92
|
cell.imageView.image = image && image.uiimage
|
64
93
|
end
|
@@ -68,7 +97,7 @@ private
|
|
68
97
|
end
|
69
98
|
|
70
99
|
if options[:detail]
|
71
|
-
raise "cell type #{
|
100
|
+
raise "cell type #{cell_style_name} does not support detailTextLabel" unless cell.detailTextLabel
|
72
101
|
cell.detailTextLabel.text = options[:detail]
|
73
102
|
end
|
74
103
|
|
@@ -349,7 +349,7 @@ class UIImage
|
|
349
349
|
# this is actually the interesting part:
|
350
350
|
new_image = self.canvas(size: new_size) do |context|
|
351
351
|
if background
|
352
|
-
background = background.uicolor
|
352
|
+
background = background.uicolor unless background.is_a?(UIColor)
|
353
353
|
background.setFill
|
354
354
|
CGContextAddRect(context, [[0, 0], new_size])
|
355
355
|
CGContextDrawPath(context, KCGPathFill)
|
data/lib/version.rb
CHANGED
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.
|
4
|
+
version: 3.3.2
|
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-
|
15
|
+
date: 2015-02-25 00:00:00.000000000 Z
|
16
16
|
dependencies: []
|
17
17
|
description: |
|
18
18
|
== Description
|