bullet_train-api 1.6.23 → 1.6.24

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: 1408a5f8a1cd991f433fdbe440207296f58513d23c35210e04b38cefc4f8e723
4
- data.tar.gz: 643696920dbccb4855509436a9bfdb6dc9a4de5a83674bed38fa18f27fbcb0cc
3
+ metadata.gz: d804ed1dce182c742eaea6f67f798bd160baa8e483e5bf0b778e2aaf53cfea7a
4
+ data.tar.gz: a979a3734abc96534ed39004f738415f064cd11ad4363044cc51002b51748fe4
5
5
  SHA512:
6
- metadata.gz: 612c965ce9f13b0b6735958babc3b43a5d33bd2a28b87173923014bddadb574b15c8d9543d06122947dad182987b1a620d2f1bef2627f9e6ebc9ad89d5df758a
7
- data.tar.gz: e861d158f819d3597b9cd2e2a649d68128326663e4c921104c6c6f3c36907e642255bba67a41619c715f72d7cb04349ed56c42642fae8c25234f9c989c96cfcb
6
+ metadata.gz: 9a6f2a8c49a6b17d12338c876a69443c6f2ccf7f604401d65f8541fb222528290de3a38b299c3d40590ef3294c3a70252e0220fde62c725f162145a621b13a65
7
+ data.tar.gz: 71c2c5a0ed25655ba970f3add908f418b252f525ea71f55b2af873c80128786c26bdd8caea75a098a6d0760c55e4b7eb4d566431d1825b08d22df123453eb666
@@ -27,18 +27,23 @@ module Api
27
27
  output = render("api/#{@version}/open_api/shared/paths", except: except)
28
28
  output = Scaffolding::Transformer.new(model.name, [parent&.name]).transform_string(output).html_safe
29
29
 
30
- custom_actions_file_path = "api/#{@version}/open_api/#{model.name.underscore.pluralize}/paths"
31
- output += render(custom_actions_file_path) if lookup_context.exists?(custom_actions_file_path, [], true)
32
-
33
- # There are some placeholders specific to this method that we still need to transform.
34
- model_symbol = model.name.underscore.tr("/", "_").to_sym
30
+ custom_actions_file_path = "api/#{@version}/open_api/#{model.model_name.collection}/paths"
31
+ custom_output = render(custom_actions_file_path).html_safe if lookup_context.exists?(custom_actions_file_path, [], true)
35
32
 
36
33
  FactoryBot::ExampleBot::REST_METHODS.each do |method|
37
- if (code = FactoryBot.send(method, model_symbol, version: @version))
34
+ if (code = FactoryBot.send(method, model.model_name.param_key.to_sym, version: @version))
38
35
  output.gsub!("🚅 #{method}", code)
36
+ custom_output&.gsub!("🚅 #{method}", code)
39
37
  end
40
38
  end
41
39
 
40
+ if custom_output
41
+ merge = deep_merge(YAML.load(output), YAML.load(custom_output)).to_yaml.html_safe
42
+ # YAML.load escapes emojis https://github.com/ruby/psych/issues/371
43
+ # Next line returns emojis back and removes yaml garbage
44
+ output = merge.gsub("---", "").gsub(/\\u[\da-f]{8}/i) { |m| [m[-8..].to_i(16)].pack("U") }
45
+ end
46
+
42
47
  indent(output, 1)
43
48
  end
44
49
 
@@ -147,5 +152,17 @@ module Api
147
152
  end
148
153
  end
149
154
  end
155
+
156
+ def deep_merge(hash1, hash2)
157
+ hash1.merge(hash2) do |_, old_val, new_val|
158
+ if old_val.is_a?(Hash) && new_val.is_a?(Hash)
159
+ deep_merge(old_val, new_val)
160
+ elsif old_val.is_a?(Array) && new_val.is_a?(Array)
161
+ (old_val + new_val).uniq
162
+ else
163
+ new_val
164
+ end
165
+ end
166
+ end
150
167
  end
151
168
  end
@@ -1,5 +1,5 @@
1
1
  module BulletTrain
2
2
  module Api
3
- VERSION = "1.6.23"
3
+ VERSION = "1.6.24"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bullet_train-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.23
4
+ version: 1.6.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-14 00:00:00.000000000 Z
11
+ date: 2024-01-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: standard