sugarcube 3.3.3 → 3.3.4
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1f67b205769f1f470e8b590eb8b52767cd56a5b8
|
4
|
+
data.tar.gz: 2f24635340a8c3f5e22c73fe427b4ab6b2dfbe28
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b7db2394ee9acfd81c91048a737dcc2e4b2bbcc523979aadb75698f98c998ae6cbe63e2212663175bb5b55b516d7153959299b4cacc3c493e96979a6f8943c67
|
7
|
+
data.tar.gz: 11a4567ddff9a7c70b0fec35fc85da9e0ff7ea94ab9591b6202433c497b2125673379ccb9e357d4f3a40535f751b6eb78275b7e5fb6caeb8b0773d16b4db7052
|
data/README.md
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
class NSString
|
2
2
|
|
3
3
|
def bold(size=nil)
|
4
|
-
|
5
|
-
nsattributedstring({ NSFontAttributeName => font })
|
4
|
+
nsattributedstring.bold(size)
|
6
5
|
end
|
7
6
|
|
8
7
|
def italic(size=nil)
|
9
|
-
|
10
|
-
nsattributedstring({ NSFontAttributeName => font })
|
8
|
+
nsattributedstring.italic(size)
|
11
9
|
end
|
12
10
|
|
13
11
|
def monospace(size=nil)
|
14
|
-
|
15
|
-
nsattributedstring({ NSFontAttributeName => font })
|
12
|
+
nsattributedstring.monospace(size)
|
16
13
|
end
|
17
14
|
|
18
15
|
def underline(underline_style=nil)
|
19
|
-
underline_style
|
20
|
-
|
16
|
+
if underline_style
|
17
|
+
nsattributedstring.underline_style(underline_style)
|
18
|
+
else
|
19
|
+
nsattributedstring.underline
|
20
|
+
end
|
21
21
|
end
|
22
22
|
|
23
23
|
end
|
@@ -45,17 +45,26 @@ class NSAttributedString
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def bold(size=nil)
|
48
|
-
|
48
|
+
size ||= UIFont.systemFontSize
|
49
|
+
font = UIFont.boldSystemFontOfSize(size)
|
49
50
|
self.font(font)
|
50
51
|
end
|
51
52
|
|
52
53
|
def italic(size=nil)
|
53
|
-
|
54
|
+
size ||= UIFont.systemFontSize
|
55
|
+
font = UIFont.italicSystemFontOfSize(size)
|
56
|
+
self.font(font)
|
57
|
+
end
|
58
|
+
|
59
|
+
def monospace(size=nil)
|
60
|
+
size ||= UIFont.systemFontSize
|
61
|
+
font = UIFont.fontWithName('Courier New', size: size)
|
54
62
|
self.font(font)
|
55
63
|
end
|
56
64
|
|
57
65
|
def font(value)
|
58
|
-
|
66
|
+
value = value.uifont if value.respond_to?(:uifont)
|
67
|
+
with_attributes({ NSFontAttributeName => value })
|
59
68
|
end
|
60
69
|
|
61
70
|
def underline
|
@@ -67,17 +76,20 @@ class NSAttributedString
|
|
67
76
|
end
|
68
77
|
|
69
78
|
def foreground_color(value)
|
70
|
-
|
79
|
+
value = value.uicolor if value.respond_to?(:uicolor)
|
80
|
+
with_attributes({ NSForegroundColorAttributeName => value })
|
71
81
|
end
|
72
82
|
alias color foreground_color
|
73
83
|
|
74
84
|
def background_color(value)
|
75
|
-
|
85
|
+
value = value.uicolor if value.respond_to?(:uicolor)
|
86
|
+
with_attributes({ NSBackgroundColorAttributeName => value })
|
76
87
|
end
|
77
88
|
alias bg_color background_color
|
78
89
|
|
79
90
|
def stroke_color(value)
|
80
|
-
|
91
|
+
value = value.uicolor if value.respond_to?(:uicolor)
|
92
|
+
with_attributes({ NSStrokeColorAttributeName => value })
|
81
93
|
end
|
82
94
|
|
83
95
|
def superscript(amount=nil)
|
@@ -1,18 +1,19 @@
|
|
1
1
|
class NSString
|
2
2
|
|
3
3
|
def bold(size=nil)
|
4
|
-
|
5
|
-
nsattributedstring({ NSFontAttributeName => font })
|
4
|
+
nsattributedstring.bold(size)
|
6
5
|
end
|
7
6
|
|
8
7
|
def monospace(size=nil)
|
9
|
-
|
10
|
-
nsattributedstring({ NSFontAttributeName => font })
|
8
|
+
nsattributedstring.monospace(size)
|
11
9
|
end
|
12
10
|
|
13
11
|
def underline(underline_style=nil)
|
14
|
-
underline_style
|
15
|
-
|
12
|
+
if underline_style
|
13
|
+
nsattributedstring.underline_style(underline_style)
|
14
|
+
else
|
15
|
+
nsattributedstring.underline
|
16
|
+
end
|
16
17
|
end
|
17
18
|
|
18
19
|
end
|
@@ -26,12 +27,20 @@ class NSAttributedString
|
|
26
27
|
end
|
27
28
|
|
28
29
|
def bold(size=nil)
|
29
|
-
|
30
|
+
size ||= NSFont.systemFontSize
|
31
|
+
font = NSFont.boldSystemFontOfSize(size)
|
30
32
|
self.font(font)
|
31
33
|
end
|
32
34
|
|
33
35
|
def font(value)
|
34
|
-
|
36
|
+
value = value.nsfont if value.respond_to?(:nsfont)
|
37
|
+
with_attributes({ NSFontAttributeName => value })
|
38
|
+
end
|
39
|
+
|
40
|
+
def monospace(size=nil)
|
41
|
+
size ||= NSFont.systemFontSize
|
42
|
+
font = NSFont.fontWithName('Courier New', size: size)
|
43
|
+
self.font({ NSFontAttributeName => font })
|
35
44
|
end
|
36
45
|
|
37
46
|
def underline
|
@@ -43,17 +52,20 @@ class NSAttributedString
|
|
43
52
|
end
|
44
53
|
|
45
54
|
def foreground_color(value)
|
46
|
-
|
55
|
+
value = value.nscolor if value.respond_to?(:nscolor)
|
56
|
+
with_attributes({ NSForegroundColorAttributeName => value })
|
47
57
|
end
|
48
58
|
alias color foreground_color
|
49
59
|
|
50
60
|
def background_color(value)
|
51
|
-
|
61
|
+
value = value.nscolor if value.respond_to?(:nscolor)
|
62
|
+
with_attributes({ NSBackgroundColorAttributeName => value })
|
52
63
|
end
|
53
64
|
alias bg_color background_color
|
54
65
|
|
55
66
|
def stroke_color(value)
|
56
|
-
|
67
|
+
value = value.nscolor if value.respond_to?(:nscolor)
|
68
|
+
with_attributes({ NSStrokeColorAttributeName => value })
|
57
69
|
end
|
58
70
|
|
59
71
|
def superscript(amount=nil)
|
data/lib/version.rb
CHANGED
@@ -28,18 +28,26 @@ describe 'NSAttributeString' do
|
|
28
28
|
end
|
29
29
|
|
30
30
|
it 'should convert html' do
|
31
|
+
plain_subject = 'Plain'.attributed_html
|
31
32
|
bold_subject = '<b>Bold</b>'.attributed_html
|
32
33
|
emphasis_subject = '<em>Emphasis</em>'.attributed_html
|
33
34
|
underline_subject = '<u>Underline</u>'.attributed_html
|
34
35
|
|
36
|
+
plain_subject.should.be.kind_of(NSAttributedString)
|
35
37
|
bold_subject.should.be.kind_of(NSAttributedString)
|
36
38
|
emphasis_subject.should.be.kind_of(NSAttributedString)
|
37
39
|
underline_subject.should.be.kind_of(NSAttributedString)
|
38
40
|
|
41
|
+
plain_font = plain_subject.attributesAtIndex(0, effectiveRange:nil)['NSFont']
|
42
|
+
|
39
43
|
# Commented out tests don't work because :bold.uifont isn't the same font instance as the html converter uses.
|
40
44
|
# bold_subject.attributesAtIndex(0, effectiveRange:nil)['NSFont'].should == :bold.uifont
|
41
45
|
# emphasis_subject.attributesAtIndex(0, effectiveRange:nil)['NSFont'].should == :italic.uifont
|
42
46
|
underline_subject.attributesAtIndex(0, effectiveRange:nil)['NSUnderline'].should == NSUnderlineStyleSingle
|
47
|
+
|
48
|
+
# we can at least make sure the font is not the default
|
49
|
+
bold_subject.attributesAtIndex(0, effectiveRange:nil)['NSFont'].should != plain_font
|
50
|
+
emphasis_subject.attributesAtIndex(0, effectiveRange:nil)['NSFont'].should != plain_font
|
43
51
|
end
|
44
52
|
|
45
53
|
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: 3.3.
|
4
|
+
version: 3.3.4
|
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-03-
|
15
|
+
date: 2015-03-18 00:00:00.000000000 Z
|
16
16
|
dependencies: []
|
17
17
|
description: |
|
18
18
|
== Description
|
@@ -306,12 +306,12 @@ require_paths:
|
|
306
306
|
- lib
|
307
307
|
required_ruby_version: !ruby/object:Gem::Requirement
|
308
308
|
requirements:
|
309
|
-
- -
|
309
|
+
- - '>='
|
310
310
|
- !ruby/object:Gem::Version
|
311
311
|
version: '0'
|
312
312
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
313
313
|
requirements:
|
314
|
-
- -
|
314
|
+
- - '>='
|
315
315
|
- !ruby/object:Gem::Version
|
316
316
|
version: '0'
|
317
317
|
requirements: []
|