ferryboat 0.1.3 → 0.1.5

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: fdc6d5593bb5c8e80755aa06380ddd8f3096d1569d7a7fc5561f9c943e9c9fc3
4
- data.tar.gz: cdbb2b13faabcd143ba1c38b2a0571c6bb384a7b582cc7f7a72239b74b0c69ce
3
+ metadata.gz: 78ec8e08a0bd5b2267b5105ecfb141d84f9676fb97d46f1bae3bec54b902ad6c
4
+ data.tar.gz: bc74ed346fb5ac26e51822be2a7618fd7796e50405bc41c736a9e8d341f9025c
5
5
  SHA512:
6
- metadata.gz: 349532f647384780b9c39d9753589139aeec49067399b507b0d20b72574afdca1e2a46a8bd878d676027bb87f0ce7f7b8e4fed8c883882bd4cc86384d75636ee
7
- data.tar.gz: 705168fb7067e2cb0a6cb942fe8d558aa8026459f48c2f4c2f66e47d46d40da94418aa41802e08f25ca09da4ce2950734450ae8351ec124f8766ac54fceac635
6
+ metadata.gz: 0a438ac5e1db9b658dc1ebd827b5d5bb2a12442880611ad7db8b8d9bda3f9aae6905c478a189b14fd51da2cafe0ebd00eab47f288a32dd820a1bc5efbf19925e
7
+ data.tar.gz: 396a35fdf33e28ddabe7421a6a07fac4fbab754ebb747313a5f5494b19cb702469650793f4b6094b63a7af6793c9b0081e58be4ca81a1bb0cd55d28c32520ef5
@@ -11,41 +11,44 @@ module Ferryboat
11
11
 
12
12
  REQUIRED_KEYS = %i[service image_repo domain].freeze
13
13
 
14
- def self.from_env(env: ENV.fetch("FERRY_ENV", "production"))
15
- new(
16
- env: env,
17
- service: ENV.fetch("FERRY_SERVICE", nil),
18
- image_repo: ENV.fetch("FERRY_IMAGE", nil),
19
- domain: ENV.fetch("FERRY_DOMAIN", nil),
20
- host: ENV.fetch("FERRY_HOST", "localhost"),
21
- provider: ENV.fetch("FERRY_PROVIDER", "docker"), # docker|kamal
22
- git_url: ENV["GIT_URL"],
23
- git_branch: ENV.fetch("GIT_BRANCH", "main"),
24
- health_path: ENV.fetch("FERRY_HEALTH_PATH", "/up"),
25
- health_timeout: Integer(ENV.fetch("FERRY_HEALTH_TIMEOUT", "120")),
26
- detect_timeout: Integer(ENV.fetch("FERRY_TRAEFIK_DETECT_TIMEOUT", "60")),
27
- auto_backup: ENV["FERRY_AUTO_BACKUP"] == "true"
28
- )
29
- end
14
+ class << self
15
+ def from_env(env: ENV.fetch("FERRY_ENV", "production"))
16
+ new(
17
+ env: env,
18
+ service: ENV.fetch("FERRY_SERVICE", nil),
19
+ image_repo: ENV.fetch("FERRY_IMAGE", nil),
20
+ domain: ENV.fetch("FERRY_DOMAIN", nil),
21
+ host: ENV.fetch("FERRY_HOST", "localhost"),
22
+ provider: ENV.fetch("FERRY_PROVIDER", "docker"), # docker|kamal
23
+ git_url: ENV["GIT_URL"],
24
+ git_branch: ENV.fetch("GIT_BRANCH", "main"),
25
+ health_path: ENV.fetch("FERRY_HEALTH_PATH", "/up"),
26
+ health_timeout: Integer(ENV.fetch("FERRY_HEALTH_TIMEOUT", "120")),
27
+ detect_timeout: Integer(ENV.fetch("FERRY_TRAEFIK_DETECT_TIMEOUT", "60")),
28
+ auto_backup: ENV["FERRY_AUTO_BACKUP"] == "true"
29
+ )
30
+ end
31
+
32
+ # Optional YAML loader (keeps env override semantics)
33
+ def from_file(path, env: "production")
34
+ data = File.exist?(path) ? (YAML.load_file(path) || {}) : {}
35
+ config = data[env] || data[env.to_s] || data[env.to_sym] || {}
30
36
 
