blueprinter 0.23.2 → 0.23.3

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: 783b36c0d89d672f0757327972b95b66f4338a759df7a7b3637cfea50ecc2b18
4
- data.tar.gz: 50e796b7d4f125bb415b6dead2ddfeda1785797d6be0fa63df2e1e56e8e390d0
3
+ metadata.gz: '04947d283f28536a499f609e8e25bb4f4ced350b75756b04dcbeb2de71100dc0'
4
+ data.tar.gz: ea71156a7134b1378fd829b0b1fd9712ab96b2b7c17d305ef5523e4872424038
5
5
  SHA512:
6
- metadata.gz: 9cfae50a0943d24d402409058d6b8f1e72972eaa7878778c6d1aff50cbd028d08acceba24289ba35d238c6915f607a45d0b94b84b61cb57caaf1f5ad9295e3e9
7
- data.tar.gz: 5bf9b8c90f10229245849682975d9a999d6aba0094f785cfa676f3fd02dc91587dab775ba2d874f42ad2ed992e50f47747f3c74347b31b90976727dd56fa0aa6
6
+ metadata.gz: 18148f52cda6a721e1b4c99d6b3d41d05bad040339d8c175ffd13f18cbd26dbde193541ebc7b42ce5a5cb6e421489741a1b6b780af3009ee850e87192f3edcea
7
+ data.tar.gz: a1b0a95d9a61be97eaffe45f39bb5347840c8dc8b48e553262e34039f79fced01454b6e867d13a2eb2709ad1f7f21915bd23143d77978404c5b382a914b1532f
@@ -1,3 +1,6 @@
1
+ ## 0.23.3 - 2019/4/7
2
+ * 🐛 [BUGFIX] Fixes issue where `exclude` fields in deeply nested views were not respected. Resolved issue [207](https://github.com/procore/blueprinter/issues/207) in [#208](https://github.com/procore/blueprinter/pull/208) by [@tpltn](https://github.com/tpltn).
3
+
1
4
  ## 0.23.2 - 2019/3/16
2
5
  * 🐛 [BUGFIX] Fixes issue where fields "bled" into other views due to merge side-effects. Resolved issue [205](https://github.com/procore/blueprinter/issues/205) in [#204](https://github.com/procore/blueprinter/pull/204) by [@trevorrjohn](https://github.com/trevorrjohn).
3
6
 
@@ -1,3 +1,3 @@
1
1
  module Blueprinter
2
- VERSION = '0.23.2'.freeze
2
+ VERSION = '0.23.3'.freeze
3
3
  end
@@ -23,9 +23,10 @@ module Blueprinter
23
23
  def fields_for(view_name)
24
24
  return identifier_fields if view_name == :identifier
25
25
 
26
- fields_hash = sortable_fields(view_name)
27
- sorted_fields = sort_by_definition ? sort_by_def(view_name, fields_hash) : fields_hash.values.sort_by(&:name)
28
- identifier_fields + sorted_fields
26
+ fields, excluded_fields = sortable_fields(view_name)
27
+ sorted_fields = sort_by_definition ? sort_by_def(view_name, fields) : fields.values.sort_by(&:name)
28
+
29
+ (identifier_fields + sorted_fields).reject { |field| excluded_fields.include?(field.name) }
29
30
  end
30
31
 
31
32
  def transformers(view_name)
@@ -42,20 +43,23 @@ module Blueprinter
42
43
  views[:identifier].fields.values
43
44
  end
44
45
 
46
+ # @param [String] view_name
47
+ # @return [Array<(Hash, Hash<String, NilClass>)>] fields, excluded_fields
45
48
  def sortable_fields(view_name)
49
+ excluded_fields = {}
46
50
  fields = views[:default].fields
47
51
  fields = merge_fields(fields, views[view_name].fields)
48
52
  views[view_name].included_view_names.each do |included_view_name|
49
- if view_name != included_view_name
50
- fields = merge_fields(fields, sortable_fields(included_view_name))
51
- end
52
- end
53
+ next if view_name == included_view_name
53
54
 
54
- views[view_name].excluded_field_names.each do |name|
55
- fields.delete(name)
55
+ view_fields, view_excluded_fields = sortable_fields(included_view_name)
56
+ fields = merge_fields(fields, view_fields)
57
+ excluded_fields.merge!(view_excluded_fields)
56
58
  end
57
59
 
58
- fields
60
+ views[view_name].excluded_field_names.each { |name| excluded_fields[name] = nil }
61
+
62
+ [fields, excluded_fields]
59
63
  end
60
64
 
61
65
  # select and order members of fields according to traversal of the definition_orders
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blueprinter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.2
4
+ version: 0.23.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Hess
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-03-16 00:00:00.000000000 Z
12
+ date: 2020-04-07 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: factory_bot
@@ -123,6 +123,20 @@ dependencies:
123
123
  - - "~>"
124
124
  - !ruby/object:Gem::Version
125
125
  version: '3.7'
126
+ - !ruby/object:Gem::Dependency
127
+ name: rspec-rails
128
+ requirement: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - "<"
131
+ - !ruby/object:Gem::Version
132
+ version: 4.0.0
133
+ type: :development
134
+ prerelease: false
135
+ version_requirements: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "<"
138
+ - !ruby/object:Gem::Version
139
+ version: 4.0.0
126
140
  - !ruby/object:Gem::Dependency
127
141
  name: sqlite3
128
142
  requirement: !ruby/object:Gem::Requirement