fedux_org-stdlib 0.11.11 → 0.11.12

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: ca6841dfdb44dda71248d9db8d5d9f950c4b8947
4
- data.tar.gz: cb82cb72e7dcd123f87a4a233ec233d3223be407
3
+ metadata.gz: a6156f7dfa578e610aa9eb1d9710477b14aa944b
4
+ data.tar.gz: 1e36f5e6ee58ff54b720c1b4cc3a32f3c5c32830
5
5
  SHA512:
6
- metadata.gz: ab158f3098a40eaa21c2e1d7a1ec575937a994cd79e1963777b21fea2780825072d57d7e86164a0f490f0098a65fe346fc871853d87b786491b8182602418704
7
- data.tar.gz: 7d728613a023f6377120dc3bce8eb26fa27f966ce9b6ae183584173ae5a409c8cd3012973015544b5e5d37ce0cab8c50943a36193a5dc0e585162c550102e53e
6
+ metadata.gz: f260d6166372b7eabe4137dd69db0a9a20cfb5266c258a8f16723083cb7c1c26aaebc5766759ff4499017ede1c5ec5532467357009ea8c08ba6cb017af2be47a
7
+ data.tar.gz: d95f898392baeb65c6efd8322c9be31156328e18caf407c1b974a98a62014bbbba288b64c4b54437d80c863174f3f4cdb41764f7d90cda3715e5516fc6e206e7
@@ -10,7 +10,7 @@ GIT
10
10
  PATH
11
11
  remote: .
12
12
  specs:
13
- fedux_org-stdlib (0.11.10)
13
+ fedux_org-stdlib (0.11.11)
14
14
  activesupport
15
15
 
16
16
  PATH
@@ -3,6 +3,27 @@
3
3
  class Array
4
4
  # Convert array to list
5
5
  #
6
+ # @example Change separator for values
7
+ #
8
+ # input = %w(v1 v2 v3)
9
+ #
10
+ # input.to_list(separator: ' | '
11
+ # => "v1" | "v2" | "v3"
12
+ #
13
+ # @example Change last separator for values
14
+ #
15
+ # input = %w(v1 v2 v3)
16
+ #
17
+ # input.to_list(last_separator: ' and '
18
+ # => "v1", "v2" and "v3"
19
+ #
20
+ # @example Change character which is placed around values
21
+ #
22
+ # input = %w(v1 v2 v3)
23
+ #
24
+ # input.to_list(around: "'")
25
+ # => 'v1', 'v2', 'v3'
26
+ #
6
27
  # @return [String]
7
28
  # A string representation of list
8
29
  def to_list(separator: ', ', last_separator: separator, around: '"')
@@ -5,9 +5,41 @@ require 'fedux_org_stdlib/core_ext/array/list'
5
5
  class Hash
6
6
  # Convert Hash to list
7
7
  #
8
+ # For more examples see 'fedux_org_stdlib/core_ext/array/list'
9
+ #
10
+ # @example Change separator for key and value
11
+ #
12
+ # input = {
13
+ # opt1: 'asdf',
14
+ # opt2: 'asdf'
15
+ # }
16
+ #
17
+ # input.to_list(format: "%s | %s")
18
+ # => "opt1 | asdf", "opt2 | asdf"
19
+ #
20
+ # @example Change separator between key/value-pairs
21
+ #
22
+ # input = {
23
+ # opt1: 'asdf',
24
+ # opt2: 'asdf'
25
+ # }
26
+ #
27
+ # input.to_list(format: "%s | %s")
28
+ # => "opt1 | asdf", "opt2 | asdf"
29
+ #
30
+ # @example Change character around key/value-pair
31
+ #
32
+ # input = {
33
+ # opt1: 'asdf',
34
+ # opt2: 'asdf'
35
+ # }
36
+ #
37
+ # input.to_list(around: "'")
38
+ # => 'opt1: asdf', 'opt2: asdf'
39
+ #
8
40
  # @return [String]
9
41
  # A string representation of hash as list
10
- def to_list
11
- map { |key, value| format('%s: %s', key, value) }.to_list
42
+ def to_list(format: '%s: %s', **args)
43
+ map { |key, value| format(format, key, value) }.to_list(**args)
12
44
  end
13
45
  end
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
  # FeduxOrgStdlib
3
3
  module FeduxOrgStdlib
4
- VERSION = '0.11.11'
4
+ VERSION = '0.11.12'
5
5
  end
@@ -12,5 +12,23 @@ RSpec.describe Array do
12
12
 
13
13
  expect(input.to_list).to eq '"opt1: asdf", "opt2: asdf"'
14
14
  end
15
+
16
+ it 'passes options' do
17
+ input = {
18
+ opt1: 'asdf',
19
+ opt2: 'asdf'
20
+ }
21
+
22
+ expect(input.to_list(around: "'")).to eq %('opt1: asdf', 'opt2: asdf')
23
+ end
24
+
25
+ it 'changes format' do
26
+ input = {
27
+ opt1: 'asdf',
28
+ opt2: 'asdf'
29
+ }
30
+
31
+ expect(input.to_list(format: '%s | %s')).to eq %("opt1 | asdf", "opt2 | asdf")
32
+ end
15
33
  end
16
34
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fedux_org-stdlib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.11
4
+ version: 0.11.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Meyer