procmux 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.travis.yml +6 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +34 -0
- data/LICENSE.txt +21 -0
- data/README.md +40 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/procmux +16 -0
- data/lib/procmux.rb +6 -0
- data/lib/procmux/prox.rb +61 -0
- data/lib/procmux/version.rb +3 -0
- data/procmux.gemspec +29 -0
- metadata +61 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: '08c181e9849023cff3632f17a07fce9407a879f95ce983b03ba79e1627e19cb1'
|
4
|
+
data.tar.gz: b06145ee41ec9778acf3ef2175f4ca72d3603fda9944f65517cbf9f50f22949c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: c956bd81249f5c95be1fc6b6842fb694a80b7a429a664e397ff237cb6ae761b3e3825d470574ee666f78a4c4a0f9aa88c64213ee61141ed7ff868b0e0afab803
|
7
|
+
data.tar.gz: a57da68948d2494a1acc56f8e30c3b36a6223f29bf43f64be8262bdab0d2294365619e519c58f266221b862d906ce8b408857f57bbb117245382740bc663f82a
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
procmux (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.4.4)
|
10
|
+
rake (12.3.3)
|
11
|
+
rspec (3.9.0)
|
12
|
+
rspec-core (~> 3.9.0)
|
13
|
+
rspec-expectations (~> 3.9.0)
|
14
|
+
rspec-mocks (~> 3.9.0)
|
15
|
+
rspec-core (3.9.2)
|
16
|
+
rspec-support (~> 3.9.3)
|
17
|
+
rspec-expectations (3.9.2)
|
18
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
+
rspec-support (~> 3.9.0)
|
20
|
+
rspec-mocks (3.9.1)
|
21
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
+
rspec-support (~> 3.9.0)
|
23
|
+
rspec-support (3.9.3)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
procmux!
|
30
|
+
rake (~> 12.0)
|
31
|
+
rspec (~> 3.0)
|
32
|
+
|
33
|
+
BUNDLED WITH
|
34
|
+
2.1.4
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2020 lunarfyre7
|
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/README.md
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# Procmux
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/procmux`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'procmux'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install procmux
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/procmux.
|
36
|
+
|
37
|
+
|
38
|
+
## License
|
39
|
+
|
40
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "procmux"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/exe/procmux
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'optparse'
|
4
|
+
require 'procmux'
|
5
|
+
|
6
|
+
DEFAULT = 'Procfile'
|
7
|
+
|
8
|
+
options = {}
|
9
|
+
OptionParser.new do |opts|
|
10
|
+
opts.on('-fFILE', '--procfile=FILE') do |v|
|
11
|
+
options[:file] = v
|
12
|
+
end
|
13
|
+
end.parse!
|
14
|
+
|
15
|
+
pm = Procmux::Prox.new procfile: options[:file] || DEFAULT
|
16
|
+
pm.run!
|
data/lib/procmux.rb
ADDED
data/lib/procmux/prox.rb
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
module Procmux
|
2
|
+
ProcEntry = Struct.new(:label, :command)
|
3
|
+
PROC_RE = /(.*?):\s*(.*)/.freeze
|
4
|
+
|
5
|
+
class Prox
|
6
|
+
def initialize(procfile: nil, proclist: nil, session_name: nil)
|
7
|
+
@session = session_name || auto_session_name
|
8
|
+
parse_file procfile if procfile
|
9
|
+
parse proclist if proclist
|
10
|
+
`tmux start-server`
|
11
|
+
end
|
12
|
+
|
13
|
+
def run!
|
14
|
+
attach_to_tmux! if check_tmux_session_exists
|
15
|
+
|
16
|
+
start_tmux_session
|
17
|
+
populate_tmux_session
|
18
|
+
attach_to_tmux!
|
19
|
+
end
|
20
|
+
|
21
|
+
def auto_session_name
|
22
|
+
"proxmux_#{File.basename(Dir.pwd).gsub(/\s/, '_')}"
|
23
|
+
end
|
24
|
+
|
25
|
+
def parse(proclist)
|
26
|
+
proclist.is_a? String or raise ArgumentError, 'Proclist must be String'
|
27
|
+
|
28
|
+
@procs = proclist.lines
|
29
|
+
.lazy
|
30
|
+
.map(&:chomp)
|
31
|
+
.map { |line| ProcEntry.new(*line.match(PROC_RE)[1..2])}
|
32
|
+
end
|
33
|
+
|
34
|
+
def parse_file(filepath)
|
35
|
+
parse File.open(filepath).read
|
36
|
+
end
|
37
|
+
|
38
|
+
def start_tmux_session
|
39
|
+
system "tmux new-session -d -s #{@session}" or raise "Error starting Tmux session!"
|
40
|
+
end
|
41
|
+
|
42
|
+
def populate_tmux_session
|
43
|
+
@procs.each_with_index do |p, i|
|
44
|
+
if i==0
|
45
|
+
`tmux rename-window -t 0 '#{p.label}'`
|
46
|
+
else
|
47
|
+
`tmux new-window -t #{@session}:#{i} -n '#{p.label}'`
|
48
|
+
end
|
49
|
+
`tmux send-keys -t '#{p.label}' '#{p.command}' C-m`
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def attach_to_tmux!
|
54
|
+
exec "tmux attach-session -t #{@session}"
|
55
|
+
end
|
56
|
+
|
57
|
+
def check_tmux_session_exists
|
58
|
+
system "tmux has -t #{@session}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
data/procmux.gemspec
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require_relative 'lib/procmux/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "procmux"
|
5
|
+
spec.version = Procmux::VERSION
|
6
|
+
spec.authors = ["lunarfyre7"]
|
7
|
+
spec.email = ["gvandereay@gmail.com"]
|
8
|
+
|
9
|
+
spec.summary = %q{A simple utility to launch a procfile in a tmux session}
|
10
|
+
# spec.description = %q{TODO: Write a longer description or delete this line.}
|
11
|
+
spec.homepage = "https://github.com/lunarfyre7/procmux"
|
12
|
+
spec.license = "MIT"
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
|
+
|
15
|
+
# spec.metadata["allowed_push_host"] = "TODO: Set to 'http://mygemserver.com'"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = "https://github.com/lunarfyre7/procmux"
|
19
|
+
# spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
23
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
24
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
25
|
+
end
|
26
|
+
spec.bindir = "exe"
|
27
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
28
|
+
spec.require_paths = ["lib"]
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: procmux
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- lunarfyre7
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-08-29 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description:
|
14
|
+
email:
|
15
|
+
- gvandereay@gmail.com
|
16
|
+
executables:
|
17
|
+
- procmux
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- ".gitignore"
|
22
|
+
- ".rspec"
|
23
|
+
- ".travis.yml"
|
24
|
+
- Gemfile
|
25
|
+
- Gemfile.lock
|
26
|
+
- LICENSE.txt
|
27
|
+
- README.md
|
28
|
+
- Rakefile
|
29
|
+
- bin/console
|
30
|
+
- bin/setup
|
31
|
+
- exe/procmux
|
32
|
+
- lib/procmux.rb
|
33
|
+
- lib/procmux/prox.rb
|
34
|
+
- lib/procmux/version.rb
|
35
|
+
- procmux.gemspec
|
36
|
+
homepage: https://github.com/lunarfyre7/procmux
|
37
|
+
licenses:
|
38
|
+
- MIT
|
39
|
+
metadata:
|
40
|
+
homepage_uri: https://github.com/lunarfyre7/procmux
|
41
|
+
source_code_uri: https://github.com/lunarfyre7/procmux
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options: []
|
44
|
+
require_paths:
|
45
|
+
- lib
|
46
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - ">="
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: 2.3.0
|
51
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
requirements: []
|
57
|
+
rubygems_version: 3.1.2
|
58
|
+
signing_key:
|
59
|
+
specification_version: 4
|
60
|
+
summary: A simple utility to launch a procfile in a tmux session
|
61
|
+
test_files: []
|