sugarcube 3.3.3 → 3.3.4

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: 59c8482c83573e42f64f42c9aa90718298be515d
4
- data.tar.gz: 58b279d2a997169e4ef3bb3582376c581257d484
3
+ metadata.gz: 1f67b205769f1f470e8b590eb8b52767cd56a5b8
4
+ data.tar.gz: 2f24635340a8c3f5e22c73fe427b4ab6b2dfbe28
5
5
  SHA512:
6
- metadata.gz: 1f199aad09635d42e99d6a352f813f3db32d64c1d01cdec9da5e3878f0b1462d3648a92dc78519936fdc49a7dd6ebcc8610c457e97d8799bb0c844b805bee5a9
7
- data.tar.gz: c5a175dcf6a9c5502bc3d6757f9290b868ce52836aaafda2b4eba12cf5e79723d2a2b5f4dc034e59f4d214ccdc04a6b3eeb657e10be4ae14ff5ae510b8183eba
6
+ metadata.gz: b7db2394ee9acfd81c91048a737dcc2e4b2bbcc523979aadb75698f98c998ae6cbe63e2212663175bb5b55b516d7153959299b4cacc3c493e96979a6f8943c67
7
+ data.tar.gz: 11a4567ddff9a7c70b0fec35fc85da9e0ff7ea94ab9591b6202433c497b2125673379ccb9e357d4f3a40535f751b6eb78275b7e5fb6caeb8b0773d16b4db7052
data/README.md CHANGED
@@ -556,7 +556,7 @@ image.draw do |context|
556
556
  end
557
557
 
558
558
  # size
559
- image = Image.canvas(size: [10, 20])
559
+ image = UIImage.canvas(size: [10, 20])
560
560
  image.width # => 10
561
561
  image.height # => 20
562
562
  ```
@@ -1,23 +1,23 @@
1
1
  class NSString
2
2
 
3
3
  def bold(size=nil)
4
- font = :bold.uifont(size)
5
- nsattributedstring({ NSFontAttributeName => font })
4
+ nsattributedstring.bold(size)
6
5
  end
7
6
 
8
7
  def italic(size=nil)
9
- font = :italic.uifont(size)
10
- nsattributedstring({ NSFontAttributeName => font })
8
+ nsattributedstring.italic(size)
11
9
  end
12
10
 
13
11
  def monospace(size=nil)
14
- font = :monospace.uifont(size)
15
- nsattributedstring({ NSFontAttributeName => font })
12
+ nsattributedstring.monospace(size)
16
13
  end
17
14
 
18
15
  def underline(underline_style=nil)
19
- underline_style ||= NSUnderlineStyleSingle
20
- nsattributedstring({ NSUnderlineStyleAttributeName => underline_style })
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
- font = :bold.uifont(size)
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
- font = :italic.uifont(size)
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
- with_attributes({ NSFontAttributeName => value.uifont })
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
- with_attributes({ NSForegroundColorAttributeName => value.uicolor })
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
- with_attributes({ NSBackgroundColorAttributeName => value.uicolor })
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
- with_attributes({ NSStrokeColorAttributeName => value.uicolor })
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
- font = :bold.nsfont(size)
5
- nsattributedstring({ NSFontAttributeName => font })
4
+ nsattributedstring.bold(size)
6
5
  end
7
6
 
8
7
  def monospace(size=nil)
9
- font = :monospace.nsfont(size)
10
- nsattributedstring({ NSFontAttributeName => font })
8
+ nsattributedstring.monospace(size)
11
9
  end
12
10
 
13
11
  def underline(underline_style=nil)
14
- underline_style ||= NSSingleUnderlineStyle
15
- nsattributedstring({ NSUnderlineStyleAttributeName => underline_style })
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
- font = :bold.nsfont(size)
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
- with_attributes({ NSFontAttributeName => value.nsfont })
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
- with_attributes({ NSForegroundColorAttributeName => value.nscolor })
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
- with_attributes({ NSBackgroundColorAttributeName => value.nscolor })
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
- with_attributes({ NSStrokeColorAttributeName => value.nscolor })
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)
@@ -1,3 +1,3 @@
1
1
  module SugarCube
2
- Version = '3.3.3'
2
+ Version = '3.3.4'
3
3
  end
@@ -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.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-12 00:00:00.000000000 Z
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: []