junction 0.1.0 → 0.1.1
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/.rubocop.yml +2 -2
- data/Gemfile +4 -4
- data/junction +46 -0
- data/junction.gemspec +15 -15
- data/lib/junction/pane_manager.rb +29 -0
- data/lib/junction/session.rb +31 -0
- data/lib/junction/version.rb +1 -1
- data/lib/tasks/junction.rake +8 -0
- data/sig/session.rbs +7 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: af02886ca2c7a2417264899dec04f7ff6eecf763a90186cff2235f98ac9f5b5b
|
4
|
+
data.tar.gz: 6876bae3b94c7d3aa7ca1558334a9b415eb783ce0c741dafc98072551c4dbe85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cce7cbcbe3a402e1bf0ca857588fb58d6fdd2e3cc0fb4445e1f6937b34d08b6a80d04954608e7fe3e3aafb2abd3104aafc90ddf12888d9070b8aa53f605eebd
|
7
|
+
data.tar.gz: 3668c708d2fa7e785a3fc1e608359fcd2cb443c35ec152aa6802fee9dc99f00ec40b5c8708b7ea7caca2572d91821e65fdd5db7d02860f51b6ef076e3b521db4
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
source
|
3
|
+
source 'https://rubygems.org'
|
4
4
|
|
5
5
|
# Specify your gem's dependencies in junction.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
gem
|
8
|
+
gem 'rake', '~> 13.0'
|
9
9
|
|
10
|
-
gem
|
10
|
+
gem 'rspec', '~> 3.0'
|
11
11
|
|
12
|
-
gem
|
12
|
+
gem 'rubocop', '~> 1.21'
|
data/junction
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require 'junction'
|
5
|
+
|
6
|
+
# CLI Implementation
|
7
|
+
manager = Junction::PaneManager.new
|
8
|
+
|
9
|
+
puts 'Welcome to RailsTmux for Rails!'
|
10
|
+
loop do
|
11
|
+
puts "\n1. Create Pane\n2. List Panes\n3. Write to Pane\n4. Read from Pane\n5. Close Pane\n6. Exit"
|
12
|
+
print 'Select an option: '
|
13
|
+
choice = gets.chomp.to_i
|
14
|
+
|
15
|
+
case choice
|
16
|
+
when 1
|
17
|
+
print 'Enter pane name: '
|
18
|
+
name = gets.chomp
|
19
|
+
print 'Enter command (or press Enter for default bash): '
|
20
|
+
command = gets.chomp
|
21
|
+
manager.create_pane(name, command.empty? ? 'bash' : command)
|
22
|
+
puts "Pane #{name} created."
|
23
|
+
when 2
|
24
|
+
puts "Panes: #{manager.list_panes.join(", ")}"
|
25
|
+
when 3
|
26
|
+
print 'Enter pane name: '
|
27
|
+
name = gets.chomp
|
28
|
+
print 'Enter input: '
|
29
|
+
input = gets.chomp
|
30
|
+
manager.write_to_pane(name, input)
|
31
|
+
when 4
|
32
|
+
print 'Enter pane name: '
|
33
|
+
name = gets.chomp
|
34
|
+
puts "Output: #{manager.read_from_pane(name)}"
|
35
|
+
when 5
|
36
|
+
print 'Enter pane name: '
|
37
|
+
name = gets.chomp
|
38
|
+
manager.close_pane(name)
|
39
|
+
puts "Pane #{name} closed."
|
40
|
+
when 6
|
41
|
+
puts 'Exiting...'
|
42
|
+
break
|
43
|
+
else
|
44
|
+
puts 'Invalid option.'
|
45
|
+
end
|
46
|
+
end
|
data/junction.gemspec
CHANGED
@@ -1,24 +1,24 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative
|
3
|
+
require_relative 'lib/junction/version'
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
|
-
spec.name =
|
6
|
+
spec.name = 'junction'
|
7
7
|
spec.version = Junction::VERSION
|
8
|
-
spec.authors = [
|
9
|
-
spec.email = [
|
8
|
+
spec.authors = ['keegankb93']
|
9
|
+
spec.email = ['keegankb@gmail.com']
|
10
10
|
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
15
|
-
spec.required_ruby_version =
|
11
|
+
spec.summary = 'Placeholder'
|
12
|
+
spec.description = 'Placeholder'
|
13
|
+
spec.homepage = 'https://github.com/keegankb93/junction'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
spec.required_ruby_version = '>= 3.2.0'
|
16
16
|
|
17
|
-
spec.metadata[
|
17
|
+
spec.metadata['allowed_push_host'] = 'https://rubygems.org'
|
18
18
|
|
19
|
-
spec.metadata[
|
20
|
-
spec.metadata[
|
21
|
-
spec.metadata[
|
19
|
+
spec.metadata['homepage_uri'] = spec.homepage
|
20
|
+
spec.metadata['source_code_uri'] = 'https://github.com/keegankb93/junction'
|
21
|
+
spec.metadata['changelog_uri'] = 'https://github.com/keegankb93/junction'
|
22
22
|
|
23
23
|
# Specify which files should be added to the gem when it is released.
|
24
24
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
@@ -27,9 +27,9 @@ Gem::Specification.new do |spec|
|
|
27
27
|
(File.expand_path(f) == __FILE__) || f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor])
|
28
28
|
end
|
29
29
|
end
|
30
|
-
spec.bindir =
|
30
|
+
spec.bindir = 'exe'
|
31
31
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
32
|
-
spec.require_paths = [
|
32
|
+
spec.require_paths = ['lib']
|
33
33
|
|
34
34
|
# Uncomment to register a new dependency of your gem
|
35
35
|
# spec.add_dependency "example-gem", "~> 1.0"
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# lib/rails_tmux/pane_manager.rb
|
2
|
+
module Junction
|
3
|
+
class PaneManager
|
4
|
+
def initialize
|
5
|
+
@panes = {}
|
6
|
+
end
|
7
|
+
|
8
|
+
def create_pane(name, command = "bash")
|
9
|
+
@panes[name] = Session.new(name, command)
|
10
|
+
end
|
11
|
+
|
12
|
+
def list_panes
|
13
|
+
@panes.keys
|
14
|
+
end
|
15
|
+
|
16
|
+
def write_to_pane(name, input)
|
17
|
+
@panes[name]&.write(input)
|
18
|
+
end
|
19
|
+
|
20
|
+
def read_from_pane(name)
|
21
|
+
@panes[name]&.read
|
22
|
+
end
|
23
|
+
|
24
|
+
def close_pane(name)
|
25
|
+
@panes[name]&.close
|
26
|
+
@panes.delete(name)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'pty'
|
4
|
+
|
5
|
+
module Junction
|
6
|
+
class Session
|
7
|
+
attr_reader :name, :pid, :output
|
8
|
+
|
9
|
+
def initialize(name, command = 'bash')
|
10
|
+
@name = name
|
11
|
+
@command = command
|
12
|
+
@output, @input, @pid = PTY.spawn(command)
|
13
|
+
end
|
14
|
+
|
15
|
+
def write(input)
|
16
|
+
@input.puts(input)
|
17
|
+
end
|
18
|
+
|
19
|
+
def read
|
20
|
+
@output.read_nonblock(1024)
|
21
|
+
rescue IO::WaitReadable
|
22
|
+
''
|
23
|
+
end
|
24
|
+
|
25
|
+
def close
|
26
|
+
Process.kill('KILL', @pid)
|
27
|
+
rescue Errno::ESRCH
|
28
|
+
# Process already exited
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/junction/version.rb
CHANGED
data/sig/session.rbs
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: junction
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- keegankb93
|
@@ -30,10 +30,15 @@ files:
|
|
30
30
|
- LICENSE.txt
|
31
31
|
- README.md
|
32
32
|
- Rakefile
|
33
|
+
- junction
|
33
34
|
- junction.gemspec
|
34
35
|
- lib/junction.rb
|
36
|
+
- lib/junction/pane_manager.rb
|
37
|
+
- lib/junction/session.rb
|
35
38
|
- lib/junction/version.rb
|
39
|
+
- lib/tasks/junction.rake
|
36
40
|
- sig/junction.rbs
|
41
|
+
- sig/session.rbs
|
37
42
|
homepage: https://github.com/keegankb93/junction
|
38
43
|
licenses:
|
39
44
|
- MIT
|
@@ -50,7 +55,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
50
55
|
requirements:
|
51
56
|
- - ">="
|
52
57
|
- !ruby/object:Gem::Version
|
53
|
-
version: 2.
|
58
|
+
version: 3.2.0
|
54
59
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
60
|
requirements:
|
56
61
|
- - ">="
|