proforma-extended-evaluator 1.0.0 → 1.1.0

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: 3f978fa2a4a04564213b30c11f6b1353734dd8df889c047b989a385857aade8e
4
- data.tar.gz: 75f683c4fb9689f6b081aa2b3f1d634cf3111d3c22c23d26481d82da8b6175e5
3
+ metadata.gz: '0766348b86e6e72ebfa8e2cdc687305197d7d43cef2a490383c31fadc89194d7'
4
+ data.tar.gz: e6eaa3c6a0409e215b07550c9a584d3e705a44dd51877ccb890ade25fb4c6bb0
5
5
  SHA512:
6
- metadata.gz: 5da22925132f972ebf226007b8b0b191336db4fc6a1e91d7b1ecb26401eeb5baa9f02c97abc3c87ce4bd4622611a191f826b28295184c1e870fa2bbed2e9be03
7
- data.tar.gz: f4e482ce9399c495a1ffd08bb5f81c000fb0ba2256c5d370de1ddcbae9fbc9c7b7feb37e056cd610187a25f2bce76db4ec1bdcadad6ff230205ffa93939b41b7
6
+ metadata.gz: 5db01296ddeaf818e7323c765f49be7c632cdbfdf83b42231b6eaec82d44200f49e4f590be898943e05862a127cf6646ebba0d3ede76b71ee4c964e226eb6d90
7
+ data.tar.gz: 759bdaabe85547aa1047f4ff5218c0dcb5673f9867d3fd51bcf73afb0e5ad0f5a06ebcdea173205a9d2cb44a16d981183a18c78996f5ea7beafd4525b5ed279f
@@ -3,6 +3,8 @@ Metrics/LineLength:
3
3
 
4
4
  Metrics/BlockLength:
5
5
  ExcludedMethods: ['let', 'it', 'describe', 'context', 'specify']
6
+ Exclude:
7
+ - proforma-extended-evaluator.gemspec
6
8
 
7
9
  Metrics/MethodLength:
8
10
  Max: 25
@@ -1,3 +1,7 @@
1
+ # 1.1.0 (May 7th, 2019)
2
+
3
+ * Replaced resolver value resolution with Objectable library.
4
+
1
5
  # 1.0.0 (April 24th, 2019)
2
6
 
3
7
  Publishing first release.
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- proforma-extended-evaluator (1.0.0)
4
+ proforma-extended-evaluator (1.1.0)
5
+ objectable (~> 1)
5
6
  stringento (~> 2)
6
7
 
7
8
  GEM
@@ -10,6 +11,7 @@ GEM
10
11
  acts_as_hashable (1.0.5)
11
12
  ansi (1.5.0)
12
13
  ast (2.4.0)
14
+ byebug (11.0.1)
13
15
  coderay (1.1.2)
14
16
  diff-lcs (1.3)
15
17
  docile (1.3.1)
@@ -42,6 +44,7 @@ GEM
42
44
  notiffany (0.1.1)
43
45
  nenv (~> 0.1)
44
46
  shellany (~> 0.0)
47
+ objectable (1.0.0)
45
48
  parallel (1.13.0)
46
49
  parser (2.6.0.0)
47
50
  ast (~> 2.4.0)
@@ -51,7 +54,11 @@ GEM
51
54
  pry (0.12.2)
52
55
  coderay (~> 1.1.0)
53
56
  method_source (~> 0.9.0)
57
+ pry-byebug (3.7.0)
58
+ byebug (~> 11.0)
59
+ pry (~> 0.10)
54
60
  rainbow (3.0.0)
61
+ rake (10.5.0)
55
62
  rb-fsevent (0.10.3)
56
63
  rb-inotify (0.9.10)
57
64
  ffi (>= 0.5.0, < 2)
@@ -100,6 +107,8 @@ DEPENDENCIES
100
107
  proforma (~> 1)
101
108
  proforma-extended-evaluator!
102
109
  pry (~> 0)
110
+ pry-byebug (~> 3)
111
+ rake (~> 10.0)
103
112
  rspec (~> 3.8)
104
113
  rubocop (~> 0.63.1)
105
114
  simplecov (~> 0.16.1)
data/Guardfile CHANGED
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- guard :rspec, cmd: 'bundle exec rspec' do
3
+ guard :rspec, cmd: 'DISABLE_SIMPLECOV=true bundle exec rspec --format=documentation' do
4
4
  require 'guard/rspec/dsl'
5
5
  dsl = Guard::RSpec::Dsl.new(self)
6
6
 
