gemsupport 0.2.0 → 0.3.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 +4 -4
- data/lib/gemsupport/core_ext/string.rb +15 -0
- data/lib/gemsupport/version.rb +1 -1
- data/spec/gemsupport/core_ext/string_spec.rb +43 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3df4c71cd4f48bf0665a2a0c307d4b595e0e756
|
4
|
+
data.tar.gz: 867518858d56bef29f40fb3e420f1b32d771ac2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29ac3ab4616a0be74e0be945cd58d01146e5f53e5301d213a0158f1f8694fc2513bebb49888ad1cecdd7c100f33d9a88ce49a43ef7937b612096a1b4b8438422
|
7
|
+
data.tar.gz: d5972738e8e21d41b92929d849a7ccdcc778176d940031334a98bfd6d49d65f3fb0eb884de4f665e0e504e777a75e8143e81074137cdfb09cf63a8a7716a0a33
|
@@ -13,4 +13,19 @@ String.class_eval do
|
|
13
13
|
e.split('_').map { |w| w.capitalize }.join
|
14
14
|
end.join('::')
|
15
15
|
end
|
16
|
+
|
17
|
+
# Remove indentation spaces for multilines string
|
18
|
+
# From:
|
19
|
+
# | Anonymous Coward
|
20
|
+
# | - Community Guest
|
21
|
+
# To:
|
22
|
+
# |Anonymous Coward
|
23
|
+
# | - Community Guest
|
24
|
+
def unindent
|
25
|
+
gsub(/^#{scan(/^[ \t]+(?=\S)/).min}/, '')
|
26
|
+
end
|
27
|
+
|
28
|
+
def unindent!
|
29
|
+
replace(unindent)
|
30
|
+
end
|
16
31
|
end
|
data/lib/gemsupport/version.rb
CHANGED
@@ -58,4 +58,47 @@ describe 'String' do
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
end
|
61
|
+
|
62
|
+
describe '#unindent' do
|
63
|
+
context 'when empty string' do
|
64
|
+
it 'does not remove anything' do
|
65
|
+
expect(''.unindent).to eq('')
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
context 'When simple line indentation' do
|
70
|
+
it 'removes the spaces' do
|
71
|
+
expect("\s\sabc".unindent).to eq('abc')
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'removes the tabs' do
|
75
|
+
expect("\tabc".unindent).to eq('abc')
|
76
|
+
end
|
77
|
+
|
78
|
+
it 'removes the whintespaces' do
|
79
|
+
expect("\t\s\sabc".unindent).to eq('abc')
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'when multi-line identation' do
|
84
|
+
it 'removes the whitespaces' do
|
85
|
+
expect("\t\sabc\n\t\sabc".unindent).to eq("abc\nabc")
|
86
|
+
end
|
87
|
+
|
88
|
+
it 'keeps relative indentation' do
|
89
|
+
expect("\tabc\n\t\tabc".unindent).to eq("abc\n\tabc")
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'ignores blank lines for indent calculation' do
|
93
|
+
expect("\n\tabc\n\n\t\tabc\n".unindent).to eq("\nabc\n\n\tabc\n")
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe '#unindent!' do
|
99
|
+
let(:source) { "\s\sabc" }
|
100
|
+
it 'modifies string in place' do
|
101
|
+
expect { source.unindent! }.to change { source }.from("\s\sabc").to('abc')
|
102
|
+
end
|
103
|
+
end
|
61
104
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gemsupport
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- mdouchement
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|