pipeops-rexec 1.0.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.
Files changed (5) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +21 -0
  3. data/README.md +211 -0
  4. data/lib/rexec.rb +35 -0
  5. metadata +134 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: daf648a63c80b783c7701b1543ba59903618e531b5560a484b6274d3dde81bb1
4
+ data.tar.gz: d02a328b6ace511f14c478d3928f79fd5be132624c9b23ee649c9e77f2e3b0ef
5
+ SHA512:
6
+ metadata.gz: d5e4289f26441de35cc62b9bbd10a354a4ed5b70ef541e90eab7fc9292402986a0e0e99fbc5f34220d4721a08fa1020f41d263f2c97b4b3bd338aac96b7ad91d
7
+ data.tar.gz: 892d324fd210063705b9722cff702c7680d4b972f6e8529ccbe27c4a84ae9f66cb6ce5acf1e21bc7769ff19ac9adc46fea1d6f0892589ae631dd69a99b0a2410
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-2026 PipeOpsHQ
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,211 @@
1
+ # Rexec Ruby SDK
2
+
3
+ Official Ruby SDK for [Rexec](https://github.com/PipeOpsHQ/rexec) - Terminal as a Service.
4
+
5
+ ## Installation
6
+
7
+ Add to your Gemfile:
8
+
9
+ ```ruby
10
+ gem 'pipeops-rexec'
11
+ ```
12
+
13
+ Or install directly:
14
+
15
+ ```bash
16
+ gem install pipeops-rexec
17
+ ```
18
+
19
+ ## Quick Start
20
+
21
+ ```ruby
22
+ require 'rexec'
23
+
24
+ client = Rexec::Client.new("https://your-instance.com", "your-token")
25
+
26
+ # Create a container
27
+ container = client.containers.create(
28
+ image: "ubuntu:24.04",
29
+ name: "my-sandbox"
30
+ )
31
+ puts "Created container: #{container.id}"
32
+
33
+ # Connect to terminal
34
+ terminal = client.terminal.connect(container.id)
35
+
36
+ terminal.on_data { |data| print data }
37
+ terminal.on_close { puts "\nConnection closed" }
38
+
39
+ terminal.write("echo 'Hello from Rexec!'\n")
40
+
41
+ sleep 2 # Wait for output
42
+
43
+ # Clean up
44
+ terminal.close
45
+ client.containers.delete(container.id)
46
+ ```
47
+
48
+ ## API Reference
49
+
50
+ ### Client
51
+
52
+ ```ruby
53
+ require 'rexec'
54
+
55
+ # Create client
56
+ client = Rexec::Client.new(
57
+ "https://your-instance.com",
58
+ "your-api-token",
59
+ timeout: 30 # optional
60
+ )
61
+ ```
62
+
63
+ ### Containers
64
+
65
+ ```ruby
66
+ # List all containers
67
+ containers = client.containers.list
68
+ containers.each do |c|
69
+ puts "#{c.name}: #{c.status}"
70
+ end
71
+
72
+ # Get a specific container
73
+ container = client.containers.get("container-id")
74
+
75
+ # Create a container
76
+ container = client.containers.create(
77
+ image: "ubuntu:24.04",
78
+ name: "my-container",
79
+ environment: { "MY_VAR" => "value" },
80
+ labels: { "project" => "demo" }
81
+ )
82
+
83
+ # Start a container
84
+ client.containers.start("container-id")
85
+
86
+ # Stop a container
87
+ client.containers.stop("container-id")
88
+
89
+ # Delete a container
90
+ client.containers.delete("container-id")
91
+ ```
92
+
93
+ ### Files
94
+
95
+ ```ruby
96
+ # List files in a directory
97
+ files = client.files.list("container-id", "/home")
98
+ files.each do |f|
99
+ icon = f.directory? ? "📁" : "📄"
100
+ puts "#{icon} #{f.name}"
101
+ end
102
+
103
+ # Download a file
104
+ content = client.files.download("container-id", "/etc/passwd")
105
+ puts content
106
+
107
+ # Create a directory
108
+ client.files.mkdir("container-id", "/home/mydir")
109
+
110
+ # Delete a file
111
+ client.files.delete("container-id", "/home/file.txt")
112
+ ```
113
+
114
+ ### Terminal
115
+
116
+ ```ruby
117
+ # Connect to terminal
118
+ terminal = client.terminal.connect("container-id", cols: 120, rows: 40)
119
+
120
+ # Send commands
121
+ terminal.write("ls -la\n")
122
+
123
+ # Handle output
124
+ terminal.on_data do |data|
125
+ print data
126
+ end
127
+
128
+ # Handle close
129
+ terminal.on_close do
130
+ puts "Connection closed"
131
+ end
132
+
133
+ # Handle errors
134
+ terminal.on_error do |error|
135
+ puts "Error: #{error}"
136
+ end
137
+
138
+ # Resize terminal
139
+ terminal.resize(150, 50)
140
+
141
+ # Close connection
142
+ terminal.close
143
+ ```
144
+
145
+ ## Examples
146
+
147
+ ### Run a Script
148
+
149
+ ```ruby
150
+ def run_script(client, container_id, script)
151
+ output = []
152
+ done = false
153
+
154
+ terminal = client.terminal.connect(container_id)
155
+
156
+ terminal.on_data { |data| output << data }
157
+ terminal.on_close { done = true }
158
+
159
+ terminal.write("#{script}\nexit\n")
160
+
161
+ sleep 0.1 until done
162
+
163
+ output.join
164
+ end
165
+
166
+ result = run_script(client, container.id, "apt update && apt install -y curl")
167
+ puts result
168
+ ```
169
+
170
+ ### Batch Operations
171
+
172
+ ```ruby
173
+ require 'concurrent'
174
+
175
+ def create_batch(client, count)
176
+ futures = (0...count).map do |i|
177
+ Concurrent::Future.execute do
178
+ client.containers.create(
179
+ image: "ubuntu:24.04",
180
+ name: "worker-#{i}"
181
+ )
182
+ end
183
+ end
184
+
185
+ futures.map(&:value)
186
+ end
187
+
188
+ containers = create_batch(client, 5)
189
+ ```
190
+
191
+ ## Error Handling
192
+
193
+ ```ruby
194
+ begin
195
+ container = client.containers.get("invalid-id")
196
+ rescue Rexec::APIError => e
197
+ puts "API Error #{e.status_code}: #{e.message}"
198
+ rescue Rexec::ConnectionError => e
199
+ puts "Connection Error: #{e.message}"
200
+ end
201
+ ```
202
+
203
+ ## Requirements
204
+
205
+ - Ruby 3.0+
206
+ - `faraday` for HTTP requests
207
+ - `websocket-client-simple` for terminal connections
208
+
209
+ ## License
210
+
211
+ MIT License - see [LICENSE](../../LICENSE) for details.
data/lib/rexec.rb ADDED
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "rexec/version"
4
+ require_relative "rexec/error"
5
+ require_relative "rexec/client"
6
+ require_relative "rexec/container"
7
+ require_relative "rexec/file_service"
8
+ require_relative "rexec/terminal"
9
+
10
+ # Rexec Ruby SDK - Official SDK for Rexec Terminal as a Service.
11
+ #
12
+ # @example Basic usage
13
+ # client = Rexec::Client.new("https://your-instance.com", "your-token")
14
+ #
15
+ # container = client.containers.create(image: "ubuntu:24.04")
16
+ # puts "Created: #{container.id}"
17
+ #
18
+ # terminal = client.terminal.connect(container.id)
19
+ # terminal.write("echo hello\n")
20
+ # terminal.on_data { |data| puts data }
21
+ #
22
+ # client.containers.delete(container.id)
23
+ #
24
+ module Rexec
25
+ class << self
26
+ # Create a new Rexec client.
27
+ #
28
+ # @param base_url [String] Base URL of your Rexec instance
29
+ # @param token [String] API token for authentication
30
+ # @return [Rexec::Client]
31
+ def new(base_url, token, **options)
32
+ Client.new(base_url, token, **options)
33
+ end
34
+ end
35
+ end
metadata ADDED
@@ -0,0 +1,134 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pipeops-rexec
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - PipeOpsHQ
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-08-01 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: faraday
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '2.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '2.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday-multipart
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: websocket-client-simple
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.8'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.8'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: yard
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.9'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.9'
97
+ description: Ruby SDK for interacting with Rexec sandboxed environments. Create containers,
98
+ execute commands, manage files, and connect to terminals.
99
+ email:
100
+ - support@pipeops.io
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - LICENSE
106
+ - README.md
107
+ - lib/rexec.rb
108
+ homepage: https://github.com/PipeOpsHQ/rexec
109
+ licenses:
110
+ - MIT
111
+ metadata:
112
+ homepage_uri: https://github.com/PipeOpsHQ/rexec
113
+ source_code_uri: https://github.com/PipeOpsHQ/rexec/tree/main/sdk/ruby
114
+ changelog_uri: https://github.com/PipeOpsHQ/rexec/blob/main/CHANGELOG.md
115
+ post_install_message:
116
+ rdoc_options: []
117
+ require_paths:
118
+ - lib
119
+ required_ruby_version: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: 3.0.0
124
+ required_rubygems_version: !ruby/object:Gem::Requirement
125
+ requirements:
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: '0'
129
+ requirements: []
130
+ rubygems_version: 3.4.19
131
+ signing_key:
132
+ specification_version: 4
133
+ summary: Official Ruby SDK for Rexec - Terminal as a Service
134
+ test_files: []