super_strip 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +27 -6
- data/lib/super_strip.rb +38 -16
- data/lib/super_strip/version.rb +1 -1
- data/super_strip.gemspec +2 -2
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 781b066a9a40c10dad47ba8778b7ca2c188da440
|
4
|
+
data.tar.gz: ef1d2fe7992e5304e02fd4c5c6e50a6ef274f271
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b1a35b61c0093f9be96db9909764cdb469ea018336dd7775150296c7ded00e860063fb5e1507dc026b042850c4183da246cdc06ebeaaa5280f00c36f40ea5cb
|
7
|
+
data.tar.gz: 8dca684b9b27538f7ffbb80495e0f49c8ac36c5f5669d2e0ab0a54b73272eb60db4ccc3df4a4549385ada16b7ef3c9d070cbcf9d177795c3a70b9405b7e37d9c
|
data/README.md
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
# SuperStrip
|
2
2
|
|
3
|
-
|
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
|
-
|
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
|
-
|
21
|
-
|
22
|
-
|
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
|
data/lib/super_strip.rb
CHANGED
@@ -1,23 +1,45 @@
|
|
1
1
|
require 'super_strip/version'
|
2
2
|
|
3
|
-
#
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
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
|
data/lib/super_strip/version.rb
CHANGED
data/super_strip.gemspec
CHANGED
@@ -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 = '
|
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.
|
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-
|
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
|
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:
|
101
|
+
summary: Provide another version of strip methods to strip special white spaces.
|
100
102
|
test_files: []
|