strings 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/lib/strings.rb +2 -2
- data/lib/strings/align.rb +5 -5
- data/lib/strings/extensions.rb +14 -10
- data/lib/strings/fold.rb +1 -1
- data/lib/strings/truncate.rb +3 -3
- data/lib/strings/version.rb +1 -1
- data/lib/strings/wrap.rb +1 -3
- data/spec/unit/extensions_spec.rb +27 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8598a1eef564d4250363a7d49402bd1fe2e45880488042749c55fb4675ac090
|
4
|
+
data.tar.gz: c33aba524285885f8c9872bc4bea15a1242ebda47b532aaabe864975475ce9a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5fa16d822454ebc169d6edb15b07e0db169bd5992d29ed00e6a00dc83ba06ce0dba04135cb3eabea5015d48ef41d043f61f8cd98f2afd2d079e4a99d7c981536
|
7
|
+
data.tar.gz: c4a24318dd99910246a3b047dddfd2e0e04186426d2ae39842ec9f6a6c84a008b5cb3697036dd62c5646fe49b5e50b602c853e76ccf5fbc354b0dae392ac7bf4
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,10 @@
|
|
1
1
|
# Change log
|
2
2
|
|
3
|
+
## [v0.1.8] - 2019-11-24
|
4
|
+
|
5
|
+
### Fixed
|
6
|
+
* Fix Ruby 2.7 warnings by Ryan Davis(@zenspider)
|
7
|
+
|
3
8
|
## [v0.1.7] - 2019-11-14
|
4
9
|
|
5
10
|
### Added
|
@@ -48,6 +53,7 @@
|
|
48
53
|
|
49
54
|
* Initial implementation and release
|
50
55
|
|
56
|
+
[v0.1.8]: https://github.com/piotrmurach/strings/compare/v0.1.7...v0.1.8
|
51
57
|
[v0.1.7]: https://github.com/piotrmurach/strings/compare/v0.1.6...v0.1.7
|
52
58
|
[v0.1.6]: https://github.com/piotrmurach/strings/compare/v0.1.5...v0.1.6
|
53
59
|
[v0.1.5]: https://github.com/piotrmurach/strings/compare/v0.1.4...v0.1.5
|
data/lib/strings.rb
CHANGED
data/lib/strings/align.rb
CHANGED
@@ -23,23 +23,23 @@ module Strings
|
|
23
23
|
# @example
|
24
24
|
# text = "the madness of men"
|
25
25
|
#
|
26
|
-
# Strings::Align.align(22, :left)
|
26
|
+
# Strings::Align.align(text, 22, direction: :left)
|
27
27
|
# # => "the madness of men "
|
28
28
|
#
|
29
|
-
# Strings::Align.align(22, :center)
|
29
|
+
# Strings::Align.align(text, 22, direction: :center)
|
30
30
|
# # => " the madness of men "
|
31
31
|
#
|
32
|
-
# Strings::Align(22, :right)
|
32
|
+
# Strings::Align(text, 22, direction: :right)
|
33
33
|
# # => " the madness of men"
|
34
34
|
#
|
35
|
-
# Strings::Align.align(22, :center, fill: '*)
|
35
|
+
# Strings::Align.align(text, 22, direction: :center, fill: '*')
|
36
36
|
# # => "***the madness of men***"
|
37
37
|
#
|
38
38
|
# @api public
|
39
39
|
def align(text, width, direction: :left, **options)
|
40
40
|
return text if width.nil?
|
41
41
|
method = to_alignment(direction)
|
42
|
-
send(method, text, width, options)
|
42
|
+
send(method, text, width, **options)
|
43
43
|
end
|
44
44
|
module_function :align
|
45
45
|
|
data/lib/strings/extensions.rb
CHANGED
@@ -5,16 +5,20 @@ require_relative '../strings'
|
|
5
5
|
module Strings
|
6
6
|
module Extensions
|
7
7
|
refine String do
|
8
|
-
def align(*args)
|
9
|
-
Align.align(self, *args)
|
8
|
+
def align(*args, **kws)
|
9
|
+
Align.align(self, *args, **kws)
|
10
10
|
end
|
11
11
|
|
12
|
-
def align_left(*args)
|
13
|
-
Align.align_left(self, *args)
|
12
|
+
def align_left(*args, **kws)
|
13
|
+
Align.align_left(self, *args, **kws)
|
14
14
|
end
|
15
15
|
|
16
|
-
def
|
17
|
-
Align.
|
16
|
+
def align_center(*args, **kws)
|
17
|
+
Align.align_center(self, *args, **kws)
|
18
|
+
end
|
19
|
+
|
20
|
+
def align_right(*args, **kws)
|
21
|
+
Align.align_right(self, *args, **kws)
|
18
22
|
end
|
19
23
|
|
20
24
|
def ansi?
|
@@ -25,8 +29,8 @@ module Strings
|
|
25
29
|
Fold.fold(self, *args)
|
26
30
|
end
|
27
31
|
|
28
|
-
def pad(*args)
|
29
|
-
Pad.pad(self, *args)
|
32
|
+
def pad(*args, **kws)
|
33
|
+
Pad.pad(self, *args, **kws)
|
30
34
|
end
|
31
35
|
|
32
36
|
def sanitize
|
@@ -37,8 +41,8 @@ module Strings
|
|
37
41
|
Truncate.truncate(self, *args)
|
38
42
|
end
|
39
43
|
|
40
|
-
def wrap(*args)
|
41
|
-
Wrap.wrap(self, *args)
|
44
|
+
def wrap(*args, **kws)
|
45
|
+
Wrap.wrap(self, *args, **kws)
|
42
46
|
end
|
43
47
|
end
|
44
48
|
end # Extensions
|
data/lib/strings/fold.rb
CHANGED
data/lib/strings/truncate.rb
CHANGED
@@ -27,15 +27,15 @@ module Strings
|
|
27
27
|
# text = "The sovereignest thing on earth is parmacetti for an inward bruise."
|
28
28
|
#
|
29
29
|
# Strings::Truncate.truncate(text)
|
30
|
-
# # => "The sovereignest thing on
|
30
|
+
# # => "The sovereignest thing on ea…"
|
31
31
|
#
|
32
32
|
# Strings::Truncate.truncate(text, 20)
|
33
|
-
# # => "The sovereignest
|
33
|
+
# # => "The sovereignest t…"
|
34
34
|
#
|
35
35
|
# Strings::Truncate.truncate(text, 20, separator: ' ' )
|
36
36
|
# # => "The sovereignest…"
|
37
37
|
#
|
38
|
-
# Strings::Truncate.truncate(40, trailing: '... (see more)' )
|
38
|
+
# Strings::Truncate.truncate(text, 40, trailing: '... (see more)' )
|
39
39
|
# # => "The sovereignest thing on... (see more)"
|
40
40
|
#
|
41
41
|
# @api public
|
data/lib/strings/version.rb
CHANGED
data/lib/strings/wrap.rb
CHANGED
@@ -39,9 +39,35 @@ RSpec.describe Strings::Extensions do
|
|
39
39
|
].join("\n"))
|
40
40
|
end
|
41
41
|
|
42
|
+
it "pads a line" do
|
43
|
+
expect(text.pad(1)).to eq([
|
44
|
+
" " * (text.size + 2),
|
45
|
+
" #{text} ",
|
46
|
+
" " * (text.size + 2),
|
47
|
+
].join("\n"))
|
48
|
+
end
|
49
|
+
|
50
|
+
it "pads a line with custom fill" do
|
51
|
+
expect(text.pad(1, fill: "*")).to eq([
|
52
|
+
"*" * (text.size + 2),
|
53
|
+
"*#{text}*",
|
54
|
+
"*" * (text.size + 2),
|
55
|
+
].join("\n"))
|
56
|
+
end
|
57
|
+
|
42
58
|
it "truncates a line" do
|
43
59
|
text = "the madness of men"
|
44
|
-
expect(text.truncate(10)).to eq(
|
60
|
+
expect(text.truncate(10)).to eq("the madn…")
|
61
|
+
end
|
62
|
+
|
63
|
+
it "truncates a line with a custom trailing" do
|
64
|
+
text = "the madness of men"
|
65
|
+
expect(text.truncate(10, trailing: "...")).to eq("the ma...")
|
66
|
+
end
|
67
|
+
|
68
|
+
it "truncates into words with a custom trailing" do
|
69
|
+
text = "the madness of men"
|
70
|
+
expect(text.truncate(16, trailing: "...", separator: " ")).to eq("the madness...")
|
45
71
|
end
|
46
72
|
|
47
73
|
it "wraps a line" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: strings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Piotr Murach
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: strings-ansi
|
@@ -163,7 +163,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
163
163
|
- !ruby/object:Gem::Version
|
164
164
|
version: '0'
|
165
165
|
requirements: []
|
166
|
-
rubygems_version: 3.0.
|
166
|
+
rubygems_version: 3.0.6
|
167
167
|
signing_key:
|
168
168
|
specification_version: 4
|
169
169
|
summary: A set of useful functions for transforming strings.
|