data/README.md CHANGED
@@ -30,6 +30,12 @@ You can also add this to your Gemfile:
30
30
  bundle add proforma-extended-evaluator
31
31
  ````
32
32
 
33
+ Note: If you are using bundler for auto-requiring then you need to specify as:
34
+
35
+ ```
36
+ gem 'proforma-extended-evaluator', require: 'proforma/extended_evaluator'
37
+ ```
38
+
33
39
  ## Examples
34
40
 
35
41
  ### Connecting to Proforma Rendering Pipeline
@@ -116,16 +122,18 @@ Notice how all strings are properly formatted as prescribed in the template.
116
122
 
117
123
  Formatter options are biased towards USA localization. You can override any of the options of the Formatter class, here are the options and their defaults:
118
124
 
119
- Option | Default
120
- ---------------- | -------
121
- currency_code | 'USD'
122
- currency_round | 2
123
- currency_symbol | '$'
124
- date_format | '%m/%d/%Y'
125
- mask_char | 'X'
126
- false_value | 'No'
127
- null_value | 'Unknown'
128
- true_value | 'Yes'
125
+ Option | Default
126
+ ------------------- | -------
127
+ currency_code | 'USD'
128
+ currency_round | 2
129
+ currency_symbol | '$'
130
+ date_format | '%m/%d/%Y'
131
+ decimal_separator | '.'
132
+ mask_char | 'X'
133
+ false_value | 'No'
134
+ null_value | 'Unknown'
135
+ thousands_separator | ','
136
+ true_value | 'Yes'
129
137
 
130
138
  ## Contributing
131
139
 
@@ -170,10 +178,7 @@ After code changes have successfully gone through the Pull Request review proces
170
178
  3. Install dependencies: `bundle`
171
179
  4. Update `CHANGELOG.md` with release notes
172
180
  5. Commit & push master to remote and ensure CI builds master successfully
173
- 6. Build the project locally: `gem build proforma-extended-evaluator`
174
- 7. Publish package to RubyGems: `gem push proforma-extended-evaluator-X.gem` where X is the version to push
175
- 8. Tag master with new version: `git tag <version>`
176
- 9. Push tags remotely: `git push origin --tags`
181
+ 6. Run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
177
182
 
178
183
  ## License
179
184
 
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -8,7 +8,9 @@
8
8
  #
9
9
 
10
10
  require 'bigdecimal'
11
+ require 'date'
11
12
  require 'forwardable'
13
+ require 'objectable'
12
14
  require 'stringento'
13
15
 
14
16
  require_relative 'extended_evaluator/formatter'
@@ -13,50 +13,14 @@ module Proforma
13
13
  class Resolver
14
14
  DEFAULT_SEPARATOR = '.'
15
15
 
16
- attr_reader :separator
16
+ attr_reader :objectable_resolver
17
17
 
18
18
  def initialize(separator: DEFAULT_SEPARATOR)
19
- @separator = separator.to_s
19
+ @objectable_resolver = Objectable.resolver(separator: separator)
20
20
  end
21
21
 
22
22
  def resolve(value, input)
23
- traverse(input, key_path(value))
24
- end
25
-
26
- private
27
-
28
- def key_path(value)
29
- return Array(value.to_s) if separator.empty?
30
-
31
- value.to_s.split(separator)
32
- end
33
-
34
- def traverse(object, through)
35
- pointer = object
36
-
37
- through.each do |t|
38
- next unless pointer
39
-
40
- pointer = get(pointer, t)
41
- end
42
-
43
- pointer
44
- end
45
-
46
- def get(object, key)
47
- if object.is_a?(Hash)
48
- indifferent_hash_get(object, key)
49
- elsif object.respond_to?(key)
50
- object.public_send(key)
51
- end
52
- end
53
-
54
- def indifferent_hash_get(hash, key)
55
- if hash.key?(key.to_s)
56
- hash[key.to_s]
57
- elsif hash.key?(key.to_s.to_sym)
58
- hash[key.to_s.to_sym]
59
- end
23
+ objectable_resolver.get(input, value)
60
24
  end
61
25
  end
62
26
  end
@@ -9,6 +9,6 @@
9
9
 
10
10
  module Proforma
11
11
  class ExtendedEvaluator
12
- VERSION = '1.0.0'
12
+ VERSION = '1.1.0'
13
13
  end
14
14
  end
@@ -22,11 +22,14 @@ Gem::Specification.new do |s|
22
22
 
23
23
  s.required_ruby_version = '>= 2.3.8'
24
24
 
25
+ s.add_dependency('objectable', '~>1')
25
26
  s.add_dependency('stringento', '~>2')
26
27
 
