bullet_train-api 1.6.27 → 1.6.28

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: e8773d252b03c1ebb3342c9ee21e302f2b7bd2e6732da748c407f7e0796002c1
4
- data.tar.gz: f7581ce2bc65fd5cd1f49324ddddb8b5936e1ee88bd431063cc82c253acc1c1f
3
+ metadata.gz: 3da820ecd4427cce764eab98c2b258a9677022ea138e990020176c1c16a5879f
4
+ data.tar.gz: 52fd62ced5483d47f5d4e31978a2788cfea8a46917e5d945eeffb0ebe203c18c
5
5
  SHA512:
6
- metadata.gz: b64ba34512b1443e2a4d314c63aa691d700d20f398f6eb3fafbe397dba225f8c4415564d5a57f990ed9146183ff7c1814104b78b14fdb862da8469216d4e2322
7
- data.tar.gz: 037ed5525018b8f23bc94cc737f1142991dbf3697c1501100e4361113a0db619b73550a5415db2845fb01b884af58ae4a688fbcc8d4c4e91008edda69237d1e7
6
+ metadata.gz: cb260cba10aaf616fa8b4ba8b7d3ab4f358dc384af7c860ff2d53389de318bfc46f9acdedde06d4cb8d4759b92b9dcff815d2c0f63bc8619e8020a062fa22c2f
7
+ data.tar.gz: c69f7552837e1706946a698ab6aa8ca470aa0b7f2a549d4ff2fe44e740ec58fa851e622979e684b080bb4f42517d75dc4972d9944e20354824e1737a10d337bc
@@ -38,8 +38,8 @@ module Api
38
38
  end
39
39
 
40
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
41
+ merge = deep_merge(YAML.safe_load(output), YAML.safe_load(custom_output)).to_yaml.html_safe
42
+ # YAML.safe_load escapes emojis https://github.com/ruby/psych/issues/371
43
43
  # Next line returns emojis back and removes yaml garbage
44
44
  output = merge.gsub("---", "").gsub(/\\u[\da-f]{8}/i) { |m| [m[-8..].to_i(16)].pack("U") }
45
45
  end
@@ -20,38 +20,56 @@ en:
20
20
  destroy: Are you sure you want to remove %{access_token_name}? This will break any active integrations using this token and can't be undone.
21
21
  fields: &fields
22
22
  id:
23
- heading: Access Token ID
23
+ heading: &id Access Token ID
24
+ api_title: *id
25
+ api_description: *id
24
26
  application_id:
25
- heading: Application ID
27
+ heading: &application_id Application ID
28
+ api_title: *application_id
29
+ api_description: *application_id
26
30
  token:
27
31
  _: &token Token
28
32
  label: *token
29
33
  heading: *token
34
+ api_title: *token
35
+ api_description: *token
30
36
  expires_in:
31
37
  _: &expires_in Expires In
32
38
  label: *expires_in
33
39
  heading: *expires_in
40
+ api_title: *expires_in
41
+ api_description: *expires_in
34
42
  scopes:
35
43
  _: &scopes Scopes
36
44
  label: *scopes
37
45
  heading: *scopes
46
+ api_title: *scopes
47
+ api_description: *scopes
38
48
  last_used_at:
39
49
  _: &last_used_at Last Used At
40
50
  label: *last_used_at
41
51
  heading: *last_used_at
52
+ api_title: *last_used_at
53
+ api_description: *last_used_at
42
54
  description:
43
55
  _: &description Description
44
56
  label: *description
45
57
  heading: *description
58
+ api_title: *description
59
+ api_description: *description
46
60
  # 🚅 super scaffolding will insert new fields above this line.
47
61
  created_at:
48
62
  _: &created_at Created
49
63
  label: *created_at
50
64
  heading: *created_at
65
+ api_title: *created_at
66
+ api_description: *created_at
51
67
  updated_at:
52
68
  _: &updated_at Updated
53
69
  label: *updated_at
54
70
  heading: *updated_at
71
+ api_title: *updated_at
72
+ api_description: *updated_at
55
73
  api:
56
74
  collection_actions: "Collection Actions for Access Tokens"
57
75
  index: "List Access Tokens"
@@ -24,32 +24,46 @@ en:
24
24
  name:
25
25
  _: &name Name
26
26
  label: *name
27
- heading: Application Name
27
+ heading: &application_name Application Name
28
+ api_title: *application_name
29
+ api_description: *application_name
28
30
 
29
31
  redirect_uri:
30
32
  _: &redirect_uri Redirect URI
31
33
  label: *redirect_uri
32
34
  heading: *redirect_uri
35
+ api_title: *redirect_uri
36
+ api_description: *redirect_uri
33
37
  help: This is only required if you're building an OAuth2-powered integration for other users.
34
38
 
35
39
  uid:
36
- heading: Client UID
40
+ heading: &uid Client UID
41
+ api_title: *uid
42
+ api_description: *uid
37
43
 
38
44
  secret:
39
- heading: Client Secret
45
+ heading: &secret Client Secret
46
+ api_title: *secret
47
+ api_description: *secret
40
48
 
41
49
  label_string:
42
- heading: Application Name
50
+ heading: *application_name
51
+ api_title: *application_name
52
+ api_description: *application_name
43
53
 
44
54
  # 🚅 super scaffolding will insert new fields above this line.
