super_strip 0.1.0 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bee232baf49e10fdbec6f4090c3b68ec0a424898
4
- data.tar.gz: 47b40de7ed23fd8c2f0ccfdaeceb111b2b494bdf
3
+ metadata.gz: 781b066a9a40c10dad47ba8778b7ca2c188da440
4
+ data.tar.gz: ef1d2fe7992e5304e02fd4c5c6e50a6ef274f271
5
5
  SHA512:
6
- metadata.gz: c262bf59e34ec44c36bc1a8eb37258ef73f84b81fbe103ae1b3a617fd637422c3e9e7c688b21698650c1f1a30080d9e2f2652c6d7182e67d2e720663f9e43158
7
- data.tar.gz: 2909e84f9a18943ed1bba72f54f2ab208f6724d11658464d7b5b7f28ab5a12176ccc3f97987e67ba0b1fe4bf5ef29a184dc3c9c283544713110ff7a001764e47
6
+ metadata.gz: 6b1a35b61c0093f9be96db9909764cdb469ea018336dd7775150296c7ded00e860063fb5e1507dc026b042850c4183da246cdc06ebeaaa5280f00c36f40ea5cb
7
+ data.tar.gz: 8dca684b9b27538f7ffbb80495e0f49c8ac36c5f5669d2e0ab0a54b73272eb60db4ccc3df4a4549385ada16b7ef3c9d070cbcf9d177795c3a70b9405b7e37d9c
data/README.md CHANGED
@@ -1,9 +1,11 @@
1
1
  # SuperStrip
2
2
 
3
- Utility module to strip special white spaces.
4
- `String#strip` removes white spaces in string, but not special white spaces for example `\u3000` (commonly used in Japanese), `\u3164` (HANGUL FILLER).
3
+ Another version of strip methods to strip special white spaces.
4
+ `String#strip` removes white spaces in string, but not special white spaces for example `\u3000` (IDEOGRAPHIC SPACE, commonly used in Japanese), `\u3164` (HANGUL FILLER).
5
5
 
6
- SuperStrip provides another lstrip, rstrip, strip functions.
6
+ [![Build Status](https://travis-ci.org/pompopo/super_strip.svg?branch=master)](https://travis-ci.org/pompopo/super_strip)
7
+ [![Gem Version](https://badge.fury.io/rb/super_strip.svg)](https://badge.fury.io/rb/super_strip)
8
+ [![MIT License](http://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)
7
9
 
8
10
  ## Installation
9
11
 
@@ -17,9 +19,28 @@ gem 'super_strip'
17
19
 
18
20
  ```
19
21
  str = ' string '
20
- SuperStrip.strip(str) #=> 'string'
21
- SuperStrip.lstrip(str) #=> 'string '
22
- SuperStrip.rstrip(str) #=> ' string'
22
+ str.super_strip #=> 'string'
23
+ str.super_lstrip #=> 'string '
24
+ str.super_rstrip #=> ' string'
25
+
26
+ # destructive methods
27
+ # These return nil if no spaces are removed
28
+ str1 = str.dup
29
+ str1.super_strip! #=> 'string'
30
+ str1 #=> 'string'
31
+
32
+ str2 = str.dup
33
+ str2.super_lstrip! #=> 'string '
34
+ str2 #=> 'string '
35
+
36
+ str3 = str.dup
37
+ str3.super_rstrip! #=> ' string'
38
+ str3 #=> ' string'
39
+ ```
40
+
41
+ If you want to remove all spaces in string, you can use `SuperStrip::WHITE_SPACES` constant.
42
+ ```
43
+ ' s t r i n g '.delete SuperStrip::WHITE_SPACES.join #=> 'string'
23
44
  ```
24
45
 
25
46
  ## Development
@@ -1,23 +1,45 @@
1
1
  require 'super_strip/version'
2
2
 
3
- # Utility module to remove special white spaces
4
- module SuperStrip
5
- class << self
6
- def lstrip(str)
7
- str.split('').drop_while do |point|
8
- WHITE_SPACES.include?(point)
9
- end.join
10
- end
11
-
12
- def rstrip(str)
13
- lstrip(str.reverse).reverse
14
- end
15
-
16
- def strip(str)
17
- lstrip(rstrip(str))
18
- end
3
+ # Special version of strip methods to remove special white spaces
4
+ class String
5
+ def super_lstrip
6
+ split('').drop_while do |point|
7
+ SuperStrip::WHITE_SPACES.include?(point)
8
+ end.join
9
+ end
10
+
11
+ def super_rstrip
12
+ reverse.super_lstrip.reverse
13
+ end
14
+
15
+ def super_strip
16
+ super_lstrip.super_rstrip
17
+ end
18
+
19
+ def super_lstrip!
20
+ do_change(:super_lstrip)
21
+ end
22
+
23
+ def super_rstrip!
24
+ do_change(:super_rstrip)
25
+ end
26
+
27
+ def super_strip!
28
+ do_change(:super_strip)
29
+ end
30
+
31
+ private
32
+
33
+ def do_change(method)
34
+ after = send(method)
35
+ changed = self != after
36
+ replace(after)
37
+ self if changed
19
38
  end
39
+ end
20
40
 
41
+ # define special white spaces
42
+ module SuperStrip
21
43
  WHITE_SPACES = %W(
22
44
  \u0009
23
45
  \u0020
@@ -1,3 +1,3 @@
1
1
  module SuperStrip
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -9,8 +9,8 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ['pompopo']
10
10
  spec.email = ['pompopo@gmail.com']
11
11
 
12
- spec.summary = 'Utility module to strip special white spaces.'
13
- spec.description = 'SuperStrip provides another lstrip, rstrip, strip functions.'
12
+ spec.summary = 'Provide another version of strip methods to strip special white spaces.'
13
+ spec.description = 'SuperStrip provides another version of lstrip, rstrip, strip, lstrip!, rstrip!, strip! functions. They can remove special white spaces such as `IDEOGRAPHIC SPACE`.'
14
14
  spec.homepage = 'https://github.com/pompopo/super_strip'
15
15
  spec.license = 'MIT'
16
16
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: super_strip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - pompopo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-07-28 00:00:00.000000000 Z
11
+ date: 2016-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -52,7 +52,9 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- description: SuperStrip provides another lstrip, rstrip, strip functions.
55
+ description: SuperStrip provides another version of lstrip, rstrip, strip, lstrip!,
56
+ rstrip!, strip! functions. They can remove special white spaces such as `IDEOGRAPHIC
57
+ SPACE`.
56
58
  email:
57
59
  - pompopo@gmail.com
58
60
  executables: []
@@ -96,5 +98,5 @@ rubyforge_project:
96
98
  rubygems_version: 2.2.2
97
99
  signing_key:
98
100
  specification_version: 4
99
- summary: Utility module to strip special white spaces.
101
+ summary: Provide another version of strip methods to strip special white spaces.
100
102
  test_files: []