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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 344e379be490559f0ca24d8b766edad6684d9e1d941f1d5afed88d9a918bb19b
4
- data.tar.gz: a43a0198dbeaff865f6b56a056e8417553d0a094456a3a2899b3b06ba5168123
3
+ metadata.gz: d8598a1eef564d4250363a7d49402bd1fe2e45880488042749c55fb4675ac090
4
+ data.tar.gz: c33aba524285885f8c9872bc4bea15a1242ebda47b532aaabe864975475ce9a1
5
5
  SHA512:
6
- metadata.gz: 53ee9e47ec42870eb2bd8661089d4dd8b9eadbd61de7ddc2a1928f180f4fe826925d783e85b1b7930e316fada17e1e5aeef1f5e90247d9e9278c0e5812c03f84
7
- data.tar.gz: 64fa7df77eb99d4d7d48fd6d6b55d09ad8ffec2de3e87cbe751007c681f9654daee704ae002ab5fcfa4a575eaf858f49e94e516d11243ff749aeabfbcda044d8
6
+ metadata.gz: 5fa16d822454ebc169d6edb15b07e0db169bd5992d29ed00e6a00dc83ba06ce0dba04135cb3eabea5015d48ef41d043f61f8cd98f2afd2d079e4a99d7c981536
7
+ data.tar.gz: c4a24318dd99910246a3b047dddfd2e0e04186426d2ae39842ec9f6a6c84a008b5cb3697036dd62c5646fe49b5e50b602c853e76ccf5fbc354b0dae392ac7bf4
@@ -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
@@ -15,8 +15,8 @@ module Strings
15
15
  # @see Strings::Align#align
16
16
  #
17
17
  # @api public
18
- def align(*args)
19
- Align.align(*args)
18
+ def align(*args, **kws)
19
+ Align.align(*args, **kws)
20
20
  end
21
21
  module_function :align
22
22
 
@@ -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
 
@@ -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 align_right(*args)
17
- Align.align_right(self, *args)
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
@@ -7,7 +7,7 @@ module Strings
7
7
  # Fold a multiline text into a single line string
8
8
  #
9
9
  # @example
10
- # fold("\tfoo \r\n\n bar") # => "foo bar"
10
+ # fold("\tfoo \r\n\n bar") # => " foo bar"
11
11
  #
12
12
  # @param [String] text
13
13
  #
@@ -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 ear…"
30
+ # # => "The sovereignest thing on ea…"
31
31
  #
32
32
  # Strings::Truncate.truncate(text, 20)
33
- # # => "The sovereignest th…"
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Strings
4
- VERSION = "0.1.7"
4
+ VERSION = "0.1.8"
5
5
  end # Strings
@@ -19,9 +19,7 @@ module Strings
19
19
  #
20
20
  # @example
21
21
  # Strings::Wrap.wrap("Some longish text", 8)
22
- # # => >Some
23
- # >longish
24
- # >text
22
+ # # => "Some \nlongish \ntext"
25
23
  #
26
24
  # @api public
27
25
  def wrap(text, wrap_at = DEFAULT_WIDTH, separator: nil)
@@ -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('the madn…')
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.7
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-14 00:00:00.000000000 Z
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.3
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.