dagger_ruby 0.6.0 → 0.7.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +21 -0
- data/lib/dagger_ruby/config.rb +7 -7
- data/lib/dagger_ruby/container.rb +1 -1
- data/lib/dagger_ruby/directory.rb +1 -1
- data/lib/dagger_ruby/version.rb +1 -1
- data/lib/dagger_ruby.rb +56 -36
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b40c8d40fe3d5a0e8ee5aa6c8ca2b5e48f564117b03f9d11d482cd9fd47452ab
|
4
|
+
data.tar.gz: 020ed088da44bb8f8ca16316491d15b32de2d654ddc6cf67941d482b9a0c72e6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 855d15fd372059950028407385935085961a9f0488e1f38d8162253a1143caae51e0c2ac97a8ee913f7e2e38ad89dcdd49f6c766413c20741922117cc4c8c24d
|
7
|
+
data.tar.gz: b14cb681341a1b2db7c8c045658a16f1928c93049bb532afd393bc707e50c08a2f58e796d8a9636cb8741c55f3ecc4b51b262d21244067d9bc8be7565c164521
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,27 @@ All notable changes to this project will be documented in this file.
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
7
|
|
8
|
+
## [0.7.0] - 2025-01-27
|
9
|
+
|
10
|
+
### Fixed
|
11
|
+
|
12
|
+
- **Code Quality**: Refactored `DaggerRuby.connection` method to reduce cyclomatic complexity from 13 to under 12 and perceived complexity from 15 to under 12
|
13
|
+
- **Code Quality**: Simplified `Config#initialize` method by replacing 6 individual keyword parameters with a single hash parameter
|
14
|
+
- **Tests**: Fixed test assertion in `test_with_directory_mounts_directory` to align with Dagger API - changed from `"directory"` to `"source"` key in `withDirectory` operation arguments
|
15
|
+
- **Environment Variables**: Improved environment variable handling using `ENV.fetch` for more consistent nil handling
|
16
|
+
|
17
|
+
### Changed
|
18
|
+
|
19
|
+
- **Config Constructor**: `DaggerRuby::Config.new` now accepts a hash of options instead of individual keyword arguments
|
20
|
+
- Old: `Config.new(log_output: $stdout, workdir: "/tmp", timeout: 300)`
|
21
|
+
- New: `Config.new(log_output: $stdout, workdir: "/tmp", timeout: 300)` (same syntax, but internally uses hash)
|
22
|
+
|
23
|
+
### Technical Details
|
24
|
+
|
25
|
+
- Broke down complex `connection` method into focused helper methods: `existing_session?`, `handle_existing_session`, `start_new_session`, `build_dagger_command`, `build_ruby_command`, `build_dagger_options`
|
26
|
+
- Maintained backward compatibility - all existing code continues to work without changes
|
27
|
+
- All tests pass with improved code structure and maintainability
|
28
|
+
|
8
29
|
## [0.6.0] - 2025-09-17
|
9
30
|
|
10
31
|
Programmatic Control:
|
data/lib/dagger_ruby/config.rb
CHANGED
@@ -4,13 +4,13 @@ module DaggerRuby
|
|
4
4
|
class Config
|
5
5
|
attr_reader :log_output, :workdir, :timeout, :quiet, :silent, :progress
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
@log_output = log_output
|
9
|
-
@workdir = workdir
|
10
|
-
@timeout = timeout || 600
|
11
|
-
@quiet = quiet || ENV["DAGGER_QUIET"]&.to_i
|
12
|
-
@silent = silent || ENV["DAGGER_SILENT"] == "true"
|
13
|
-
@progress = progress || ENV.fetch("DAGGER_PROGRESS", nil)
|
7
|
+
def initialize(options = {})
|
8
|
+
@log_output = options[:log_output]
|
9
|
+
@workdir = options[:workdir]
|
10
|
+
@timeout = options[:timeout] || 600
|
11
|
+
@quiet = options[:quiet] || ENV["DAGGER_QUIET"]&.to_i
|
12
|
+
@silent = options[:silent] || ENV["DAGGER_SILENT"] == "true"
|
13
|
+
@progress = options[:progress] || ENV.fetch("DAGGER_PROGRESS", nil)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
@@ -19,7 +19,7 @@ module DaggerRuby
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def with_directory(path, directory, opts = {})
|
22
|
-
args = { "path" => path, "
|
22
|
+
args = { "path" => path, "source" => directory.is_a?(DaggerObject) ? directory.id : directory }
|
23
23
|
args["exclude"] = opts[:exclude] if opts[:exclude]
|
24
24
|
args["include"] = opts[:include] if opts[:include]
|
25
25
|
args["owner"] = opts[:owner] if opts[:owner]
|
@@ -29,7 +29,7 @@ module DaggerRuby
|
|
29
29
|
end
|
30
30
|
|
31
31
|
def with_directory(path, directory, opts = {})
|
32
|
-
args = { "path" => path, "
|
32
|
+
args = { "path" => path, "source" => directory.is_a?(DaggerObject) ? directory.id : directory }
|
33
33
|
args["exclude"] = opts[:exclude] if opts[:exclude]
|
34
34
|
args["include"] = opts[:include] if opts[:include]
|
35
35
|
|
data/lib/dagger_ruby/version.rb
CHANGED
data/lib/dagger_ruby.rb
CHANGED
@@ -8,45 +8,65 @@ require_relative "dagger_ruby/errors"
|
|
8
8
|
module DaggerRuby
|
9
9
|
class << self
|
10
10
|
def connection(config = nil)
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
11
|
+
if existing_session?
|
12
|
+
handle_existing_session(config)
|
13
|
+
else
|
14
|
+
start_new_session(config)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def existing_session?
|
21
|
+
ENV.fetch("DAGGER_SESSION_PORT", nil) && ENV.fetch("DAGGER_SESSION_TOKEN", nil)
|
22
|
+
end
|
23
|
+
|
24
|
+
def handle_existing_session(config)
|
25
|
+
client = Client.new(config: config)
|
26
|
+
if block_given?
|
27
|
+
begin
|
28
|
+
yield client
|
29
|
+
ensure
|
30
|
+
client.close
|
22
31
|
end
|
23
32
|
else
|
24
|
-
|
25
|
-
require "open3"
|
26
|
-
|
27
|
-
# Get the current script and its arguments
|
28
|
-
script = $PROGRAM_NAME
|
29
|
-
args = ARGV
|
30
|
-
|
31
|
-
# Construct the command that dagger should run
|
32
|
-
ruby_cmd = ["ruby", script, *args].join(" ")
|
33
|
-
|
34
|
-
# Get verbosity options from config or environment
|
35
|
-
quiet = config&.quiet || ENV["DAGGER_QUIET"]&.to_i
|
36
|
-
silent = config&.silent || ENV["DAGGER_SILENT"] == "true"
|
37
|
-
progress = config&.progress || ENV.fetch("DAGGER_PROGRESS", nil)
|
38
|
-
|
39
|
-
# Build dagger command with options
|
40
|
-
cmd_parts = ["dagger"]
|
41
|
-
cmd_parts += ["-q"] * quiet if quiet&.positive?
|
42
|
-
cmd_parts += ["--silent"] if silent
|
43
|
-
cmd_parts += ["--progress", progress] if progress
|
44
|
-
cmd_parts += ["run", ruby_cmd]
|
45
|
-
cmd = cmd_parts.join(" ")
|
46
|
-
|
47
|
-
# Execute the command
|
48
|
-
exec(cmd)
|
33
|
+
client
|
49
34
|
end
|
50
35
|
end
|
36
|
+
|
37
|
+
def start_new_session(config)
|
38
|
+
require "open3"
|
39
|
+
cmd = build_dagger_command(config)
|
40
|
+
exec(cmd)
|
41
|
+
end
|
42
|
+
|
43
|
+
def build_dagger_command(config)
|
44
|
+
ruby_cmd = build_ruby_command
|
45
|
+
dagger_options = build_dagger_options(config)
|
46
|
+
|
47
|
+
cmd_parts = ["dagger"] + dagger_options + ["run", ruby_cmd]
|
48
|
+
cmd_parts.join(" ")
|
49
|
+
end
|
50
|
+
|
51
|
+
def build_ruby_command
|
52
|
+
script = $PROGRAM_NAME
|
53
|
+
args = ARGV
|
54
|
+
["ruby", script, *args].join(" ")
|
55
|
+
end
|
56
|
+
|
57
|
+
def build_dagger_options(config)
|
58
|
+
options = []
|
59
|
+
|
60
|
+
quiet = config&.quiet || ENV["DAGGER_QUIET"]&.to_i
|
61
|
+
options += ["-q"] * quiet if quiet&.positive?
|
62
|
+
|
63
|
+
silent = config&.silent || ENV["DAGGER_SILENT"] == "true"
|
64
|
+
options += ["--silent"] if silent
|
65
|
+
|
66
|
+
progress = config&.progress || ENV.fetch("DAGGER_PROGRESS", nil)
|
67
|
+
options += ["--progress", progress] if progress
|
68
|
+
|
69
|
+
options
|
70
|
+
end
|
51
71
|
end
|
52
72
|
end
|