vidibus-core_extensions 0.3.11 → 0.3.12

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.
data/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = vidibus-core_extensions
2
2
 
3
- This gem is part of the open source SOA framework Vidibus: http://www.vidibus.org
3
+ This gem is part of the open source SOA framework Vidibus: http://vidibus.org
4
4
 
5
5
  It provides some extensions to the ruby core.
6
6
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.11
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 = clone
48
+ c = dup
49
49
  for char, map in LATIN_MAP
50
- c.gsub!(/(#{map.join('|')})/, char)
50
+ c.gsub!(/[#{map.join}]/mu, char)
51
51
  end
52
- c.gsub(/[^a-z0-9\.\,\|\?\!\:;"'=\+\-_]+/i, " ").
53
- gsub(/ {2,}/, " ")
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
- self.gsub(/^(.{#{length.to_i-1}})(.)([\w]*)(.*)/m) do
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
- self
110
+ str
108
111
  else
109
112
  "#{$1}#{$2}#{$3}#{ellipsis}"
110
113
  end
@@ -1,6 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
- describe "Vidibus::CoreExtensions::Array" do
3
+ describe "Array" do
4
4
  describe "#flatten_once" do
5
5
  it "should return array" do
6
6
  array = ['go', 'for', 'it']
@@ -1,6 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
- describe "Vidibus::CoreExtensions::FileUtils" do
3
+ describe "FileUtils" do
4
4
  describe ".remove_dir_r" do
5
5
  let(:tmpdir) { File.join(File.dirname(__FILE__), "..", "..", "tmp") }
6
6
  before { FileUtils.mkdir_p("#{tmpdir}/some/test/dir")}
@@ -1,6 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
- describe "Vidibus::CoreExtensions::Hash" do
3
+ describe "Hash" do
4
4
  describe "#to_uri" do
5
5
  it "should join params with '&'" do
6
6
  hash = {:some => "value", :another => "thing"}
@@ -1,6 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
- describe "Vidibus::CoreExtensions::Object" do
3
+ describe "Object" do
4
4
  describe "#try!" do
5
5
  let(:dog) do
6
6
  Struct.new("Dog", :out) unless defined?(Struct::Dog)
@@ -1,7 +1,7 @@
1
1
  # encoding: utf-8
2
2
  require "spec_helper"
3
3
 
4
- describe "Vidibus::CoreExtensions::String" do
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 return whole string if it equals length" do
93
- "O Brother, Where Art Thou?".snip(11).should eql("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 trim white space" do
97
- "O Brother, Where Art Thou?".snip(11).should eql("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.11"
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-10-29}
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: 5
4
+ hash: 11
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 11
10
- version: 0.3.11
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-10-29 00:00:00 +02:00
18
+ date: 2010-11-16 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies: []
21
21