stringento 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/Gemfile.lock +1 -1
- data/lib/stringento/formatter.rb +2 -2
- data/lib/stringento/template.rb +2 -2
- data/lib/stringento/version.rb +1 -1
- data/spec/stringento/formatter_spec.rb +20 -20
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e2ed02f2ce032043003cb96b312c8208d34a866aa614e743d5b5039021ec2741
|
4
|
+
data.tar.gz: a99db04c9fc54e9965b0a6b92091d36bcb7e1f0c7046a7b968e086a64051a4a4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e307f218a6d258e92ca99c2f7896d5fe9e2e446541dffce9a4802ce1c13f9ef0e529b223cb7fddd9447587cb3f7944b5d1aab89eedb715f0c5171e421485830c
|
7
|
+
data.tar.gz: 9c6aec1db753180bacaaa8002e60c5c9108788a5bb850cfdc0981974b1dc2fab72985354dab976b543428b15d33e3cf78a4d29c4077f2f64abdc19f764be5bc3
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
# 2.0.0 (April 7th, 2019)
|
2
|
+
|
3
|
+
*Breaking change in the formatter signature*
|
4
|
+
|
5
|
+
* Formatter#format signature was renamed and changed from: `format(value, method, arg)` to: `formatter(method, value arg)`. This should help this method not conflict with Kernel#format and also match the signature closer to its visitor methods: `*_formatter(value, arg)`.
|
6
|
+
|
7
|
+
# 1.0.0 (April 7th, 2019)
|
8
|
+
|
9
|
+
Initial Release
|
10
|
+
|
1
11
|
# 0.0.1 (April 4th, 2019)
|
2
12
|
|
3
13
|
Library Shell.
|
data/Gemfile.lock
CHANGED
data/lib/stringento/formatter.rb
CHANGED
@@ -18,8 +18,8 @@ module Stringento
|
|
18
18
|
|
19
19
|
private_constant :METHOD_SUFFIX
|
20
20
|
|
21
|
-
def
|
22
|
-
method_name = "#{
|
21
|
+
def formatter(method, value, arg = '')
|
22
|
+
method_name = "#{method}#{METHOD_SUFFIX}"
|
23
23
|
|
24
24
|
if respond_to?(method_name)
|
25
25
|
send(method_name, value, arg)
|
data/lib/stringento/template.rb
CHANGED
@@ -31,9 +31,9 @@ module Stringento
|
|
31
31
|
placeholders.inject(value) do |output, placeholder|
|
32
32
|
resolved_value = (resolver || default_resolver).resolve(placeholder.name, input)
|
33
33
|
|
34
|
-
formatted_value = (formatter || default_formatter).
|
35
|
-
resolved_value,
|
34
|
+
formatted_value = (formatter || default_formatter).formatter(
|
36
35
|
placeholder.formatter,
|
36
|
+
resolved_value,
|
37
37
|
placeholder.arg
|
38
38
|
)
|
39
39
|
|
data/lib/stringento/version.rb
CHANGED
@@ -11,11 +11,11 @@ require 'spec_helper'
|
|
11
11
|
require './spec/examples/custom_formatter'
|
12
12
|
|
13
13
|
describe ::Stringento::Formatter do
|
14
|
-
describe 'when not specifying a
|
14
|
+
describe 'when not specifying a method' do
|
15
15
|
it 'should return value as a string' do
|
16
|
-
|
17
|
-
|
18
|
-
actual = described_class.new.
|
16
|
+
method = ''
|
17
|
+
value = 'some value'
|
18
|
+
actual = described_class.new.formatter(method, value)
|
19
19
|
|
20
20
|
expect(actual).to eq(value)
|
21
21
|
end
|
@@ -23,9 +23,9 @@ describe ::Stringento::Formatter do
|
|
23
23
|
|
24
24
|
describe 'when specifying a formatter that does not exist' do
|
25
25
|
it 'should return value as a string' do
|
26
|
-
|
27
|
-
|
28
|
-
actual = described_class.new.
|
26
|
+
method = 'doesnt_exist'
|
27
|
+
value = 'some value'
|
28
|
+
actual = described_class.new.formatter(method, value)
|
29
29
|
|
30
30
|
expect(actual).to eq(value)
|
31
31
|
end
|
@@ -36,27 +36,27 @@ describe ::Stringento::Formatter do
|
|
36
36
|
formatter = CustomFormatter.new
|
37
37
|
method = 'yes_no'
|
38
38
|
|
39
|
-
expect(formatter.
|
40
|
-
expect(formatter.
|
41
|
-
expect(formatter.
|
42
|
-
expect(formatter.
|
39
|
+
expect(formatter.formatter(method, true)).to eq('Yes')
|
40
|
+
expect(formatter.formatter(method, 'true')).to eq('Yes')
|
41
|
+
expect(formatter.formatter(method, '')).to eq('Yes')
|
42
|
+
expect(formatter.formatter(method, 'false')).to eq('Yes')
|
43
43
|
|
44
|
-
expect(formatter.
|
45
|
-
expect(formatter.
|
44
|
+
expect(formatter.formatter(method, false)).to eq('No')
|
45
|
+
expect(formatter.formatter(method, nil)).to eq('No')
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
49
|
it 'yes_no_unknown formatter should be called' do
|
50
50
|
formatter = CustomFormatter.new
|
51
|
-
method
|
51
|
+
method = 'yes_no_unknown'
|
52
52
|
|
53
|
-
expect(formatter.
|
54
|
-
expect(formatter.
|
55
|
-
expect(formatter.
|
56
|
-
expect(formatter.
|
53
|
+
expect(formatter.formatter(method, true)).to eq('Yes')
|
54
|
+
expect(formatter.formatter(method, 'true')).to eq('Yes')
|
55
|
+
expect(formatter.formatter(method, '')).to eq('Yes')
|
56
|
+
expect(formatter.formatter(method, 'false')).to eq('Yes')
|
57
57
|
|
58
|
-
expect(formatter.
|
58
|
+
expect(formatter.formatter(method, false)).to eq('No')
|
59
59
|
|
60
|
-
expect(formatter.
|
60
|
+
expect(formatter.formatter(method, nil)).to eq('Unknown')
|
61
61
|
end
|
62
62
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stringento
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Ruggio
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faker
|