27
28
  s.add_development_dependency('guard-rspec', '~>4.7')
28
29
  s.add_development_dependency('proforma', '~>1')
29
30
  s.add_development_dependency('pry', '~>0')
31
+ s.add_development_dependency('pry-byebug', '~> 3')
32
+ s.add_development_dependency 'rake', '~> 10.0'
30
33
  s.add_development_dependency('rspec', '~> 3.8')
31
34
  s.add_development_dependency('rubocop', '~>0.63.1')
32
35
  s.add_development_dependency('simplecov', '~>0.16.1')
@@ -7,13 +7,19 @@
7
7
  # LICENSE file in the root directory of this source tree.
8
8
  #
9
9
 
10
- require 'yaml'
11
- require 'pry'
12
10
  require 'proforma'
11
+ require 'pry'
12
+ require 'pry-byebug'
13
+ require 'yaml'
14
+
15
+ unless ENV['DISABLE_SIMPLECOV'] == 'true'
16
+ require 'simplecov'
17
+ require 'simplecov-console'
13
18
 
14
- require 'simplecov'
15
- require 'simplecov-console'
16
- SimpleCov.formatter = SimpleCov::Formatter::Console
17
- SimpleCov.start
19
+ SimpleCov.formatter = SimpleCov::Formatter::Console
20
+ SimpleCov.start do
21
+ add_filter %r{\A/spec/}
22
+ end
23
+ end
18
24
 
19
25
  require './lib/proforma/extended_evaluator'
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: proforma-extended-evaluator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.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-25 00:00:00.000000000 Z
11
+ date: 2019-05-07 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: objectable
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: stringento
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +80,34 @@ dependencies:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry-byebug
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '10.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '10.0'
69
111
  - !ruby/object:Gem::Dependency
70
112
  name: rspec
71
113
  requirement: !ruby/object:Gem::Requirement
@@ -143,6 +185,7 @@ files:
143
185
  - Guardfile
144
186
  - LICENSE
145
187
  - README.md
188
+ - Rakefile
146
189
  - bin/console
147
190
  - lib/proforma/extended_evaluator.rb
148
191
  - lib/proforma/extended_evaluator/formatter.rb
@@ -150,7 +193,6 @@ files:
150
193
  - lib/proforma/extended_evaluator/version.rb
151
194
  - proforma-extended-evaluator.gemspec
152
195
  - spec/proforma/extended_evaluator/formatter_spec.rb
153
- - spec/proforma/extended_evaluator/resolver_spec.rb
154
196
  - spec/proforma/extended_evaluator_spec.rb
155
197
  - spec/spec_helper.rb
156
198
  homepage: https://github.com/bluemarblepayroll/proforma-extended-evaluator
@@ -178,6 +220,5 @@ specification_version: 4
178
220
  summary: Proforma evaluator plugin for nested object value resolution and text templating
179
221
  test_files:
180
222
  - spec/proforma/extended_evaluator/formatter_spec.rb
181
- - spec/proforma/extended_evaluator/resolver_spec.rb
182
223
  - spec/proforma/extended_evaluator_spec.rb
183
224
  - spec/spec_helper.rb
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- #
4
- # Copyright (c) 2019-present, Blue Marble Payroll, LLC
5
- #
6
- # This source code is licensed under the MIT license found in the
7
- # LICENSE file in the root directory of this source tree.
8
- #
9
-
10
- require 'spec_helper'
11
-
12
- describe Proforma::ExtendedEvaluator::Resolver do
13
- subject { described_class.new }
14
-
15
- context 'when input is a hash' do
16
- let(:input) { { 'id' => 1, demographics: { 'first' => 'Matt' } } }
17
-
18
- specify '#resolve gets correct value' do
19
- expect(subject.resolve(:id, input)).to eq(input['id'])
20
- expect(subject.resolve('id', input)).to eq(input['id'])
21
-
22
- expect(subject.resolve('demographics.first', input)).to eq(input.dig(:demographics, 'first'))
23
- end
24
- end
25
-
26
- context 'when input is an OpenStruct' do
27
- let(:input) do
28
- OpenStruct.new(
29
- id: 1,
30
- demographics: OpenStruct.new(
31
- first: 'Matt'
32
- )
33
- )
34
- end
35
-
36
- specify '#resolve gets correct value' do
37
- expect(subject.resolve(:id, input)).to eq(input.id)
38
- expect(subject.resolve('id', input)).to eq(input.id)
39
-
40
- expect(subject.resolve('demographics.first', input)).to eq(input.demographics.first)
41
- end
42
- end
43
- end