overmind 0.1.1 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 583c665185ac9a2c43d196b8799addfb00418fce5b9cfd1f5ea58bf5a62578ac
4
- data.tar.gz: 178f5d61807ce18e20c76c7002a2a1bf3b6f310f82253c580aa93f86c1203d3a
3
+ metadata.gz: b93d653a8fa2ff13aefd30e4b235f37c674e4b7f8e1ae21156059a59ffd82dc1
4
+ data.tar.gz: fe695400e605e22fb6919f702bb4b14e6ff869ccfb92cde33e010ac8799cef8a
5
5
  SHA512:
6
- metadata.gz: 3a28e4adc006a1ea28c21f5bffb2701546a0d7ccf64b2da352e32464ccb6b607235035b8ef6e193acda0683f42eff787e5ef191e1fccff0174e54fa3b4b71a9e
7
- data.tar.gz: 5dd4723662ffba6565a118b600e1c8bf9e492403615fc213c9a7ae5be342093a14e3e8395e7c513b0f94517665bc47f9be5527868cca55da8b3991113c6e438e
6
+ metadata.gz: 2aed2f1d5c80c0a8b2d49303a1ed81257dadc745d5e051a3e17a11020282ba3b52a871fb54734f40ddf434bfb05853d34eaeb7ca1c9858133bfa18316fd40659
7
+ data.tar.gz: 183e19219c9524aec5033b724a64f2732cda4e669b7237113f716af67007bb56254a5fda5e8c29b9ec54ce23c96b8e14512414390e54fba1a1ae6ce16efdeb26
@@ -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) ? "#{TMUX_FOLDER_PATH}:#{ENV["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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Overmind
4
- VERSION = "0.1.1"
4
+ VERSION = "2.5.0"
5
5
  end
data/libexec/overmind CHANGED
Binary file
data/overmind.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = "Overmind is a process manager for Procfile-based applications and tmux."
13
13
  spec.homepage = "https://github.com/DarthSim/overmind"
14
14
  spec.license = "MIT"
15
- spec.required_ruby_version = ">= 0"
15
+ spec.required_ruby_version = ">= 2.3"
16
16
 
17
17
  spec.metadata["homepage_uri"] = spec.homepage
18
18
  spec.metadata["source_code_uri"] = "https://github.com/DarthSim/overmind"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: overmind
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 2.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - prog-supdex
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-11 00:00:00.000000000 Z
11
+ date: 2024-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -63,6 +63,7 @@ files:
63
63
  - LICENSE.txt
64
64
  - bin/overmind
65
65
  - lib/overmind.rb
66
+ - lib/overmind/cli.rb
66
67
  - lib/overmind/version.rb
67
68
  - libexec/overmind
68
69
  - libexec/prebuilt-tmux/bin/tmux
@@ -82,14 +83,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
82
83
  requirements:
83
84
  - - ">="
84
85
  - !ruby/object:Gem::Version
85
- version: '0'
86
+ version: '2.3'
86
87
  required_rubygems_version: !ruby/object:Gem::Requirement
87
88
  requirements:
88
89
  - - ">="
89
90
  - !ruby/object:Gem::Version
90
91
  version: '0'
91
92
  requirements: []
92
- rubygems_version: 3.4.21
93
+ rubygems_version: 3.2.3
93
94
  signing_key:
94
95
  specification_version: 4
95
96
  summary: Overmind is a process manager for Procfile-based applications and tmux.