thor 0.19.4 → 1.0.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 +5 -5
- data/CHANGELOG.md +57 -0
- data/README.md +6 -2
- data/lib/thor.rb +37 -12
- data/lib/thor/actions.rb +31 -13
- data/lib/thor/actions/create_file.rb +2 -1
- data/lib/thor/actions/create_link.rb +4 -2
- data/lib/thor/actions/directory.rb +7 -17
- data/lib/thor/actions/empty_directory.rb +9 -1
- data/lib/thor/actions/file_manipulation.rb +58 -12
- data/lib/thor/actions/inject_into_file.rb +27 -10
- data/lib/thor/base.rb +84 -41
- data/lib/thor/command.rb +30 -21
- data/lib/thor/core_ext/hash_with_indifferent_access.rb +12 -0
- data/lib/thor/error.rb +78 -0
- data/lib/thor/group.rb +4 -4
- data/lib/thor/invocation.rb +1 -0
- data/lib/thor/line_editor.rb +2 -2
- data/lib/thor/line_editor/basic.rb +2 -0
- data/lib/thor/line_editor/readline.rb +6 -6
- data/lib/thor/nested_context.rb +29 -0
- data/lib/thor/parser.rb +4 -4
- data/lib/thor/parser/arguments.rb +2 -2
- data/lib/thor/parser/option.rb +22 -9
- data/lib/thor/parser/options.rb +25 -9
- data/lib/thor/rake_compat.rb +1 -0
- data/lib/thor/runner.rb +9 -6
- data/lib/thor/shell.rb +4 -4
- data/lib/thor/shell/basic.rb +72 -17
- data/lib/thor/shell/color.rb +6 -2
- data/lib/thor/shell/html.rb +3 -3
- data/lib/thor/util.rb +17 -1
- data/lib/thor/version.rb +1 -1
- data/thor.gemspec +9 -2
- metadata +19 -10
- data/lib/thor/core_ext/io_binary_read.rb +0 -12
- data/lib/thor/core_ext/ordered_hash.rb +0 -129
data/lib/thor/shell/color.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative "basic"
|
2
2
|
|
3
3
|
class Thor
|
4
4
|
module Shell
|
@@ -97,7 +97,11 @@ class Thor
|
|
97
97
|
protected
|
98
98
|
|
99
99
|
def can_display_colors?
|
100
|
-
stdout.tty?
|
100
|
+
stdout.tty? && !are_colors_disabled?
|
101
|
+
end
|
102
|
+
|
103
|
+
def are_colors_disabled?
|
104
|
+
!ENV['NO_COLOR'].nil?
|
101
105
|
end
|
102
106
|
|
103
107
|
# Overwrite show_diff to show diff with colors if Diff::LCS is
|
data/lib/thor/shell/html.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative "basic"
|
2
2
|
|
3
3
|
class Thor
|
4
4
|
module Shell
|
@@ -51,13 +51,13 @@ class Thor
|
|
51
51
|
def set_color(string, *colors)
|
52
52
|
if colors.all? { |color| color.is_a?(Symbol) || color.is_a?(String) }
|
53
53
|
html_colors = colors.map { |color| lookup_color(color) }
|
54
|
-
"<span style=\"#{html_colors.join('; ')};\">#{string}</span>"
|
54
|
+
"<span style=\"#{html_colors.join('; ')};\">#{Thor::Util.escape_html(string)}</span>"
|
55
55
|
else
|
56
56
|
color, bold = colors
|
57
57
|
html_color = self.class.const_get(color.to_s.upcase) if color.is_a?(Symbol)
|
58
58
|
styles = [html_color]
|
59
59
|
styles << BOLD if bold
|
60
|
-
"<span style=\"#{styles.join('; ')};\">#{string}</span>"
|
60
|
+
"<span style=\"#{styles.join('; ')};\">#{Thor::Util.escape_html(string)}</span>"
|
61
61
|
end
|
62
62
|
end
|
63
63
|
|
data/lib/thor/util.rb
CHANGED
@@ -27,7 +27,7 @@ class Thor
|
|
27
27
|
end
|
28
28
|
|
29
29
|
# Receives a constant and converts it to a Thor namespace. Since Thor
|
30
|
-
# commands can be added to a sandbox, this method is also
|
30
|
+
# commands can be added to a sandbox, this method is also responsible for
|
31
31
|
# removing the sandbox namespace.
|
32
32
|
#
|
33
33
|
# This method should not be used in general because it's used to deal with
|
@@ -263,6 +263,22 @@ class Thor
|
|
263
263
|
def escape_globs(path)
|
264
264
|
path.to_s.gsub(/[*?{}\[\]]/, '\\\\\\&')
|
265
265
|
end
|
266
|
+
|
267
|
+
# Returns a string that has had any HTML characters escaped.
|
268
|
+
#
|
269
|
+
# ==== Examples
|
270
|
+
#
|
271
|
+
# Thor::Util.escape_html('<div>') # => "<div>"
|
272
|
+
#
|
273
|
+
# ==== Parameters
|
274
|
+
# String
|
275
|
+
#
|
276
|
+
# ==== Returns
|
277
|
+
# String
|
278
|
+
#
|
279
|
+
def escape_html(string)
|
280
|
+
CGI.escapeHTML(string)
|
281
|
+
end
|
266
282
|
end
|
267
283
|
end
|
268
284
|
end
|
data/lib/thor/version.rb
CHANGED
data/thor.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift lib unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require "thor/version"
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.add_development_dependency "bundler", "
|
7
|
+
spec.add_development_dependency "bundler", ">= 1.0", "< 3"
|
8
8
|
spec.authors = ["Yehuda Katz", "José Valim"]
|
9
9
|
spec.description = "Thor is a toolkit for building powerful command-line interfaces."
|
10
10
|
spec.email = "ruby-thor@googlegroups.com"
|
@@ -13,8 +13,15 @@ Gem::Specification.new do |spec|
|
|
13
13
|
spec.homepage = "http://whatisthor.com/"
|
14
14
|
spec.licenses = %w(MIT)
|
15
15
|
spec.name = "thor"
|
16
|
+
spec.metadata = {
|
17
|
+
"bug_tracker_uri" => "https://github.com/erikhuda/thor/issues",
|
18
|
+
"changelog_uri" => "https://github.com/erikhuda/thor/blob/master/CHANGELOG.md",
|
19
|
+
"documentation_uri" => "http://whatisthor.com/",
|
20
|
+
"source_code_uri" => "https://github.com/erikhuda/thor/tree/v#{Thor::VERSION}",
|
21
|
+
"wiki_uri" => "https://github.com/erikhuda/thor/wiki"
|
22
|
+
}
|
16
23
|
spec.require_paths = %w(lib)
|
17
|
-
spec.required_ruby_version = ">=
|
24
|
+
spec.required_ruby_version = ">= 2.0.0"
|
18
25
|
spec.required_rubygems_version = ">= 1.3.5"
|
19
26
|
spec.summary = spec.description
|
20
27
|
spec.version = Thor::VERSION
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: thor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yehuda Katz
|
@@ -9,22 +9,28 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2019-12-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '1.0'
|
21
|
+
- - "<"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: '3'
|
21
24
|
type: :development
|
22
25
|
prerelease: false
|
23
26
|
version_requirements: !ruby/object:Gem::Requirement
|
24
27
|
requirements:
|
25
|
-
- - "
|
28
|
+
- - ">="
|
26
29
|
- !ruby/object:Gem::Version
|
27
30
|
version: '1.0'
|
31
|
+
- - "<"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3'
|
28
34
|
description: Thor is a toolkit for building powerful command-line interfaces.
|
29
35
|
email: ruby-thor@googlegroups.com
|
30
36
|
executables:
|
@@ -49,14 +55,13 @@ files:
|
|
49
55
|
- lib/thor/base.rb
|
50
56
|
- lib/thor/command.rb
|
51
57
|
- lib/thor/core_ext/hash_with_indifferent_access.rb
|
52
|
-
- lib/thor/core_ext/io_binary_read.rb
|
53
|
-
- lib/thor/core_ext/ordered_hash.rb
|
54
58
|
- lib/thor/error.rb
|
55
59
|
- lib/thor/group.rb
|
56
60
|
- lib/thor/invocation.rb
|
57
61
|
- lib/thor/line_editor.rb
|
58
62
|
- lib/thor/line_editor/basic.rb
|
59
63
|
- lib/thor/line_editor/readline.rb
|
64
|
+
- lib/thor/nested_context.rb
|
60
65
|
- lib/thor/parser.rb
|
61
66
|
- lib/thor/parser/argument.rb
|
62
67
|
- lib/thor/parser/arguments.rb
|
@@ -74,7 +79,12 @@ files:
|
|
74
79
|
homepage: http://whatisthor.com/
|
75
80
|
licenses:
|
76
81
|
- MIT
|
77
|
-
metadata:
|
82
|
+
metadata:
|
83
|
+
bug_tracker_uri: https://github.com/erikhuda/thor/issues
|
84
|
+
changelog_uri: https://github.com/erikhuda/thor/blob/master/CHANGELOG.md
|
85
|
+
documentation_uri: http://whatisthor.com/
|
86
|
+
source_code_uri: https://github.com/erikhuda/thor/tree/v1.0.1
|
87
|
+
wiki_uri: https://github.com/erikhuda/thor/wiki
|
78
88
|
post_install_message:
|
79
89
|
rdoc_options: []
|
80
90
|
require_paths:
|
@@ -83,15 +93,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
83
93
|
requirements:
|
84
94
|
- - ">="
|
85
95
|
- !ruby/object:Gem::Version
|
86
|
-
version:
|
96
|
+
version: 2.0.0
|
87
97
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
98
|
requirements:
|
89
99
|
- - ">="
|
90
100
|
- !ruby/object:Gem::Version
|
91
101
|
version: 1.3.5
|
92
102
|
requirements: []
|
93
|
-
|
94
|
-
rubygems_version: 2.5.2
|
103
|
+
rubygems_version: 3.0.3
|
95
104
|
signing_key:
|
96
105
|
specification_version: 4
|
97
106
|
summary: Thor is a toolkit for building powerful command-line interfaces.
|
@@ -1,12 +0,0 @@
|
|
1
|
-
class IO #:nodoc:
|
2
|
-
class << self
|
3
|
-
unless method_defined? :binread
|
4
|
-
def binread(file, *args)
|
5
|
-
raise ArgumentError, "wrong number of arguments (#{1 + args.size} for 1..3)" unless args.size < 3
|
6
|
-
File.open(file, "rb") do |f|
|
7
|
-
f.read(*args)
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
@@ -1,129 +0,0 @@
|
|
1
|
-
class Thor
|
2
|
-
module CoreExt
|
3
|
-
class OrderedHash < ::Hash
|
4
|
-
if RUBY_VERSION < "1.9"
|
5
|
-
def initialize(*args, &block)
|
6
|
-
super
|
7
|
-
@keys = []
|
8
|
-
end
|
9
|
-
|
10
|
-
def initialize_copy(other)
|
11
|
-
super
|
12
|
-
# make a deep copy of keys
|
13
|
-
@keys = other.keys
|
14
|
-
end
|
15
|
-
|
16
|
-
def []=(key, value)
|
17
|
-
@keys << key unless key?(key)
|
18
|
-
super
|
19
|
-
end
|
20
|
-
|
21
|
-
def delete(key)
|
22
|
-
if key? key
|
23
|
-
index = @keys.index(key)
|
24
|
-
@keys.delete_at index
|
25
|
-
end
|
26
|
-
super
|
27
|
-
end
|
28
|
-
|
29
|
-
def delete_if
|
30
|
-
super
|
31
|
-
sync_keys!
|
32
|
-
self
|
33
|
-
end
|
34
|
-
|
35
|
-
alias_method :reject!, :delete_if
|
36
|
-
|
37
|
-
def reject(&block)
|
38
|
-
dup.reject!(&block)
|
39
|
-
end
|
40
|
-
|
41
|
-
def keys
|
42
|
-
@keys.dup
|
43
|
-
end
|
44
|
-
|
45
|
-
def values
|
46
|
-
@keys.map { |key| self[key] }
|
47
|
-
end
|
48
|
-
|
49
|
-
def to_hash
|
50
|
-
self
|
51
|
-
end
|
52
|
-
|
53
|
-
def to_a
|
54
|
-
@keys.map { |key| [key, self[key]] }
|
55
|
-
end
|
56
|
-
|
57
|
-
def each_key
|
58
|
-
return to_enum(:each_key) unless block_given?
|
59
|
-
@keys.each { |key| yield(key) }
|
60
|
-
self
|
61
|
-
end
|
62
|
-
|
63
|
-
def each_value
|
64
|
-
return to_enum(:each_value) unless block_given?
|
65
|
-
@keys.each { |key| yield(self[key]) }
|
66
|
-
self
|
67
|
-
end
|
68
|
-
|
69
|
-
def each
|
70
|
-
return to_enum(:each) unless block_given?
|
71
|
-
@keys.each { |key| yield([key, self[key]]) }
|
72
|
-
self
|
73
|
-
end
|
74
|
-
|
75
|
-
def each_pair
|
76
|
-
return to_enum(:each_pair) unless block_given?
|
77
|
-
@keys.each { |key| yield(key, self[key]) }
|
78
|
-
self
|
79
|
-
end
|
80
|
-
|
81
|
-
alias_method :select, :find_all
|
82
|
-
|
83
|
-
def clear
|
84
|
-
super
|
85
|
-
@keys.clear
|
86
|
-
self
|
87
|
-
end
|
88
|
-
|
89
|
-
def shift
|
90
|
-
k = @keys.first
|
91
|
-
v = delete(k)
|
92
|
-
[k, v]
|
93
|
-
end
|
94
|
-
|
95
|
-
def merge!(other_hash)
|
96
|
-
if block_given?
|
97
|
-
other_hash.each { |k, v| self[k] = key?(k) ? yield(k, self[k], v) : v }
|
98
|
-
else
|
99
|
-
other_hash.each { |k, v| self[k] = v }
|
100
|
-
end
|
101
|
-
self
|
102
|
-
end
|
103
|
-
|
104
|
-
alias_method :update, :merge!
|
105
|
-
|
106
|
-
def merge(other_hash, &block)
|
107
|
-
dup.merge!(other_hash, &block)
|
108
|
-
end
|
109
|
-
|
110
|
-
# When replacing with another hash, the initial order of our keys must come from the other hash -ordered or not.
|
111
|
-
def replace(other)
|
112
|
-
super
|
113
|
-
@keys = other.keys
|
114
|
-
self
|
115
|
-
end
|
116
|
-
|
117
|
-
def inspect
|
118
|
-
"#<#{self.class} #{super}>"
|
119
|
-
end
|
120
|
-
|
121
|
-
private
|
122
|
-
|
123
|
-
def sync_keys!
|
124
|
-
@keys.delete_if { |k| !key?(k) }
|
125
|
-
end
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
end
|