sugarcube 3.0.6 → 3.0.7
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: c4433f242c29157de91a82193c803bf2bbe5b62c
|
4
|
+
data.tar.gz: c92a36e4e77fac55689af4795caf4b8e04393246
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a07af0dbc818c68088334d6d719edc4c578491c8284d2e9560398eb561ef9da38848b9de7b9e5f58ca0f374e029eaf9362ad3e0fdd33d8abd559e7c2386cf442
|
7
|
+
data.tar.gz: 976d1445e52230c5c73f840e8d406fea4c1523fec3137713eee6037c34d215c576c997f82aa14ab40a3c4f720decb404b34683f5e4feee69c15cb39f27595954
|
@@ -111,6 +111,28 @@ class NSAttributedString
|
|
111
111
|
string
|
112
112
|
end
|
113
113
|
|
114
|
+
def empty?
|
115
|
+
self.length == 0
|
116
|
+
end
|
117
|
+
|
118
|
+
def strip
|
119
|
+
# Trim leading whitespace and newlines.
|
120
|
+
charSet = NSCharacterSet.whitespaceAndNewlineCharacterSet
|
121
|
+
range = self.string.rangeOfCharacterFromSet(charSet)
|
122
|
+
while (range.length != 0 && range.location == 0)
|
123
|
+
self.replaceCharactersInRange(range, withString:"")
|
124
|
+
range = self.string.rangeOfCharacterFromSet(charSet)
|
125
|
+
end
|
126
|
+
|
127
|
+
# Trim trailing whitespace and newlines.
|
128
|
+
range = self.string.rangeOfCharacterFromSet(charSet, options:NSBackwardsSearch)
|
129
|
+
while (range.length != 0 && NSMaxRange(range) == self.length)
|
130
|
+
self.replaceCharactersInRange(range, withString:"")
|
131
|
+
range = self.string.rangeOfCharacterFromSet(charSet, options:NSBackwardsSearch)
|
132
|
+
end
|
133
|
+
self
|
134
|
+
end
|
135
|
+
|
114
136
|
end
|
115
137
|
|
116
138
|
|
data/lib/version.rb
CHANGED
@@ -37,6 +37,24 @@ describe 'NSAttributeString' do
|
|
37
37
|
'test'.attrd.vertical_glyph_form(1).should.have_string_attributes({ NSVerticalGlyphFormAttributeName => 1 })
|
38
38
|
end
|
39
39
|
|
40
|
+
it 'should have have `empty?`' do
|
41
|
+
'test'.attrd.empty?.should == false
|
42
|
+
''.attrd.empty?.should == true
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'should have `strip`' do
|
46
|
+
'test '.attrd.strip.should == 'test'.attrd
|
47
|
+
' test '.attrd.strip.should == 'test'.attrd
|
48
|
+
' test'.attrd.strip.should == 'test'.attrd
|
49
|
+
"\ntest".attrd.strip.should == 'test'.attrd
|
50
|
+
"\n test".attrd.strip.should == 'test'.attrd
|
51
|
+
"\n test \n".attrd.strip.should == 'test'.attrd
|
52
|
+
"\n test \n".attrd.strip.should == 'test'.attrd
|
53
|
+
"test ".attrd.strip.should == 'test'.attrd
|
54
|
+
"test\n ".attrd.strip.should == 'test'.attrd
|
55
|
+
" \n test".attrd.strip.should == 'test'.attrd
|
56
|
+
end
|
57
|
+
|
40
58
|
end
|
41
59
|
|
42
60
|
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.0.
|
4
|
+
version: 3.0.7
|
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: 2015-01-
|
14
|
+
date: 2015-01-18 00:00:00.000000000 Z
|
15
15
|
dependencies: []
|
16
16
|
description: |
|
17
17
|
== Description
|