31
- # Optional YAML loader (keeps env override semantics)
32
- def self.from_file(path, env: "production")
33
- data = YAML.load_file(path)
34
- cfg = (data[env] || {})
35
- new(
36
- env: env,
37
- service: ENV["FERRY_SERVICE"] || cfg["service"],
38
- image_repo: ENV["FERRY_IMAGE"] || cfg["image_repo"] || cfg["docker_registry"],
39
- domain: ENV["FERRY_DOMAIN"] || cfg["domain"],
40
- host: ENV["FERRY_HOST"] || cfg["host"] || "localhost",
41
- provider: ENV["FERRY_PROVIDER"] || cfg["provider"] || "docker",
42
- git_url: ENV["GIT_URL"] || cfg["git_url"],
43
- git_branch: ENV["GIT_BRANCH"] || cfg["git_branch"] || "main",
44
- health_path: ENV["FERRY_HEALTH_PATH"] || cfg["health_path"] || "/up",
45
- health_timeout: Integer(ENV["FERRY_HEALTH_TIMEOUT"] || cfg["health_timeout"] || 120),
46
- detect_timeout: Integer(ENV["FERRY_TRAEFIK_DETECT_TIMEOUT"] || cfg["detect_timeout"] || 60),
47
- auto_backup: (ENV["FERRY_AUTO_BACKUP"] || cfg["auto_backup"]).to_s == "true"
48
- )
37
+ new(
38
+ env: env,
39
+ service: ENV["FERRY_SERVICE"] || config["service"],
40
+ image_repo: ENV["FERRY_IMAGE"] || config["image_repo"] || config["docker_registry"],
41
+ domain: ENV["FERRY_DOMAIN"] || config["domain"],
42
+ host: ENV["FERRY_HOST"] || config["host"] || "localhost",
43
+ provider: ENV["FERRY_PROVIDER"] || config["provider"] || "docker",
44
+ git_url: ENV["GIT_URL"] || config["git_url"],
45
+ git_branch: ENV["GIT_BRANCH"] || config["git_branch"] || "main",
46
+ health_path: ENV["FERRY_HEALTH_PATH"] || config["health_path"] || "/up",
47
+ health_timeout: Integer(ENV["FERRY_HEALTH_TIMEOUT"] || config["health_timeout"] || 120),
48
+ detect_timeout: Integer(ENV["FERRY_TRAEFIK_DETECT_TIMEOUT"] || config["detect_timeout"] || 60),
49
+ auto_backup: (ENV["FERRY_AUTO_BACKUP"] || config["auto_backup"]).to_s == "true"
50
+ )
51
+ end
49
52
  end
50
53
 
51
54
  def initialize(env:, service:, image_repo:, domain:, host:, provider:, git_url:, git_branch:, health_path:, health_timeout:, detect_timeout:, auto_backup:)
@@ -59,11 +62,11 @@ module Ferryboat
59
62
 
60
63
  def validate!
61
64
  missing = []
62
- missing << :service if blank?(service)
63
- missing << :image_repo if blank?(image_repo)
64
- missing << :domain if blank?(domain)
65
- return true if missing.empty?
66
- raise ArgumentError, "Missing required config: #{missing.join(', ')}"
65
+ missing << :service if blank?(service)
66
+ missing << :image_repo if blank?(image_repo)
67
+ missing << :domain if blank?(domain)
68
+ raise ArgumentError, "Missing required config: #{missing.join(', ')}" unless missing.empty?
69
+ true
67
70
  end
68
71
 
69
72
  def provider_runner
@@ -85,6 +88,8 @@ module Ferryboat
85
88
 
86
89
  private
87
90
 
88
- def blank?(s) = s.nil? || s.to_s.strip.empty?
91
+ def blank?(v)
92
+ v.nil? || v.to_s.strip.empty?
93
+ end
89
94
  end
90
95
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ferryboat
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.5"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ferryboat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - 21tycoons