stringento 1.0.0 → 2.0.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: a9c5bc1e6be2d2b938d8558ffed9dfbf772e6455e5d685d191a573b4ed2f39d0
4
- data.tar.gz: 35a3d3762d62d34e7910d96f3572b0fb99188212baa931d0c6fbc7b2c4546302
3
+ metadata.gz: e2ed02f2ce032043003cb96b312c8208d34a866aa614e743d5b5039021ec2741
4
+ data.tar.gz: a99db04c9fc54e9965b0a6b92091d36bcb7e1f0c7046a7b968e086a64051a4a4
5
5
  SHA512:
6
- metadata.gz: b2a0ccd6b31c1fab010b8204e5be9786fe8df043dc4f198bc44a9dc52f1b72d1bc7bb5cb242c122cbd33b3263f9a6542fe6dc9f9e19c12996f65a688812ce3ef
7
- data.tar.gz: ca6ba92b4db5ad88ec139f2352684f3b7534224bedc631546ac21f053354824f75dcddb15d6e27d5d130b2da600ad363ab13a1c5b3f9afd2eaa291f039493242
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stringento (1.0.0)
4
+ stringento (2.0.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -18,8 +18,8 @@ module Stringento
18
18
 
19
19
  private_constant :METHOD_SUFFIX
20
20
 
21
- def format(value, formatter = '', arg = '')
22
- method_name = "#{formatter}#{METHOD_SUFFIX}"
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)
@@ -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).format(
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
 
@@ -8,5 +8,5 @@
8
8
  #
9
9
 
10
10
  module Stringento
11
- VERSION = '1.0.0'
11
+ VERSION = '2.0.0'
12
12
  end
@@ -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 formatter' do
14
+ describe 'when not specifying a method' do
15
15
  it 'should return value as a string' do
16
- value = 'some value'
17
-
18
- actual = described_class.new.format(value)
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
- value = 'some value'
27
-
28
- actual = described_class.new.format(value, 'doesnt_exist')
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.format(true, method)).to eq('Yes')
40
- expect(formatter.format('true', method)).to eq('Yes')
41
- expect(formatter.format('', method)).to eq('Yes')
42
- expect(formatter.format('false', method)).to eq('Yes')
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.format(false, method)).to eq('No')
45
- expect(formatter.format(nil, method)).to eq('No')
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 = 'yes_no_unknown'
51
+ method = 'yes_no_unknown'
52
52
 
53
- expect(formatter.format(true, method)).to eq('Yes')
54
- expect(formatter.format('true', method)).to eq('Yes')
55
- expect(formatter.format('', method)).to eq('Yes')
56
- expect(formatter.format('false', method)).to eq('Yes')
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.format(false, method)).to eq('No')
58
+ expect(formatter.formatter(method, false)).to eq('No')
59
59
 
60
- expect(formatter.format(nil, method)).to eq('Unknown')
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: 1.0.0
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-05 00:00:00.000000000 Z
11
+ date: 2019-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faker