rubyshell 1.3.0 → 1.3.2
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/bin/console +11 -0
- data/bin/rubyshell +10 -0
- data/bin/setup +8 -0
- data/lib/rubyshell/chainer.rb +4 -0
- data/lib/rubyshell/command.rb +12 -11
- data/lib/rubyshell/error.rb +14 -0
- data/lib/rubyshell/executor.rb +1 -3
- data/lib/rubyshell/overwrited_commands.rb +13 -0
- data/lib/rubyshell/tty/irb.rb +29 -0
- data/lib/rubyshell/version.rb +1 -1
- data/lib/rubyshell.rb +2 -0
- metadata +9 -4
- data/exe/rubyshell +0 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 11208bfa2670078a1665b386260f125f0ddd313f53ea4cba06d057b3fd7d58c4
|
|
4
|
+
data.tar.gz: '08c133def7ce9b41cfbef1e17183e7962a57bf4e8a06ac0d64c4b3a337dc3c83'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 34f26ad513a3ff7133bb0b6240945d62d1f35090c0fbd29c09946b23cf5b1728d573df7ae7f898f02ba2a2b0acfa4e9b6156ecb442a6f3148c60880e94364923
|
|
7
|
+
data.tar.gz: d71f115c187835d5f44ace7159a95c1025e511d6d31f299febb92d7ff5ac1cb03a0cf9a2085398ed9b4e19cb7c89cad6c3e996d8b4cc4e7b0e100cbd7a6e40e6
|
data/bin/console
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
require "bundler/setup"
|
|
5
|
+
require "rubyshell"
|
|
6
|
+
|
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
|
9
|
+
|
|
10
|
+
require "irb"
|
|
11
|
+
IRB.start(__FILE__)
|
data/bin/rubyshell
ADDED
data/bin/setup
ADDED
data/lib/rubyshell/chainer.rb
CHANGED
data/lib/rubyshell/command.rb
CHANGED
|
@@ -20,10 +20,12 @@ module RubyShell
|
|
|
20
20
|
raise RubyShell::CommandError.new(command: to_shell, stdout: stdout, stderr: stderr, status: status)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
stdout.chomp
|
|
23
|
+
StringWrapper.new(stdout.chomp)
|
|
24
24
|
end
|
|
25
|
-
rescue StandardError
|
|
26
|
-
raise RubyShell::CommandError
|
|
25
|
+
rescue StandardError => e
|
|
26
|
+
raise e if e.is_a?(RubyShell::CommandError)
|
|
27
|
+
|
|
28
|
+
raise RubyShell::CommandError.new(command: to_shell, message: e.message)
|
|
27
29
|
end
|
|
28
30
|
|
|
29
31
|
def parsed_args
|
|
@@ -54,14 +56,13 @@ module RubyShell
|
|
|
54
56
|
end
|
|
55
57
|
end
|
|
56
58
|
|
|
57
|
-
class
|
|
58
|
-
def
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
super
|
|
59
|
+
class StringWrapper < String
|
|
60
|
+
def inspect
|
|
61
|
+
if $stdin.isatty
|
|
62
|
+
to_s
|
|
63
|
+
else
|
|
64
|
+
super
|
|
65
|
+
end
|
|
65
66
|
end
|
|
66
67
|
end
|
|
67
68
|
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RubyShell
|
|
4
|
+
class CommandError < StandardError
|
|
5
|
+
def initialize(command:, stdout: "", stderr: "", status: "", message: nil)
|
|
6
|
+
@command = command
|
|
7
|
+
@stdout = stdout
|
|
8
|
+
@stderr = stderr
|
|
9
|
+
@status = status
|
|
10
|
+
|
|
11
|
+
super(message || (stderr.empty? ? stdout : stderr))
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
data/lib/rubyshell/executor.rb
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RubyShell
|
|
4
|
+
module Tty
|
|
5
|
+
module IrbWorkspace
|
|
6
|
+
def initialize(*args, **kwargs)
|
|
7
|
+
super
|
|
8
|
+
|
|
9
|
+
main.define_singleton_method(:to_s) do
|
|
10
|
+
Dir.pwd.split("/").last(2).join("/")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
@main.extend(RubyShell::Executor)
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
IRB::WorkSpace.prepend(RubyShell::Tty::IrbWorkspace)
|
|
20
|
+
|
|
21
|
+
IRB.conf[:IRB_RC] = proc do |ctx|
|
|
22
|
+
if defined?(IRB::Command) && IRB::Command.respond_to?(:commands)
|
|
23
|
+
IRB::Command.commands.delete(:cd)
|
|
24
|
+
elsif defined?(IRB::ExtendCommand) && IRB::ExtendCommand.respond_to?(:commands)
|
|
25
|
+
IRB::ExtendCommand.commands.delete(:cd)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
ctx.command_aliases.delete(:cd) if ctx.respond_to?(:command_aliases) && ctx.command_aliases
|
|
29
|
+
end
|
data/lib/rubyshell/version.rb
CHANGED
data/lib/rubyshell.rb
CHANGED
|
@@ -4,7 +4,9 @@ require_relative "rubyshell/version"
|
|
|
4
4
|
require_relative "rubyshell/command"
|
|
5
5
|
require_relative "rubyshell/chainer"
|
|
6
6
|
require_relative "rubyshell/chain_context"
|
|
7
|
+
require_relative "rubyshell/overwrited_commands"
|
|
7
8
|
require_relative "rubyshell/executor"
|
|
9
|
+
require_relative "rubyshell/error"
|
|
8
10
|
|
|
9
11
|
module Kernel
|
|
10
12
|
def sh(&block)
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rubyshell
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.3.
|
|
4
|
+
version: 1.3.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- albertalef
|
|
8
8
|
autorequire:
|
|
9
|
-
bindir:
|
|
9
|
+
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-01-
|
|
11
|
+
date: 2026-01-20 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: A rubist way to run shell commands
|
|
14
14
|
email:
|
|
@@ -21,12 +21,17 @@ files:
|
|
|
21
21
|
- CHANGELOG.md
|
|
22
22
|
- README.md
|
|
23
23
|
- Rakefile
|
|
24
|
-
-
|
|
24
|
+
- bin/console
|
|
25
|
+
- bin/rubyshell
|
|
26
|
+
- bin/setup
|
|
25
27
|
- lib/rubyshell.rb
|
|
26
28
|
- lib/rubyshell/chain_context.rb
|
|
27
29
|
- lib/rubyshell/chainer.rb
|
|
28
30
|
- lib/rubyshell/command.rb
|
|
31
|
+
- lib/rubyshell/error.rb
|
|
29
32
|
- lib/rubyshell/executor.rb
|
|
33
|
+
- lib/rubyshell/overwrited_commands.rb
|
|
34
|
+
- lib/rubyshell/tty/irb.rb
|
|
30
35
|
- lib/rubyshell/version.rb
|
|
31
36
|
homepage: https://github.com/albertalef/rubyshell
|
|
32
37
|
licenses:
|