45
55
  created_at:
46
56
  _: &created_at Added
47
57
  label: *created_at
48
58
  heading: *created_at
59
+ api_title: *created_at
60
+ api_description: *created_at
49
61
  updated_at:
50
62
  _: &updated_at Updated
51
63
  label: *updated_at
52
64
  heading: *updated_at
65
+ api_title: *updated_at
66
+ api_description: *updated_at
53
67
  index:
54
68
  section: "%{teams_possessive} Platform Applications"
55
69
  contexts:
@@ -1,5 +1,5 @@
1
1
  module BulletTrain
2
2
  module Api
3
- VERSION = "1.6.27"
3
+ VERSION = "1.6.28"
4
4
  end
5
5
  end
@@ -146,5 +146,103 @@ namespace :bullet_train do
146
146
  )
147
147
  end
148
148
  end
149
+
150
+ desc "Create `api_title` and `api_description` translations"
151
+ task create_translations: :environment do
152
+ # Define the root of the locales directory
153
+ locales_root = Rails.root.join("config", "locales").to_s
154
+
155
+ # Define the backup directory
156
+ backup_dir = Rails.root.join("tmp", "locales_backup")
157
+ FileUtils.mkdir_p(backup_dir) unless Dir.exist?(backup_dir)
158
+
159
+ original_files = Dir.glob("#{locales_root}/**/*.yml")
160
+ differing_files_count = 0
161
+
162
+ original_files.each do |file|
163
+ puts "Processing #{file}..."
164
+
165
+ lines = File.readlines(file)
166
+ new_content = []
167
+ inside_fields = false
168
+ current_field = nil
169
+ fields_indentation = 4
170
+ api_title_exists = false
171
+ api_description_exists = false
172
+
173
+ # Read the entire file as a string
174
+ lines.each_with_index do |line, index|
175
+ # fields are always under locale:model:
176
+ if line.start_with?("#{" " * fields_indentation}fields:")
177
+ inside_fields = true
178
+ new_content << line
179
+ next
180
+ end
181
+
182
+ if inside_fields
183
+ current_indentation = line.index(/\S/) || 0
184
+ if current_indentation <= fields_indentation
185
+ # We've exited the fields block
186
+ inside_fields = false
187
+ current_field = nil
188
+ elsif current_indentation == fields_indentation + 2
189
+ # We're on a line with a field name
190
+ current_field = line.strip.split(":").first
191
+
192
+ api_title_exists = false
193
+ api_description_exists = false
194
+
195
+ n = 1
196
+ until index + n >= lines.length || (lines[index + n].index(/\S/) || 0) <= fields_indentation
197
+ if lines[index + n].strip.start_with?("api_title:")
198
+ api_title_exists = true
199
+ elsif lines[index + n].strip.start_with?("api_description:")
200
+ api_description_exists = true
201
+ end
202
+ n += 1
203
+ end
204
+
205
+ elsif current_field && line.strip.start_with?("heading:")
206
+ heading_value = line.split(":").last&.strip
207
+ indent = " " * current_indentation
208
+
209
+ if heading_value&.start_with?("&", "*")
210
+ new_content << line
211
+ else
212
+ heading_value = "&#{current_field} #{heading_value}"
213
+ new_content << "#{indent}heading: #{heading_value}\n"
214
+ end
215
+
216
+ field_key = heading_value[1..]&.split(" ")&.first
217
+ new_content << "#{indent}api_title: *#{field_key}\n" unless api_title_exists
218
+ new_content << "#{indent}api_description: *#{field_key}\n" unless api_description_exists
219
+
220
+ next
221
+ end
222
+ end
223
+
224
+ new_content << line
225
+ end
226
+
227
+ # Only write to file if there are changes
228
+ unless lines.join == new_content.join
229
+ differing_files_count += 1
230
+
231
+ # Compute the relative path manually
232
+ relative_path = file.sub(/^#{Regexp.escape(locales_root)}\/?/, "")
233
+
234
+ backup_path = File.join(backup_dir, relative_path)
235
+ FileUtils.mkdir_p(File.dirname(backup_path))
236
+ FileUtils.cp(file, backup_path)
237
+ puts "↳ Updating, backup created: #{backup_path}"
238
+
239
+ # Write the updated data back to the file
240
+ File.write(file, new_content.join)
241
+ end
242
+ end
243
+
244
+ puts "---"
245
+ puts "Total files updated: #{differing_files_count}/#{original_files.size}"
246
+ end
149
247
  end
150
248
  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.27
4
+ version: 1.6.28
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Culver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-19 00:00:00.000000000 Z
11
+ date: 2024-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: standard
@@ -246,7 +246,9 @@ licenses:
246
246
  metadata:
247
247
  homepage_uri: https://github.com/bullet-train-co/bullet_train-core/tree/main/bullet_train-api
248
248
  source_code_uri: https://github.com/bullet-train-co/bullet_train-core/tree/main/bullet_train-api
249
- post_install_message:
249
+ post_install_message: "\n Bullet Train is switching to separate translations for
250
+ API documentation.\n To automatically update existing translations, run once:\n\n
251
+ \ bundle exec rake bullet_train:api:create_translations\n\n "
250
252
  rdoc_options: []
251
253
  require_paths:
252
254
  - lib