rubyshell 1.3.0 → 1.3.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: f21be5da171237ec3217b6dde48055661f29a83dea187022b31fa412412d4057
4
- data.tar.gz: d4a738f0169a395ed449407eb95a0e78df9d6b827472030977db728900ac055d
3
+ metadata.gz: 71600c3dfe95d34a08ae287a966739973ec61f50510dab8c40a99bb4bc6941ad
4
+ data.tar.gz: 0b8869b6abd73e47bb9991e7b37d4b8c2a819a7126b506d951c41436449c4df6
5
5
  SHA512:
6
- metadata.gz: afe062bedbf8e8f1064aa662c8925364da817279fb83d9a2af74ea552cd146aa63d17fda67b7c16e608a3f0b386d5d0bc1cdcb6365398cc3e726f6255ff33de7
7
- data.tar.gz: 369ac530ad58e8ed4489ca17536dcf9786491b8a641e04a24c565f8182b6d10b9e043d5714d50969bcd438a8d13e8388ba3a11b0628891d51aff5c01a80014ec
6
+ metadata.gz: a5a707cc81ff623438bf32b2bf64c25a29fe2ebad7d6684ffe0900d64b911570553d3c647b9ea967c7c3b23c77a1a59d4db149783519283f3937f2ef2e8e243d
7
+ data.tar.gz: decee58de77cbbbe82586c16f4c3a1b92d4097598c38145eb7ea2b394bd6d2a0c4b7d83681f51d321084c687441e63a98094f552288c5bdbdfb6f93810b75df5
data/Rakefile CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require "bundler/gem_tasks"
4
4
  require "rspec/core/rake_task"
5
+ require "bundler/gem_tasks"
5
6
 
6
7
  RSpec::Core::RakeTask.new(:spec)
7
8
 
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
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "rubyshell"
5
+
6
+ if ARGV.first&.strip&.start_with? "exec"
7
+ extend RubyShell::Executor # rubocop:disable Style/MixinUsage
8
+
9
+ load(ARGV.last)
10
+ end
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -40,6 +40,10 @@ module RubyShell
40
40
 
41
41
  stdout.chomp
42
42
  end
43
+ rescue StandardError => e
44
+ raise e if e.is_a?(RubyShell::CommandError)
45
+
46
+ raise RubyShell::CommandError.new(command: to_shell, message: e.message)
43
47
  end
44
48
 
45
49
  def to_shell
@@ -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.new(command: to_shell)
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 CommandError < StandardError
58
- def initialize(command:, stdout: "", stderr: "", status: "")
59
- @command = command
60
- @stdout = stdout
61
- @stderr = stderr
62
- @status = status
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
@@ -4,9 +4,7 @@ module RubyShell
4
4
  module Executor
5
5
  module_function
6
6
 
7
- def cd(path, &block)
8
- Dir.chdir(path, &block)
9
- end
7
+ include RubyShell::OverwritedCommands
10
8
 
11
9
  def chain(&block)
12
10
  RubyShell::ChainContext.class_eval(&block).exec_commands
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyShell
4
+ module OverwritedCommands
5
+ def self.included(mod)
6
+ mod.extend self
7
+ end
8
+
9
+ def cd(path, &block)
10
+ Dir.chdir(path, &block)
11
+ end
12
+
13
+ def ls(*args)
14
+ method_missing(:ls, *args)
15
+ end
16
+ end
17
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyShell
4
- VERSION = "1.3.0"
4
+ VERSION = "1.3.1"
5
5
  end
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.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - albertalef
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2026-01-18 00:00:00.000000000 Z
11
+ date: 2026-01-19 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: A rubist way to run shell commands
14
14
  email:
@@ -21,12 +21,16 @@ files:
21
21
  - CHANGELOG.md
22
22
  - README.md
23
23
  - Rakefile
24
- - exe/rubyshell
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
30
34
  - lib/rubyshell/version.rb
31
35
  homepage: https://github.com/albertalef/rubyshell
32
36
  licenses:
data/exe/rubyshell DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require "rubyshell"
5
-
6
- require "irb"
7
-
8
- IRB.start(__FILE__)