vidibus-core_extensions 0.3.11 → 0.3.12
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -1
- data/VERSION +1 -1
- data/lib/vidibus/core_extensions/string.rb +10 -7
- data/spec/vidibus/core_extensions/array_spec.rb +1 -1
- data/spec/vidibus/core_extensions/file_utils_spec.rb +1 -1
- data/spec/vidibus/core_extensions/hash_spec.rb +1 -1
- data/spec/vidibus/core_extensions/object_spec.rb +1 -1
- data/spec/vidibus/core_extensions/string_spec.rb +9 -5
- data/vidibus-core_extensions.gemspec +2 -2
- metadata +4 -4
data/README.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.12
|
@@ -4,7 +4,7 @@ class String
|
|
4
4
|
# Map of latin chars and their representations as unicode chars.
|
5
5
|
LATIN_MAP = {
|
6
6
|
"A" => %w[À Á Â Ã Å Ą Ā],
|
7
|
-
"a" => %w[
|
7
|
+
"a" => %w[à á â ã å ą ả ã ạ ă ắ ằ ẳ ẵ ặ â ấ ầ ẩ ẫ ậ ā],
|
8
8
|
"AE" => %w[Ä Æ Ǽ],
|
9
9
|
"ae" => %w[ä æ ǽ],
|
10
10
|
"C" => %w[Ç Č Ć Ĉ],
|
@@ -45,12 +45,13 @@ class String
|
|
45
45
|
|
46
46
|
# Replaces non-latin chars, leaves some special ones.
|
47
47
|
def latinize
|
48
|
-
c =
|
48
|
+
c = dup
|
49
49
|
for char, map in LATIN_MAP
|
50
|
-
c.gsub!(/
|
50
|
+
c.gsub!(/[#{map.join}]/mu, char)
|
51
51
|
end
|
52
|
-
c.gsub(/[^a-
|
53
|
-
|
52
|
+
c.gsub!(/[^a-zA-Z0-9\.\,\|\?\!\:;"'=\+\-_]+/mu, " ")
|
53
|
+
c.gsub!(/\s+/, " ")
|
54
|
+
c
|
54
55
|
end
|
55
56
|
|
56
57
|
# Returns a string that may be used as permalink
|
@@ -100,11 +101,13 @@ class String
|
|
100
101
|
#
|
101
102
|
def snip(length, ellipsis = "…")
|
102
103
|
return self if self.empty?
|
103
|
-
|
104
|
+
str = dup
|
105
|
+
str.strip!
|
106
|
+
str.gsub(/^(.{#{length.to_i-1}})(.)([\w]*)(.*)/m) do
|
104
107
|
if $2 == " "
|
105
108
|
"#{$1}#{ellipsis}"
|
106
109
|
elsif $3.empty? and $4.empty?
|
107
|
-
|
110
|
+
str
|
108
111
|
else
|
109
112
|
"#{$1}#{$2}#{$3}#{ellipsis}"
|
110
113
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
require "spec_helper"
|
3
3
|
|
4
|
-
describe "
|
4
|
+
describe "String" do
|
5
5
|
describe "::LATIN_MAP" do
|
6
6
|
it "should contain a Hash map" do
|
7
7
|
String::LATIN_MAP.should be_a(Hash)
|
@@ -89,14 +89,18 @@ describe "Vidibus::CoreExtensions::String" do
|
|
89
89
|
"O Brother, Where Art Thou?".snip(26).should eql("O Brother, Where Art Thou?")
|
90
90
|
end
|
91
91
|
|
92
|
-
it "should
|
93
|
-
"O Brother,
|
92
|
+
it "should strip white space between words" do
|
93
|
+
"O Brother, Where Art Thou?".snip(11).should eql("O Brother,…")
|
94
94
|
end
|
95
95
|
|
96
|
-
it "should
|
97
|
-
"O Brother,
|
96
|
+
it "should strip trailing white space" do
|
97
|
+
"O Brother, Where Art Thou? ".snip(26).should eql("O Brother, Where Art Thou?")
|
98
98
|
end
|
99
99
|
|
100
|
+
it "should strip leading white space" do
|
101
|
+
" O Brother, Where Art Thou?".snip(26).should eql("O Brother, Where Art Thou?")
|
102
|
+
end
|
103
|
+
|
100
104
|
it "should handle content with backets" do
|
101
105
|
"O Brother (Or Sister), Where Art Thou?".snip(20).should eql("O Brother (Or Sister…")
|
102
106
|
end
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{vidibus-core_extensions}
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.12"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Andre Pankratz"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-11-16}
|
13
13
|
s.description = %q{Provides some extensions to the ruby core.}
|
14
14
|
s.email = %q{andre@vidibus.com}
|
15
15
|
s.extra_rdoc_files = [
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vidibus-core_extensions
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 12
|
10
|
+
version: 0.3.12
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Andre Pankratz
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-
|
18
|
+
date: 2010-11-16 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|