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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 38bc3490243e16ad199e9d54e7f471d8e4f51e17bef81878eff61cb7aa241c7c
4
- data.tar.gz: '019d7c918361afaf1f59a9f8c3c95d1142e3b109a9a2fffb5bda6c9f01fc93d7'
3
+ metadata.gz: af02886ca2c7a2417264899dec04f7ff6eecf763a90186cff2235f98ac9f5b5b
4
+ data.tar.gz: 6876bae3b94c7d3aa7ca1558334a9b415eb783ce0c741dafc98072551c4dbe85
5
5
  SHA512:
6
- metadata.gz: 399aa31db6f9334f59c9ae5043b77aed312dff7885dd3468779576c800a99612c65c58525e65675b0041a06089988085771a5cd10db51586bbf00f2964444455
7
- data.tar.gz: 66fc2dfdd32f49c29a6a625bb46e0b9d509c6216f4e24e173bff875fd2fb8db30950d852246d6f9dad958648cc367918023a88848bb36b81751c27553514bf11
6
+ metadata.gz: 4cce7cbcbe3a402e1bf0ca857588fb58d6fdd2e3cc0fb4445e1f6937b34d08b6a80d04954608e7fe3e3aafb2abd3104aafc90ddf12888d9070b8aa53f605eebd
7
+ data.tar.gz: 3668c708d2fa7e785a3fc1e608359fcd2cb443c35ec152aa6802fee9dc99f00ec40b5c8708b7ea7caca2572d91821e65fdd5db7d02860f51b6ef076e3b521db4
data/.rubocop.yml CHANGED
@@ -1,9 +1,9 @@
1
1
  AllCops:
2
- TargetRubyVersion: 2.6
2
+ TargetRubyVersion: 3.2
3
3
 
4
4
  Style/StringLiterals:
5
5
  Enabled: true
6
- EnforcedStyle: double_quotes
6
+ EnforcedStyle: single_quotes
7
7
 
8
8
  Style/StringLiteralsInInterpolation:
9
9
  Enabled: true
data/Gemfile CHANGED
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source "https://rubygems.org"
3
+ source 'https://rubygems.org'
4
4
 
5
5
  # Specify your gem's dependencies in junction.gemspec
6
6
  gemspec
7
7
 
8
- gem "rake", "~> 13.0"
8
+ gem 'rake', '~> 13.0'
9
9
 
10
- gem "rspec", "~> 3.0"
10
+ gem 'rspec', '~> 3.0'
11
11
 
12
- gem "rubocop", "~> 1.21"
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 "lib/junction/version"
3
+ require_relative 'lib/junction/version'
4
4
 
5
5
  Gem::Specification.new do |spec|
6
- spec.name = "junction"
6
+ spec.name = 'junction'
7
7
  spec.version = Junction::VERSION
8
- spec.authors = ["keegankb93"]
9
- spec.email = ["keegankb@gmail.com"]
8
+ spec.authors = ['keegankb93']
9
+ spec.email = ['keegankb@gmail.com']
10
10
 
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 = ">= 2.6.0"
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["allowed_push_host"] = "https://rubygems.org"
17
+ spec.metadata['allowed_push_host'] = 'https://rubygems.org'
18
18
 
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"
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 = "exe"
30
+ spec.bindir = 'exe'
31
31
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
- spec.require_paths = ["lib"]
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Junction
4
- VERSION = "0.1.0"
4
+ VERSION = '0.1.1'
5
5
  end
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ namespace :junction do
4
+ desc 'Run junction'
5
+ task :start do
6
+ exec 'junction'
7
+ end
8
+ end
data/sig/session.rbs ADDED
@@ -0,0 +1,7 @@
1
+ module Junction
2
+ class Session
3
+ @command: string
4
+ @name: string
5
+
6
+ end
7
+ end
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.0
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.6.0
58
+ version: 3.2.0
54
59
  required_rubygems_version: !ruby/object:Gem::Requirement
55
60
  requirements:
56
61
  - - ">="