File tree Expand file tree Collapse file tree 3 files changed +57
-19
lines changed
Expand file tree Collapse file tree 3 files changed +57
-19
lines changed Original file line number Diff line number Diff line change 3131 end
3232end
3333
34- # Fix for https://github.com/erikhuda/thor/issues/398
35- # Copied from https://github.com/rails/thor/issues/398#issuecomment-622988390
36- class Thor
37- module Shell
38- class Basic
39- def print_wrapped ( message , options = { } )
40- indent = ( options [ :indent ] || 0 ) . to_i
41- if indent . zero?
42- stdout . puts ( message )
43- else
44- message . each_line do |message_line |
45- stdout . print ( " " * indent )
46- stdout . puts ( message_line . chomp )
47- end
48- end
49- end
50- end
51- end
52- end
34+ require_relative "patches/thor"
5335
5436module Cpflow
5537 class Error < StandardError ; end
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ class Thor
4+ # Fix for https://github.com/erikhuda/thor/issues/398
5+ # Copied from https://github.com/rails/thor/issues/398#issuecomment-622988390
6+ module Shell
7+ class Basic
8+ def print_wrapped ( message , options = { } )
9+ indent = ( options [ :indent ] || 0 ) . to_i
10+ if indent . zero?
11+ stdout . puts ( message )
12+ else
13+ message . each_line do |message_line |
14+ stdout . print ( " " * indent )
15+ stdout . puts ( message_line . chomp )
16+ end
17+ end
18+ end
19+ end
20+ end
21+
22+ # Fix for https://github.com/rails/thor/issues/742
23+ def self . basename
24+ @package_name || super
25+ end
26+ end
Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ require "thor"
4+ require "patches/thor"
5+
6+ describe Thor do
7+ describe ".basename" do
8+ subject ( :basename ) { klass . send ( :basename ) }
9+
10+ context "when class has defined package name" do
11+ let ( :klass ) do
12+ Class . new ( described_class ) do
13+ package_name "test_package_name"
14+ end
15+ end
16+
17+ it "returns package name" do
18+ expect ( basename ) . to eq ( "test_package_name" )
19+ end
20+ end
21+
22+ context "when class doesn't have defined package name" do
23+ let ( :klass ) { Class . new ( described_class ) }
24+
25+ it "returns basename of program invoking the class" do
26+ expect ( basename ) . to eq ( "rspec" )
27+ end
28+ end
29+ end
30+ end
You can’t perform that action at this time.
0 commit comments