parameter_substitution 1.0.0 → 1.1.0.pre.1

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: 9d6031634a3751b62d9d584b15849f2ca5129af7d167be16d507bf2872ec3f86
4
- data.tar.gz: b9a1ce433449018cbd38baf05df52a6dadd521d788cf0ad4aabed2c7ba79f7a1
3
+ metadata.gz: 01e0aa08d4f8130fd493c54e5958aed36159746476fa168180407401584aaaf6
4
+ data.tar.gz: 4bc6bd8c7b94edc3690c474f8b7ece56d6e9aadf1d825e14bcc7413a2b1fe7a9
5
5
  SHA512:
6
- metadata.gz: 05edabbb29a83d31801c0b5945da813a3ebd8b2814b3ef4661b0444c290818baaaadd4ac477fb0c2b39a1d108be6955135b4cc527a404212e71e7cb576388f8e
7
- data.tar.gz: a509ef29f6bcfc7811ea0ede3e7298b54af4750b27995272dc1b0aed0cbc211a572cf2c8c8703212f851a524bad6d51ecb2a4b942e6a7153a2e8985e334bd22f
6
+ metadata.gz: e8c2436cdce9ccaf16e02fe368aaa22337d43af01cdd1c35677a7fccf8af19db089c7ebfffbf859b52b3188b7323b884d8ed7cc57f63935afc7fb2d3f1075829
7
+ data.tar.gz: 1b1b2548aaa1a4e6ed4940c4589e65f3247d76ca9aa07089d0c7cde701acecb1704b12018b57b1661ce89d4b47416c337c9ee3aaab3a7b7c208b8f88263349ae
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ class ParameterSubstitution::Formatters::IfTruthy < ParameterSubstitution::Formatters::Base
4
+ TRUTHY_VALUES = [true, "true", "t", 1, "1", "on", "yes"].freeze
5
+
6
+ def self.description
7
+ "If the input is truthy (i.e. #{TRUTHY_VALUES.inspect}) then the input is replaced with the first argument. Otherwise, the input is replaced with the second argument."
8
+ end
9
+
10
+ def self.has_parameters?
11
+ true
12
+ end
13
+
14
+ def initialize(value_if_true, value_if_false)
15
+ @value_if_true = value_if_true
16
+ @value_if_false = value_if_false
17
+ end
18
+
19
+ def format(value)
20
+ if TRUTHY_VALUES.include?(downcase_if_string(value))
21
+ @value_if_true
22
+ else
23
+ @value_if_false
24
+ end
25
+ end
26
+
27
+ :private
28
+
29
+ def downcase_if_string(value)
30
+ if value.is_a?(String)
31
+ value.downcase
32
+ else
33
+ value
34
+ end
35
+ end
36
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ParameterSubstitution
4
- VERSION = "1.0.0"
4
+ VERSION = "1.1.0.pre.1"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parameter_substitution
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0.pre.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Invoca Development
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-18 00:00:00.000000000 Z
11
+ date: 2020-05-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -105,6 +105,7 @@ files:
105
105
  - lib/parameter_substitution/formatters/duration_grouped_by_description.rb
106
106
  - lib/parameter_substitution/formatters/greater_than_value.rb
107
107
  - lib/parameter_substitution/formatters/if_nil.rb
108
+ - lib/parameter_substitution/formatters/if_truthy.rb
108
109
  - lib/parameter_substitution/formatters/in_timezone.rb
109
110
  - lib/parameter_substitution/formatters/json_parse.rb
110
111
  - lib/parameter_substitution/formatters/left.rb
@@ -144,9 +145,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
144
145
  version: '0'
145
146
  required_rubygems_version: !ruby/object:Gem::Requirement
146
147
  requirements:
147
- - - ">="
148
+ - - ">"
148
149
  - !ruby/object:Gem::Version
149
- version: '0'
150
+ version: 1.3.1
150
151
  requirements: []
151
152
  rubygems_version: 3.0.3
152
153
  signing_key: