lapsoss 0.1.0 → 0.2.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.
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "digest"
3
+ require 'digest'
4
4
 
5
5
  module Lapsoss
6
6
  # Release and version tracking system
@@ -16,7 +16,7 @@ module Lapsoss
16
16
  end
17
17
 
18
18
  def get_release_info
19
- now = Time.now
19
+ now = Time.zone.now
20
20
 
21
21
  # Return cached info if still valid
22
22
  if @cached_release_info && @cache_timestamp && (now - @cache_timestamp) < @cache_duration
@@ -28,34 +28,26 @@ module Lapsoss
28
28
 
29
29
  # Add custom version providers
30
30
  @version_providers.each do |provider|
31
- begin
32
- if provider_info = provider.call
33
- release_info.merge!(provider_info)
34
- end
35
- rescue StandardError => e
36
- warn "Release provider failed: #{e.message}"
31
+ if provider_info = provider.call
32
+ release_info.merge!(provider_info)
37
33
  end
34
+ rescue StandardError => e
35
+ warn "Release provider failed: #{e.message}"
38
36
  end
39
37
 
40
38
  # Add Git information
41
- if @git_enabled
42
- if git_info = detect_git_info
43
- release_info.merge!(git_info)
44
- end
39
+ if @git_enabled && (git_info = detect_git_info)
40
+ release_info.merge!(git_info)
45
41
  end
46
42
 
47
43
  # Add environment information
48
- if @environment_enabled
49
- if env_info = detect_environment_info
50
- release_info.merge!(env_info)
51
- end
44
+ if @environment_enabled && (env_info = detect_environment_info)
45
+ release_info.merge!(env_info)
52
46
  end
53
47
 
54
48
  # Add deployment information
55
- if @deployment_enabled
56
- if deployment_info = detect_deployment_info
57
- release_info.merge!(deployment_info)
58
- end
49
+ if @deployment_enabled && (deployment_info = detect_deployment_info)
50
+ release_info.merge!(deployment_info)
59
51
  end
60
52
 
61
53
  # Generate release ID if not provided
@@ -80,44 +72,42 @@ module Lapsoss
80
72
  private
81
73
 
82
74
  def detect_git_info
83
- return nil unless File.exist?(".git")
75
+ return nil unless File.exist?('.git')
84
76
 
85
77
  git_info = {}
86
78
 
87
79
  begin
88
80
  # Get current commit SHA
89
- commit_sha = execute_git_command("rev-parse HEAD")
81
+ commit_sha = execute_git_command('rev-parse HEAD')
90
82
  git_info[:commit_sha] = commit_sha if commit_sha
91
83
 
92
84
  # Get short commit SHA
93
- short_sha = execute_git_command("rev-parse --short HEAD")
85
+ short_sha = execute_git_command('rev-parse --short HEAD')
94
86
  git_info[:short_sha] = short_sha if short_sha
95
87
 
96
88
  # Get branch name
97
- branch = execute_git_command("rev-parse --abbrev-ref HEAD")
98
- git_info[:branch] = branch if branch && branch != "HEAD"
89
+ branch = execute_git_command('rev-parse --abbrev-ref HEAD')
90
+ git_info[:branch] = branch if branch && branch != 'HEAD'
99
91
 
100
92
  # Get commit timestamp
101
- commit_timestamp = execute_git_command("log -1 --format=%ct")
102
- if commit_timestamp && !commit_timestamp.empty?
103
- git_info[:commit_timestamp] = Time.at(commit_timestamp.to_i)
104
- end
93
+ commit_timestamp = execute_git_command('log -1 --format=%ct')
94
+ git_info[:commit_timestamp] = Time.zone.at(commit_timestamp.to_i) if commit_timestamp.present?
105
95
 
106
96
  # Get commit message
107
- commit_message = execute_git_command("log -1 --format=%s")
97
+ commit_message = execute_git_command('log -1 --format=%s')
108
98
  git_info[:commit_message] = commit_message if commit_message
109
99
 
110
100
  # Get committer info
111
- committer = execute_git_command("log -1 --format=%cn")
101
+ committer = execute_git_command('log -1 --format=%cn')
112
102
  git_info[:committer] = committer if committer
113
103
 
114
104
  # Get tag if on a tag
115
- tag = execute_git_command("describe --exact-match --tags HEAD 2>/dev/null")
116
- git_info[:tag] = tag if tag && !tag.empty?
105
+ tag = execute_git_command('describe --exact-match --tags HEAD 2>/dev/null')
106
+ git_info[:tag] = tag if tag.present?
117
107
 
118
108
  # Get latest tag
119
- latest_tag = execute_git_command("describe --tags --abbrev=0 2>/dev/null")
120
- git_info[:latest_tag] = latest_tag if latest_tag && !latest_tag.empty?
109
+ latest_tag = execute_git_command('describe --tags --abbrev=0 2>/dev/null')
110
+ git_info[:latest_tag] = latest_tag if latest_tag.present?
121
111
 
122
112
  # Get commits since latest tag
123
113
  if latest_tag
@@ -126,14 +116,12 @@ module Lapsoss
126
116
  end
127
117
 
128
118
  # Check if working directory is dirty
129
- git_status = execute_git_command("status --porcelain")
119
+ git_status = execute_git_command('status --porcelain')
130
120
  git_info[:dirty] = !git_status.empty? if git_status
131
121
 
132
122
  # Get remote URL
133
- remote_url = execute_git_command("config --get remote.origin.url")
134
- if remote_url
135
- git_info[:remote_url] = sanitize_remote_url(remote_url)
136
- end
123
+ remote_url = execute_git_command('config --get remote.origin.url')
124
+ git_info[:remote_url] = sanitize_remote_url(remote_url) if remote_url
137
125
 
138
126
  git_info
139
127
  rescue StandardError => e
@@ -146,19 +134,19 @@ module Lapsoss
146
134
  env_info = {}
147
135
 
148
136
  # Application version from common environment variables
149
- env_info[:app_version] = ENV["APP_VERSION"] if ENV["APP_VERSION"]
150
- env_info[:version] = ENV["VERSION"] if ENV["VERSION"]
137
+ env_info[:app_version] = ENV['APP_VERSION'] if ENV['APP_VERSION']
138
+ env_info[:version] = ENV['VERSION'] if ENV['VERSION']
151
139
 
152
140
  # Environment detection
153
141
  env_info[:environment] = detect_environment
154
142
 
155
143
  # Application name
156
- env_info[:app_name] = ENV["APP_NAME"] if ENV["APP_NAME"]
144
+ env_info[:app_name] = ENV['APP_NAME'] if ENV['APP_NAME']
157
145
 
158
146
  # Build information
159
- env_info[:build_number] = ENV["BUILD_NUMBER"] if ENV["BUILD_NUMBER"]
160
- env_info[:build_id] = ENV["BUILD_ID"] if ENV["BUILD_ID"]
161
- env_info[:build_url] = ENV["BUILD_URL"] if ENV["BUILD_URL"]
147
+ env_info[:build_number] = ENV['BUILD_NUMBER'] if ENV['BUILD_NUMBER']
148
+ env_info[:build_id] = ENV['BUILD_ID'] if ENV['BUILD_ID']
149
+ env_info[:build_url] = ENV['BUILD_URL'] if ENV['BUILD_URL']
162
150
 
163
151
  # CI/CD information
164
152
  env_info[:ci] = detect_ci_info
@@ -170,14 +158,14 @@ module Lapsoss
170
158
  deployment_info = {}
171
159
 
172
160
  # Deployment timestamp
173
- if ENV["DEPLOYMENT_TIME"]
174
- deployment_info[:deployment_time] = parse_time(ENV["DEPLOYMENT_TIME"])
175
- elsif ENV["DEPLOYED_AT"]
176
- deployment_info[:deployment_time] = parse_time(ENV["DEPLOYED_AT"])
161
+ if ENV['DEPLOYMENT_TIME']
162
+ deployment_info[:deployment_time] = parse_time(ENV['DEPLOYMENT_TIME'])
163
+ elsif ENV['DEPLOYED_AT']
164
+ deployment_info[:deployment_time] = parse_time(ENV['DEPLOYED_AT'])
177
165
  end
178
166
 
179
167
  # Deployment ID
180
- deployment_info[:deployment_id] = ENV["DEPLOYMENT_ID"] if ENV["DEPLOYMENT_ID"]
168
+ deployment_info[:deployment_id] = ENV['DEPLOYMENT_ID'] if ENV['DEPLOYMENT_ID']
181
169
 
182
170
  # Platform-specific detection
183
171
  deployment_info.merge!(detect_heroku_info)
@@ -191,113 +179,111 @@ module Lapsoss
191
179
  end
192
180
 
193
181
  def detect_environment
194
- return ENV["RAILS_ENV"] if ENV["RAILS_ENV"]
195
- return ENV["RACK_ENV"] if ENV["RACK_ENV"]
196
- return ENV["NODE_ENV"] if ENV["NODE_ENV"]
197
- return ENV["ENVIRONMENT"] if ENV["ENVIRONMENT"]
198
- return ENV["ENV"] if ENV["ENV"]
182
+ return ENV['RAILS_ENV'] if ENV['RAILS_ENV']
183
+ return ENV['RACK_ENV'] if ENV['RACK_ENV']
184
+ return ENV['NODE_ENV'] if ENV['NODE_ENV']
185
+ return ENV['ENVIRONMENT'] if ENV['ENVIRONMENT']
186
+ return ENV['ENV'] if ENV['ENV']
199
187
 
200
188
  # Try to detect from Rails if available
201
- if defined?(Rails) && Rails.respond_to?(:env)
202
- return Rails.env.to_s
203
- end
189
+ return Rails.env.to_s if defined?(Rails) && Rails.respond_to?(:env)
204
190
 
205
191
  # Default fallback
206
- "unknown"
192
+ 'unknown'
207
193
  end
208
194
 
209
195
  def detect_ci_info
210
196
  ci_info = {}
211
197
 
212
198
  # GitHub Actions
213
- if ENV["GITHUB_ACTIONS"]
214
- ci_info[:provider] = "github_actions"
215
- ci_info[:run_id] = ENV["GITHUB_RUN_ID"]
216
- ci_info[:run_number] = ENV["GITHUB_RUN_NUMBER"]
217
- ci_info[:workflow] = ENV["GITHUB_WORKFLOW"]
218
- ci_info[:actor] = ENV["GITHUB_ACTOR"]
219
- ci_info[:repository] = ENV["GITHUB_REPOSITORY"]
220
- ci_info[:ref] = ENV["GITHUB_REF"]
221
- ci_info[:sha] = ENV["GITHUB_SHA"]
199
+ if ENV['GITHUB_ACTIONS']
200
+ ci_info[:provider] = 'github_actions'
201
+ ci_info[:run_id] = ENV.fetch('GITHUB_RUN_ID', nil)
202
+ ci_info[:run_number] = ENV.fetch('GITHUB_RUN_NUMBER', nil)
203
+ ci_info[:workflow] = ENV.fetch('GITHUB_WORKFLOW', nil)
204
+ ci_info[:actor] = ENV.fetch('GITHUB_ACTOR', nil)
205
+ ci_info[:repository] = ENV.fetch('GITHUB_REPOSITORY', nil)
206
+ ci_info[:ref] = ENV.fetch('GITHUB_REF', nil)
207
+ ci_info[:sha] = ENV.fetch('GITHUB_SHA', nil)
222
208
  end
223
209
 
224
210
  # GitLab CI
225
- if ENV["GITLAB_CI"]
226
- ci_info[:provider] = "gitlab_ci"
227
- ci_info[:pipeline_id] = ENV["CI_PIPELINE_ID"]
228
- ci_info[:job_id] = ENV["CI_JOB_ID"]
229
- ci_info[:job_name] = ENV["CI_JOB_NAME"]
230
- ci_info[:commit_sha] = ENV["CI_COMMIT_SHA"]
231
- ci_info[:commit_ref] = ENV["CI_COMMIT_REF_NAME"]
232
- ci_info[:project_url] = ENV["CI_PROJECT_URL"]
211
+ if ENV['GITLAB_CI']
212
+ ci_info[:provider] = 'gitlab_ci'
213
+ ci_info[:pipeline_id] = ENV.fetch('CI_PIPELINE_ID', nil)
214
+ ci_info[:job_id] = ENV.fetch('CI_JOB_ID', nil)
215
+ ci_info[:job_name] = ENV.fetch('CI_JOB_NAME', nil)
216
+ ci_info[:commit_sha] = ENV.fetch('CI_COMMIT_SHA', nil)
217
+ ci_info[:commit_ref] = ENV.fetch('CI_COMMIT_REF_NAME', nil)
218
+ ci_info[:project_url] = ENV.fetch('CI_PROJECT_URL', nil)
233
219
  end
234
220
 
235
221
  # Jenkins
236
- if ENV["JENKINS_URL"]
237
- ci_info[:provider] = "jenkins"
238
- ci_info[:build_number] = ENV["BUILD_NUMBER"]
239
- ci_info[:build_id] = ENV["BUILD_ID"]
240
- ci_info[:job_name] = ENV["JOB_NAME"]
241
- ci_info[:build_url] = ENV["BUILD_URL"]
242
- ci_info[:git_commit] = ENV["GIT_COMMIT"]
243
- ci_info[:git_branch] = ENV["GIT_BRANCH"]
222
+ if ENV['JENKINS_URL']
223
+ ci_info[:provider] = 'jenkins'
224
+ ci_info[:build_number] = ENV.fetch('BUILD_NUMBER', nil)
225
+ ci_info[:build_id] = ENV.fetch('BUILD_ID', nil)
226
+ ci_info[:job_name] = ENV.fetch('JOB_NAME', nil)
227
+ ci_info[:build_url] = ENV.fetch('BUILD_URL', nil)
228
+ ci_info[:git_commit] = ENV.fetch('GIT_COMMIT', nil)
229
+ ci_info[:git_branch] = ENV.fetch('GIT_BRANCH', nil)
244
230
  end
245
231
 
246
232
  # CircleCI
247
- if ENV["CIRCLECI"]
248
- ci_info[:provider] = "circleci"
249
- ci_info[:build_num] = ENV["CIRCLE_BUILD_NUM"]
250
- ci_info[:workflow_id] = ENV["CIRCLE_WORKFLOW_ID"]
251
- ci_info[:job] = ENV["CIRCLE_JOB"]
252
- ci_info[:project_reponame] = ENV["CIRCLE_PROJECT_REPONAME"]
253
- ci_info[:sha1] = ENV["CIRCLE_SHA1"]
254
- ci_info[:branch] = ENV["CIRCLE_BRANCH"]
233
+ if ENV['CIRCLECI']
234
+ ci_info[:provider] = 'circleci'
235
+ ci_info[:build_num] = ENV.fetch('CIRCLE_BUILD_NUM', nil)
236
+ ci_info[:workflow_id] = ENV.fetch('CIRCLE_WORKFLOW_ID', nil)
237
+ ci_info[:job] = ENV.fetch('CIRCLE_JOB', nil)
238
+ ci_info[:project_reponame] = ENV.fetch('CIRCLE_PROJECT_REPONAME', nil)
239
+ ci_info[:sha1] = ENV.fetch('CIRCLE_SHA1', nil)
240
+ ci_info[:branch] = ENV.fetch('CIRCLE_BRANCH', nil)
255
241
  end
256
242
 
257
243
  # Travis CI
258
- if ENV["TRAVIS"]
259
- ci_info[:provider] = "travis"
260
- ci_info[:build_id] = ENV["TRAVIS_BUILD_ID"]
261
- ci_info[:build_number] = ENV["TRAVIS_BUILD_NUMBER"]
262
- ci_info[:job_id] = ENV["TRAVIS_JOB_ID"]
263
- ci_info[:commit] = ENV["TRAVIS_COMMIT"]
264
- ci_info[:branch] = ENV["TRAVIS_BRANCH"]
265
- ci_info[:tag] = ENV["TRAVIS_TAG"]
244
+ if ENV['TRAVIS']
245
+ ci_info[:provider] = 'travis'
246
+ ci_info[:build_id] = ENV.fetch('TRAVIS_BUILD_ID', nil)
247
+ ci_info[:build_number] = ENV.fetch('TRAVIS_BUILD_NUMBER', nil)
248
+ ci_info[:job_id] = ENV.fetch('TRAVIS_JOB_ID', nil)
249
+ ci_info[:commit] = ENV.fetch('TRAVIS_COMMIT', nil)
250
+ ci_info[:branch] = ENV.fetch('TRAVIS_BRANCH', nil)
251
+ ci_info[:tag] = ENV.fetch('TRAVIS_TAG', nil)
266
252
  end
267
253
 
268
254
  ci_info
269
255
  end
270
256
 
271
257
  def detect_heroku_info
272
- return {} unless ENV["HEROKU_APP_NAME"]
258
+ return {} unless ENV['HEROKU_APP_NAME']
273
259
 
274
260
  {
275
- platform: "heroku",
276
- app_name: ENV["HEROKU_APP_NAME"],
277
- dyno: ENV["DYNO"],
278
- slug_commit: ENV["HEROKU_SLUG_COMMIT"],
279
- release_version: ENV["HEROKU_RELEASE_VERSION"],
280
- slug_description: ENV["HEROKU_SLUG_DESCRIPTION"]
261
+ platform: 'heroku',
262
+ app_name: ENV.fetch('HEROKU_APP_NAME', nil),
263
+ dyno: ENV.fetch('DYNO', nil),
264
+ slug_commit: ENV.fetch('HEROKU_SLUG_COMMIT', nil),
265
+ release_version: ENV.fetch('HEROKU_RELEASE_VERSION', nil),
266
+ slug_description: ENV.fetch('HEROKU_SLUG_DESCRIPTION', nil)
281
267
  }
282
268
  end
283
269
 
284
270
  def detect_aws_info
285
271
  info = {}
286
272
 
287
- if ENV["AWS_EXECUTION_ENV"]
288
- info[:platform] = "aws"
289
- info[:execution_env] = ENV["AWS_EXECUTION_ENV"]
290
- info[:region] = ENV["AWS_REGION"] || ENV["AWS_DEFAULT_REGION"]
291
- info[:function_name] = ENV["AWS_LAMBDA_FUNCTION_NAME"]
292
- info[:function_version] = ENV["AWS_LAMBDA_FUNCTION_VERSION"]
273
+ if ENV['AWS_EXECUTION_ENV']
274
+ info[:platform] = 'aws'
275
+ info[:execution_env] = ENV['AWS_EXECUTION_ENV']
276
+ info[:region] = ENV['AWS_REGION'] || ENV.fetch('AWS_DEFAULT_REGION', nil)
277
+ info[:function_name] = ENV.fetch('AWS_LAMBDA_FUNCTION_NAME', nil)
278
+ info[:function_version] = ENV.fetch('AWS_LAMBDA_FUNCTION_VERSION', nil)
293
279
  end
294
280
 
295
281
  # EC2 metadata (if available)
296
- if ENV["EC2_INSTANCE_ID"]
297
- info[:platform] = "aws_ec2"
298
- info[:instance_id] = ENV["EC2_INSTANCE_ID"]
299
- info[:instance_type] = ENV["EC2_INSTANCE_TYPE"]
300
- info[:availability_zone] = ENV["EC2_AVAILABILITY_ZONE"]
282
+ if ENV['EC2_INSTANCE_ID']
283
+ info[:platform] = 'aws_ec2'
284
+ info[:instance_id] = ENV['EC2_INSTANCE_ID']
285
+ info[:instance_type] = ENV.fetch('EC2_INSTANCE_TYPE', nil)
286
+ info[:availability_zone] = ENV.fetch('EC2_AVAILABILITY_ZONE', nil)
301
287
  end
302
288
 
303
289
  info
@@ -306,21 +292,21 @@ module Lapsoss
306
292
  def detect_gcp_info
307
293
  info = {}
308
294
 
309
- if ENV["GOOGLE_CLOUD_PROJECT"]
310
- info[:platform] = "gcp"
311
- info[:project] = ENV["GOOGLE_CLOUD_PROJECT"]
312
- info[:region] = ENV["GOOGLE_CLOUD_REGION"]
313
- info[:function_name] = ENV["FUNCTION_NAME"]
314
- info[:function_signature_type] = ENV["FUNCTION_SIGNATURE_TYPE"]
295
+ if ENV['GOOGLE_CLOUD_PROJECT']
296
+ info[:platform] = 'gcp'
297
+ info[:project] = ENV['GOOGLE_CLOUD_PROJECT']
298
+ info[:region] = ENV.fetch('GOOGLE_CLOUD_REGION', nil)
299
+ info[:function_name] = ENV.fetch('FUNCTION_NAME', nil)
300
+ info[:function_signature_type] = ENV.fetch('FUNCTION_SIGNATURE_TYPE', nil)
315
301
  end
316
302
 
317
303
  # App Engine
318
- if ENV["GAE_APPLICATION"]
319
- info[:platform] = "gcp_app_engine"
320
- info[:application] = ENV["GAE_APPLICATION"]
321
- info[:service] = ENV["GAE_SERVICE"]
322
- info[:version] = ENV["GAE_VERSION"]
323
- info[:runtime] = ENV["GAE_RUNTIME"]
304
+ if ENV['GAE_APPLICATION']
305
+ info[:platform] = 'gcp_app_engine'
306
+ info[:application] = ENV['GAE_APPLICATION']
307
+ info[:service] = ENV.fetch('GAE_SERVICE', nil)
308
+ info[:version] = ENV.fetch('GAE_VERSION', nil)
309
+ info[:runtime] = ENV.fetch('GAE_RUNTIME', nil)
324
310
  end
325
311
 
326
312
  info
@@ -329,12 +315,12 @@ module Lapsoss
329
315
  def detect_azure_info
330
316
  info = {}
331
317
 
332
- if ENV["WEBSITE_SITE_NAME"]
333
- info[:platform] = "azure"
334
- info[:site_name] = ENV["WEBSITE_SITE_NAME"]
335
- info[:resource_group] = ENV["WEBSITE_RESOURCE_GROUP"]
336
- info[:subscription_id] = ENV["WEBSITE_OWNER_NAME"]
337
- info[:sku] = ENV["WEBSITE_SKU"]
318
+ if ENV['WEBSITE_SITE_NAME']
319
+ info[:platform] = 'azure'
320
+ info[:site_name] = ENV['WEBSITE_SITE_NAME']
321
+ info[:resource_group] = ENV.fetch('WEBSITE_RESOURCE_GROUP', nil)
322
+ info[:subscription_id] = ENV.fetch('WEBSITE_OWNER_NAME', nil)
323
+ info[:sku] = ENV.fetch('WEBSITE_SKU', nil)
338
324
  end
339
325
 
340
326
  info
@@ -343,11 +329,11 @@ module Lapsoss
343
329
  def detect_docker_info
344
330
  info = {}
345
331
 
346
- if ENV["DOCKER_CONTAINER_ID"] || File.exist?("/.dockerenv")
347
- info[:platform] = "docker"
348
- info[:container_id] = ENV["DOCKER_CONTAINER_ID"]
349
- info[:image] = ENV["DOCKER_IMAGE"]
350
- info[:tag] = ENV["DOCKER_TAG"]
332
+ if ENV['DOCKER_CONTAINER_ID'] || File.exist?('/.dockerenv')
333
+ info[:platform] = 'docker'
334
+ info[:container_id] = ENV['DOCKER_CONTAINER_ID']
335
+ info[:image] = ENV.fetch('DOCKER_IMAGE', nil)
336
+ info[:tag] = ENV.fetch('DOCKER_TAG', nil)
351
337
  end
352
338
 
353
339
  info
@@ -356,13 +342,13 @@ module Lapsoss
356
342
  def detect_kubernetes_info
357
343
  info = {}
358
344
 
359
- if ENV["KUBERNETES_SERVICE_HOST"]
360
- info[:platform] = "kubernetes"
361
- info[:namespace] = ENV["KUBERNETES_NAMESPACE"]
362
- info[:pod_name] = ENV["HOSTNAME"]
363
- info[:service_account] = ENV["KUBERNETES_SERVICE_ACCOUNT"]
364
- info[:cluster_name] = ENV["CLUSTER_NAME"]
365
- info[:node_name] = ENV["NODE_NAME"]
345
+ if ENV['KUBERNETES_SERVICE_HOST']
346
+ info[:platform] = 'kubernetes'
347
+ info[:namespace] = ENV.fetch('KUBERNETES_NAMESPACE', nil)
348
+ info[:pod_name] = ENV.fetch('HOSTNAME', nil)
349
+ info[:service_account] = ENV.fetch('KUBERNETES_SERVICE_ACCOUNT', nil)
350
+ info[:cluster_name] = ENV.fetch('CLUSTER_NAME', nil)
351
+ info[:node_name] = ENV.fetch('NODE_NAME', nil)
366
352
  end
367
353
 
368
354
  info
@@ -377,7 +363,7 @@ module Lapsoss
377
363
 
378
364
  def sanitize_remote_url(url)
379
365
  # Remove credentials from Git URLs
380
- url.gsub(%r{://[^@/]+@}, "://")
366
+ url.gsub(%r{://[^@/]+@}, '://')
381
367
  end
382
368
 
383
369
  def parse_time(time_str)
@@ -385,24 +371,22 @@ module Lapsoss
385
371
 
386
372
  # Try different time formats
387
373
  formats = [
388
- "%Y-%m-%dT%H:%M:%S%z", # ISO 8601 with timezone
389
- "%Y-%m-%dT%H:%M:%SZ", # ISO 8601 UTC
390
- "%Y-%m-%d %H:%M:%S %z", # Standard format with timezone
391
- "%Y-%m-%d %H:%M:%S", # Standard format without timezone
392
- "%s" # Unix timestamp
374
+ '%Y-%m-%dT%H:%M:%S%z', # ISO 8601 with timezone
375
+ '%Y-%m-%dT%H:%M:%SZ', # ISO 8601 UTC
376
+ '%Y-%m-%d %H:%M:%S %z', # Standard format with timezone
377
+ '%Y-%m-%d %H:%M:%S', # Standard format without timezone
378
+ '%s' # Unix timestamp
393
379
  ]
394
380
 
395
381
  formats.each do |format|
396
- begin
397
- return Time.strptime(time_str, format)
398
- rescue ArgumentError
399
- next
400
- end
382
+ return Time.strptime(time_str, format)
383
+ rescue ArgumentError
384
+ next
401
385
  end
402
386
 
403
387
  # Try parsing as integer (Unix timestamp)
404
388
  begin
405
- return Time.at(time_str.to_i) if time_str.match?(/^\d+$/)
389
+ return Time.zone.at(time_str.to_i) if time_str.match?(/^\d+$/)
406
390
  rescue ArgumentError
407
391
  nil
408
392
  end
@@ -429,7 +413,7 @@ module Lapsoss
429
413
 
430
414
  # If we have components, join them
431
415
  if components.any?
432
- release_id = components.join("-")
416
+ release_id = components.join('-')
433
417
  # Truncate if too long
434
418
  release_id.length > 64 ? release_id[0, 64] : release_id
435
419
  else
@@ -461,20 +445,18 @@ module Lapsoss
461
445
 
462
446
  def self.from_ruby_constant(constant_name)
463
447
  lambda do
464
- begin
465
- constant = Object.const_get(constant_name)
466
- { version: constant.to_s }
467
- rescue NameError
468
- nil
469
- end
448
+ constant = Object.const_get(constant_name)
449
+ { version: constant.to_s }
450
+ rescue NameError
451
+ nil
470
452
  end
471
453
  end
472
454
 
473
455
  def self.from_gemfile_lock
474
456
  lambda do
475
- return nil unless File.exist?("Gemfile.lock")
457
+ return nil unless File.exist?('Gemfile.lock')
476
458
 
477
- content = File.read("Gemfile.lock")
459
+ content = File.read('Gemfile.lock')
478
460
 
479
461
  # Extract gems with versions
480
462
  gems = {}
@@ -488,14 +470,14 @@ module Lapsoss
488
470
 
489
471
  def self.from_package_json
490
472
  lambda do
491
- return nil unless File.exist?("package.json")
473
+ return nil unless File.exist?('package.json')
492
474
 
493
475
  begin
494
- package_info = JSON.parse(File.read("package.json"))
476
+ package_info = JSON.parse(File.read('package.json'))
495
477
  {
496
- version: package_info["version"],
497
- name: package_info["name"],
498
- dependencies: package_info["dependencies"]&.keys
478
+ version: package_info['version'],
479
+ name: package_info['name'],
480
+ dependencies: package_info['dependencies']&.keys
499
481
  }.compact
500
482
  rescue JSON::ParserError
501
483
  nil
@@ -517,14 +499,10 @@ module Lapsoss
517
499
  }
518
500
 
519
501
  # Get application version if defined
520
- if app.class.respond_to?(:version)
521
- info[:app_version] = app.class.version
522
- end
502
+ info[:app_version] = app.class.version if app.class.respond_to?(:version)
523
503
 
524
504
  # Get application name
525
- if app.class.respond_to?(:name)
526
- info[:app_name] = app.class.name
527
- end
505
+ info[:app_name] = app.class.name if app.class.respond_to?(:name)
528
506
 
529
507
  info
530
508
  end
@@ -542,7 +520,7 @@ module Lapsoss
542
520
  return {
543
521
  revision: revision,
544
522
  deployed_at: File.mtime(file),
545
- deployment_method: "capistrano"
523
+ deployment_method: 'capistrano'
546
524
  }
547
525
  end
548
526
 
@@ -9,11 +9,9 @@ module Lapsoss
9
9
  # @param event [Lapsoss::Event] The event to process.
10
10
  def process_event(event)
11
11
  Registry.instance.active.each do |adapter|
12
- begin
13
- adapter.capture(event)
14
- rescue => e
15
- handle_adapter_error(adapter, event, e)
16
- end
12
+ adapter.capture(event)
13
+ rescue StandardError => e
14
+ handle_adapter_error(adapter, event, e)
17
15
  end
18
16
  end
19
17