overmind 0.1.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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 9a0f475e911384af6f69897158bf8cd8418451e1b7b995b0ade28a59f8a772c4
4
+ data.tar.gz: 800847132dd8cbd2652644d352034868ca611179165bdbdd9b811df2158a43d5
5
+ SHA512:
6
+ metadata.gz: 61911ff8ef159b205a7b340c88a2bfb8e914e7152f9253ccdc8272ead0d2a122d2e9fb774530df5f43e9a5b755984dea9f766556afc15e29879e34f1098c2dd8
7
+ data.tar.gz: 5e5762893c708b8ce597993d0ab47568b045980361115100c7ed23b0944706b6c0de3de3b8e27d0f2980c3cef8f15536c0a281a603eb024434d29c33a4805de8
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2024 prog-supdex
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
13
+ all 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
21
+ THE SOFTWARE.
data/bin/overmind ADDED
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'overmind/cli'
5
+
6
+ begin
7
+ cli = Overmind::CLI.new
8
+ exit_code = cli.run(ARGV)
9
+ exit exit_code
10
+ rescue StandardError => e
11
+ warn e.message
12
+ exit 1
13
+ end
@@ -0,0 +1,93 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Overmind
4
+ # Command-line interface for running golang library Overmind
5
+ # It ensures that the necessary dependencies, such as tmux, are present
6
+ # and runs Overmind with any provided arguments.
7
+ class CLI
8
+ SUPPORTED_OS_REGEX = /darwin|linux|bsd/i
9
+ # Path to the library's executable files
10
+ LIBRARY_PATH = File.expand_path("#{File.dirname(__FILE__)}/../../libexec")
11
+ OVERMIND_PATH = "#{LIBRARY_PATH}/overmind"
12
+ TMUX_FOLDER_PATH = "#{LIBRARY_PATH}/prebuilt-tmux/bin"
13
+ TMUX_PATH = "#{TMUX_FOLDER_PATH}/tmux"
14
+
15
+ def run(args = [])
16
+ os_validate!
17
+ validate_tmux_present!
18
+ validate_overmind_present!
19
+
20
+ # Ensures arguments are properly quoted if they contain spaces
21
+ args = args.map { |x| x.include?(" ") ? "'#{x}'" : x }
22
+
23
+ # Use prebuild tmux if found
24
+ path_with_tmux = File.exist?(TMUX_PATH) ? "#{ENV["PATH"]}:#{TMUX_FOLDER_PATH}" : ENV["PATH"]
25
+
26
+ # Spawns the Overmind process with modified PATH if necessary
27
+ pid = spawn({"PATH" => path_with_tmux}, "#{OVERMIND_PATH} #{args.join(" ")}")
28
+
29
+ Process.wait(pid)
30
+
31
+ $?.exitstatus
32
+ end
33
+
34
+ private
35
+
36
+ # Checks if the current OS is supported based on a regex match
37
+ def os_supported?
38
+ RUBY_PLATFORM.match?(SUPPORTED_OS_REGEX)
39
+ end
40
+
41
+ # Checks if tmux is installed either globally or as a prebuilt binary
42
+ def tmux_installed?
43
+ system("which tmux") || File.exist?(TMUX_PATH)
44
+ end
45
+
46
+ # Checks if the Overmind executable is present
47
+ def overmind_installed?
48
+ File.exist?(OVERMIND_PATH)
49
+ end
50
+
51
+ # Validates the operating system and aborts with an error message if unsupported
52
+ def os_validate!
53
+ return if os_supported?
54
+
55
+ abort_with_message("Error: This gem supports Linux, *BSD, and macOS only.")
56
+ end
57
+
58
+ # Validates the presence of tmux and aborts with an error message if not found
59
+ def validate_tmux_present!
60
+ return if tmux_installed?
61
+
62
+ abort_with_message(<<~MSG)
63
+ Error: tmux not found. Please ensure tmux is installed and available in PATH.
64
+ If tmux is not installed, you can usually install it using your package manager. For example:
65
+
66
+ # For Ubuntu/Debian
67
+ sudo apt-get install tmux
68
+ #{" "}
69
+ # For macOS
70
+ brew install tmux
71
+ #{" "}
72
+ # For FreeBSD
73
+ sudo pkg install tmux
74
+
75
+ Installation commands might vary based on your operating system and its version.#{" "}
76
+ Please consult your system's package management documentation for the most accurate instructions.
77
+ MSG
78
+ end
79
+
80
+ # Validates the presence of Overmind and aborts with an error message if not found
81
+ def validate_overmind_present!
82
+ return if overmind_installed?
83
+
84
+ abort_with_message("Error: Invalid platform. Overmind wasn't built for #{RUBY_PLATFORM}")
85
+ end
86
+
87
+ # Aborts execution with a given error message
88
+ def abort_with_message(message)
89
+ warn "\e[31m#{message}\e[0m"
90
+ exit 1
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Overmind
4
+ VERSION = "0.1.0"
5
+ end
data/lib/overmind.rb ADDED
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Overmind; end
data/libexec/overmind ADDED
Binary file
Binary file
data/overmind.gemspec ADDED
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/overmind/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "overmind"
7
+ spec.version = Overmind::VERSION
8
+ spec.authors = ["prog-supdex"]
9
+ spec.email = ["symeton@gmail.com"]
10
+
11
+ spec.summary = "Overmind is a process manager for Procfile-based applications and tmux."
12
+ spec.description = "Overmind is a process manager for Procfile-based applications and tmux."
13
+ spec.homepage = "https://github.com/DarthSim/overmind"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 0"
16
+
17
+ spec.metadata["homepage_uri"] = spec.homepage
18
+ spec.metadata["source_code_uri"] = "https://github.com/DarthSim/overmind"
19
+
20
+ # Specify which files should be added to the gem when it is released.
21
+ spec.files = Dir["bin/*", "lib/**/*.rb", "libexec/**/*", "overmind.gemspec", "LICENSE.txt"]
22
+ spec.bindir = "bin"
23
+ spec.executables = ["overmind"]
24
+ spec.require_paths = %w[lib libexec]
25
+
26
+ spec.add_development_dependency "bundler"
27
+ spec.add_development_dependency "rake", "~> 13.0"
28
+ spec.add_development_dependency "rspec", "~> 3.5"
29
+ end
metadata ADDED
@@ -0,0 +1,97 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: overmind
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - prog-supdex
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2024-03-07 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '13.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '13.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.5'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.5'
55
+ description: Overmind is a process manager for Procfile-based applications and tmux.
56
+ email:
57
+ - symeton@gmail.com
58
+ executables:
59
+ - overmind
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - LICENSE.txt
64
+ - bin/overmind
65
+ - lib/overmind.rb
66
+ - lib/overmind/cli.rb
67
+ - lib/overmind/version.rb
68
+ - libexec/overmind
69
+ - libexec/prebuilt-tmux/bin/tmux
70
+ - overmind.gemspec
71
+ homepage: https://github.com/DarthSim/overmind
72
+ licenses:
73
+ - MIT
74
+ metadata:
75
+ homepage_uri: https://github.com/DarthSim/overmind
76
+ source_code_uri: https://github.com/DarthSim/overmind
77
+ post_install_message:
78
+ rdoc_options: []
79
+ require_paths:
80
+ - lib
81
+ - libexec
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ required_rubygems_version: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ version: '0'
92
+ requirements: []
93
+ rubygems_version: 3.4.21
94
+ signing_key:
95
+ specification_version: 4
96
+ summary: Overmind is a process manager for Procfile-based applications and tmux.
97
+ test_files: []