super_settings 2.2.1 → 2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f2db5de763e2b71a248913369bf05dda818d328fdee379a703054164ecdb9f51
4
- data.tar.gz: 5ca7f24e706c33d4b79363144eb98e41c8772e046709f6fc2bc7f21ba91ea592
3
+ metadata.gz: e4db9231cfc6b54497dc703ad1b06b4a4a8e9773546df32786be8c60096ead77
4
+ data.tar.gz: 4a7753a5e5abcdee82fcc9c5835e6164a5b5334b80d1ae6c1b59953ea013279d
5
5
  SHA512:
6
- metadata.gz: c3c45f9701cf13c981de225ea0fbe157709aab31cea37e967b33deeb0a9e382d2d0fe8e1a4afae889d572743f4bd40ad21e206ec6db34f74cff493c1a2560130
7
- data.tar.gz: 5923794e1704cabf9885e6e7ff90420302158c77911efa9b47441a0d14c0e1326c0f0ca6699dc523898a08f0eb9375ceada0bf6414367eb5fa0995166ea2b1d5
6
+ metadata.gz: 14cddc913184e9b63f86993d6c35a1022d951c6a486bab79514c45b13eb9433959dfdb9836df09c74b5e3049b887142871955d95a9fbcdd99a7cbf8db967ea24
7
+ data.tar.gz: '068ec34332ffb50af7552fac14f8ef90b2180036c7031a04ed9b51f52cfd1180f9e2b45896bb9dd00b3acdd0fb4f47d2f8fd0e9d8d06301d4cd3b1b373ce1e65'
data/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@ All notable changes to this project will be documented in this file.
4
4
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
5
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
6
 
7
+ ## 2.3.0
8
+
9
+ ### Changed
10
+
11
+ - Calling `SuperSettings.get` on a setting stored as an array now returns the array as a multiline string rather than simply calling `to_s` on the array. So an array setting stored as `["foo", "bar"]` will now be returned as `"foo\nbar"` rather than `'["foo", "bar"]'`.
12
+ - Calling `SuperSettings.get` on a setting stored as a datetime will now return the value as an ISO-8601 formatted string rather than simply calling `to_s` on the `Time` object.
13
+
7
14
  ## 2.2.1
8
15
 
9
16
  ### Added
data/VERSION CHANGED
@@ -1 +1 @@
1
- 2.2.1
1
+ 2.3.0
@@ -34,7 +34,7 @@ module SuperSettings
34
34
  # @param value [Object]
35
35
  # @return [Time]
36
36
  def time(value)
37
- value = nil if value.nil? || value.to_s.empty?
37
+ value = nil if blank?(value)
38
38
  return nil if value.nil?
39
39
 
40
40
  time = if value.is_a?(Numeric)
@@ -50,6 +50,25 @@ module SuperSettings
50
50
  time
51
51
  end
52
52
 
53
+ # Cast a value to a string.
54
+ #
55
+ # @param value [Object]
56
+ # @return [String]
57
+ def string(value)
58
+ value = nil if blank?(value)
59
+ return nil if value.nil?
60
+
61
+ if value.is_a?(String)
62
+ value
63
+ elsif value.is_a?(Array)
64
+ value.join("\n")
65
+ elsif value.respond_to?(:iso8601)
66
+ value.iso8601
67
+ else
68
+ value.to_s
69
+ end
70
+ end
71
+
53
72
  # @return [Boolean] true if the value is nil or empty.
54
73
  def blank?(value)
55
74
  return true if value.nil?
@@ -35,7 +35,10 @@ module SuperSettings
35
35
  # @return [String]
36
36
  def get(key, default = nil)
37
37
  val = context_setting(key)
38
- val.nil? ? default : val.to_s
38
+ return val if val.is_a?(String)
39
+ return default if val.nil?
40
+
41
+ Coerce.string(val)
39
42
  end
40
43
 
41
44
  # Alias for {#get} to allow using the [] operator to get a setting value.
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: super_settings
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.1
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Durand
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-05 00:00:00.000000000 Z
11
+ date: 2025-04-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler