stringub-commons 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -3,3 +3,4 @@
3
3
  Gemfile.lock
4
4
  pkg/*
5
5
  coverage*
6
+ doc*
data/README.markdown CHANGED
@@ -1,18 +1,40 @@
1
- # serradura-stringub-commons
1
+ # serradura/stringub-commons
2
2
 
3
3
  ## Links
4
4
 
5
- <a href='http://rubygems.org/gems/stringub_commons'>http://rubygems.org/gems/stringub_commons</a>
5
+ <a href='https://rubygems.org/gems/stringub-commons'>https://rubygems.org/gems/stringub-commons</a>
6
6
 
7
- <a href="http://github.com/serradura/stringub_commons">http://github.com/serradura/stringub_commons</a>
7
+ <a href="https://github.com/serradura/stringub-commons">https://github.com/serradura/stringub-commons</a>
8
8
 
9
9
  ## Description
10
10
  This library borned from the early versions of string_utility_belt gem, this gem adds new common purpose methods to String class. E.g: split a string in words, replace a sequence of spaces per a unique space.
11
11
 
12
12
  ## Install
13
13
 
14
- gem install stringub_commons
14
+ gem install stringub_commons
15
15
 
16
16
  ## Examples
17
- Examples can be founds in the tests.
17
+ ### Method: words
18
+ Split strings into an array of words.
19
+
20
+ # Ex:
21
+ "Ruby on Rails".words
22
+ # >> ["Ruby", "on", "Rails"]
23
+
24
+ "Serradura's house".words
25
+ # >> ["Serradura's", "house"]
26
+
27
+ ### Method: unique_spaces
28
+ Removes a sequence of any kind of space characters per a unique whitespace.
29
+
30
+ " \n abc ".unique_spaces
31
+ # >> " abc "
32
+
33
+ #Tip:
34
+ #If do you need remove trailing whitespaces. chain the String#strip method:
35
+
36
+ " \n abc ".unique_spaces.strip
37
+ # >> "abc"
38
+
39
+ More examples can be founds in the tests.
18
40
 
@@ -1,20 +1,46 @@
1
1
  require "stringub-commons/version"
2
2
 
3
+ # Stringub::Commons provides new methods for strings.
3
4
  module Stringub
4
5
  module Commons
6
+ # Regexp pattern used to define words.
5
7
  WORD_PATTERN = /\w[\w\'\-]*/
8
+ # Regexp pattern used to match any kind of space, ex: ' ', \n, \r, \t
6
9
  ANY_SPACE_PATTERN = /\s+/
7
10
 
8
11
  UNIQUE_SPACE = " "
9
12
 
13
+ # Split strings into an array of words.
14
+ # # Ex:
15
+ # "Ruby on Rails".words
16
+ # # >> ["Ruby", "on", "Rails"]
17
+ #
18
+ # "Serradura's house".words
19
+ # # >> ["Serradura's", "house"]
20
+ #
21
+ # "Module and sub-module".words
22
+ # # >> ["Module", "and", "aub-module"]
10
23
  def words
11
24
  self.scan(WORD_PATTERN)
12
25
  end
13
26
 
27
+ # Removes a sequence of any kind of space characters per a unique whitespace.
28
+ # # Ex:
29
+ # " \n abc ".unique_spaces
30
+ # # >> " abc "
31
+ #
32
+ # "\o/ \n\r\t ".unique_spaces
33
+ # # >> "\o/ "
34
+ # ===Tip:
35
+ # If do you need remove trailing whitespaces. chain the String#strip method:
36
+ # " \n abc ".unique_spaces.strip
37
+ # # >> "abc"
14
38
  def unique_spaces
15
39
  self.gsub(ANY_SPACE_PATTERN, UNIQUE_SPACE)
16
40
  end
17
41
 
42
+ # Removes a sequence of any kind of space characters per a unique whitespace.
43
+ # Returns nil if str was not altered.
18
44
  def unique_spaces!
19
45
  self.gsub!(ANY_SPACE_PATTERN, UNIQUE_SPACE)
20
46
  end
@@ -1,5 +1,5 @@
1
1
  module Stringub
2
2
  module Commons
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stringub-commons
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Rodrigo Serradura
@@ -15,8 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-07-24 00:00:00 -07:00
19
- default_executable:
18
+ date: 2011-07-27 00:00:00 Z
20
19
  dependencies: []
21
20
 
22
21
  description: "This library borned from the early versions of string_utility_belt gem, this gem adds new common purpose methods to String class. E.g: split a string in words, replace a sequence of spaces per a unique space."
@@ -38,7 +37,6 @@ files:
38
37
  - stringub-commons.gemspec
39
38
  - test/stringub-commons_test.rb
40
39
  - test/test_helper.rb
41
- has_rdoc: true
42
40
  homepage: ""
43
41
  licenses: []
44
42
 
@@ -68,10 +66,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
68
66
  requirements: []
69
67
 
70
68
  rubyforge_project: stringub-commons
71
- rubygems_version: 1.5.3
69
+ rubygems_version: 1.8.2
72
70
  signing_key:
73
71
  specification_version: 3
74
72
  summary: Useful methods for strings
75
- test_files:
76
- - test/stringub-commons_test.rb
77
- - test/test_helper.rb
73
+ test_files: []
74
+