webget-string_extensions 1.0.0
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/lib/string_extensions.rb +27 -0
- data/test/unit/string_extensions_test.rb +19 -0
- metadata +53 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
# = String Extensions
|
2
|
+
#
|
3
|
+
# Author:: Joel Parker Henderson, joelparkerhenderson@gmail.com
|
4
|
+
# Copyright:: Copyright (c) 2006-2008 Joel Parker Henderson
|
5
|
+
# License:: CreativeCommons License, Non-commercial Share Alike
|
6
|
+
# License:: LGPL, GNU Lesser General Public License
|
7
|
+
#
|
8
|
+
# Ruby String base class extensions
|
9
|
+
#
|
10
|
+
##
|
11
|
+
|
12
|
+
class String
|
13
|
+
|
14
|
+
def words
|
15
|
+
split(/\W*\b\W*/)
|
16
|
+
end
|
17
|
+
|
18
|
+
def split_tab
|
19
|
+
split(/\t/)
|
20
|
+
end
|
21
|
+
|
22
|
+
def capitalize_words
|
23
|
+
split(/\b/).map{|x| x.capitalize }.join
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'string_extensions'
|
3
|
+
|
4
|
+
class StringExtensionsTest < Test::Unit::TestCase
|
5
|
+
|
6
|
+
def test_words
|
7
|
+
assert_equal(['foo','goo','hoo'],"foo goo hoo".words)
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_split_tab
|
11
|
+
assert_equal(['foo','goo','hoo'],"foo\tgoo\thoo".split_tab)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_capitalize_words
|
15
|
+
assert_equal("Foo Goo Hoo","foo goo hoo".capitalize_words)
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
metadata
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: webget-string_extensions
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- WebGet
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-02-05 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: webget@webget.com
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files: []
|
23
|
+
|
24
|
+
files:
|
25
|
+
- lib/string_extensions.rb
|
26
|
+
has_rdoc: true
|
27
|
+
homepage: http://webget.com/
|
28
|
+
post_install_message:
|
29
|
+
rdoc_options: []
|
30
|
+
|
31
|
+
require_paths:
|
32
|
+
- lib
|
33
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
34
|
+
requirements:
|
35
|
+
- - ">="
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: "0"
|
38
|
+
version:
|
39
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
requirements: []
|
46
|
+
|
47
|
+
rubyforge_project:
|
48
|
+
rubygems_version: 1.2.0
|
49
|
+
signing_key:
|
50
|
+
specification_version: 2
|
51
|
+
summary: Ruby String base class extensions
|
52
|
+
test_files:
|
53
|
+
- test/unit/string_extensions_test.rb
|