thor 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f24a2dd00001feb1d7f9d68b1cf8aff06dd9f347e230846eda8662595a514ac9
4
- data.tar.gz: 5fcf2e12c1a1f7112b72286f3eded990dc6f00df0ecc45a5e32465915c10b515
3
+ metadata.gz: d9d12a41fe3b4da55677d0c265e0c0ed194b7a63f7236c8703c0b33bce2eaea5
4
+ data.tar.gz: 5e95ec2585dcf45267d180b0dbb8985dd3f6edbfec27bb255060c2a337d8f2ba
5
5
  SHA512:
6
- metadata.gz: 03d0bd2991357425d2ceeeaf3a538f280e9a1a2ce7d35cc210c5413744940f022602339ce721aff4bad5c51ebde0a071d533a06c7c697dee8fabbcb468671dc5
7
- data.tar.gz: 1fe2bbce8f427aaa3a9a314b647796927d8dbaf52b2873c1def2d072c3fd98076abcbc50890d913f195a30835208f5f2d272d59969a89e3821f1ff6c1080d073
6
+ metadata.gz: 14be531d0089734aa368df537cc975a1f5319e1b30bfe8288c3573681a16065a98f4a3e6c67fb6ad3eef05e968d2df69d622805557aafa4e90ef1c6a95b4a5ea
7
+ data.tar.gz: ce7d64257d5836b6c52d0722254b9a01fe2565a3ba6ec8da99c905412d5814038d0d71dec8859e1f76b24bc4e4fc0183c7f21bb352e6e1dbf5ab5d11f22ab096
@@ -10,7 +10,6 @@ class Thor
10
10
  # destination<String>:: the relative path to the destination root.
11
11
  # config<Hash>:: give :verbose => false to not log the status, and
12
12
  # :mode => :preserve, to preserve the file mode from the source.
13
-
14
13
  #
15
14
  # ==== Examples
16
15
  #
@@ -275,9 +274,8 @@ class Thor
275
274
  end
276
275
  end
277
276
 
278
- # Uncomment all lines matching a given regex. It will leave the space
279
- # which existed before the comment hash in tact but will remove any spacing
280
- # between the comment hash and the beginning of the line.
277
+ # Uncomment all lines matching a given regex. Preserves indentation before
278
+ # the comment hash and removes the hash and any immediate following space.
281
279
  #
282
280
  # ==== Parameters
283
281
  # path<String>:: path of the file to be changed
@@ -291,7 +289,7 @@ class Thor
291
289
  def uncomment_lines(path, flag, *args)
292
290
  flag = flag.respond_to?(:source) ? flag.source : flag
293
291
 
294
- gsub_file(path, /^(\s*)#[[:blank:]]*(.*#{flag})/, '\1\2', *args)
292
+ gsub_file(path, /^(\s*)#[[:blank:]]?(.*#{flag})/, '\1\2', *args)
295
293
  end
296
294
 
297
295
  # Comment all lines matching a given regex. It will leave the space
@@ -26,10 +26,7 @@ class Thor
26
26
 
27
27
  def print_default
28
28
  if @type == :array and @default.is_a?(Array)
29
- @default.map { |x|
30
- p = x.gsub('"','\\"')
31
- "\"#{p}\""
32
- }.join(" ")
29
+ @default.map(&:dump).join(" ")
33
30
  else
34
31
  @default
35
32
  end
@@ -89,8 +89,8 @@ class Thor
89
89
 
90
90
  sample = "[#{sample}]".dup unless required?
91
91
 
92
- if boolean?
93
- sample << ", [#{dasherize('no-' + human_name)}]" unless (name == "force") || name.match(/\Ano[\-_]/)
92
+ if boolean? && name != "force" && !name.match(/\A(no|skip)[\-_]/)
93
+ sample << ", [#{dasherize('no-' + human_name)}], [#{dasherize('skip-' + human_name)}]"
94
94
  end
95
95
 
96
96
  aliases_for_usage.ljust(padding) + sample
@@ -250,7 +250,8 @@ class Thor
250
250
  @parsing_options
251
251
  end
252
252
 
253
- # Parse boolean values which can be given as --foo=true, --foo or --no-foo.
253
+ # Parse boolean values which can be given as --foo=true or --foo for true values, or
254
+ # --foo=false, --no-foo or --skip-foo for false values.
254
255
  #
255
256
  def parse_boolean(switch)
256
257
  if current_is_value?
@@ -67,15 +67,15 @@ class Thor
67
67
  # Readline.
68
68
  #
69
69
  # ==== Example
70
- # ask("What is your name?")
70
+ # ask("What is your name?")
71
71
  #
72
- # ask("What is the planet furthest from the sun?", :default => "Pluto")
72
+ # ask("What is the planet furthest from the sun?", :default => "Neptune")
73
73
  #
74
- # ask("What is your favorite Neopolitan flavor?", :limited_to => ["strawberry", "chocolate", "vanilla"])
74
+ # ask("What is your favorite Neopolitan flavor?", :limited_to => ["strawberry", "chocolate", "vanilla"])
75
75
  #
76
- # ask("What is your password?", :echo => false)
76
+ # ask("What is your password?", :echo => false)
77
77
  #
78
- # ask("Where should the file be saved?", :path => true)
78
+ # ask("Where should the file be saved?", :path => true)
79
79
  #
80
80
  def ask(statement, *args)
81
81
  options = args.last.is_a?(Hash) ? args.pop : {}
@@ -93,7 +93,7 @@ class Thor
93
93
  # are passed straight to puts (behavior got from Highline).
94
94
  #
95
95
  # ==== Example
96
- # say("I know you knew that.")
96
+ # say("I know you knew that.")
97
97
  #
98
98
  def say(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
99
99
  return if quiet?
@@ -110,7 +110,7 @@ class Thor
110
110
  # are passed straight to puts (behavior got from Highline).
111
111
  #
112
112
  # ==== Example
113
- # say_error("error: something went wrong")
113
+ # say_error("error: something went wrong")
114
114
  #
115
115
  def say_error(message = "", color = nil, force_new_line = (message.to_s !~ /( |\t)\Z/))
116
116
  return if quiet?
@@ -143,14 +143,14 @@ class Thor
143
143
  stdout.flush
144
144
  end
145
145
 
146
- # Make a question the to user and returns true if the user replies "y" or
146
+ # Asks the user a question and returns true if the user replies "y" or
147
147
  # "yes".
148
148
  #
149
149
  def yes?(statement, color = nil)
150
150
  !!(ask(statement, color, add_to_history: false) =~ is?(:yes))
151
151
  end
152
152
 
153
- # Make a question the to user and returns true if the user replies "n" or
153
+ # Asks the user a question and returns true if the user replies "n" or
154
154
  # "no".
155
155
  #
156
156
  def no?(statement, color = nil)
@@ -67,7 +67,7 @@ class Thor
67
67
  # Ask something to the user and receives a response.
68
68
  #
69
69
  # ==== Example
70
- # ask("What is your name?")
70
+ # ask("What is your name?")
71
71
  #
72
72
  # TODO: Implement #ask for Thor::Shell::HTML
73
73
  def ask(statement, color = nil)
@@ -102,33 +102,17 @@ class Thor
102
102
 
103
103
  def truncate(string)
104
104
  return string unless @truncate
105
- as_unicode do
106
- chars = string.chars.to_a
107
- if chars.length <= @truncate
108
- chars.join
109
- else
110
- chars[0, @truncate - 3 - @indent].join + "..."
111
- end
105
+ chars = string.chars.to_a
106
+ if chars.length <= @truncate
107
+ chars.join
108
+ else
109
+ chars[0, @truncate - 3 - @indent].join + "..."
112
110
  end
113
111
  end
114
112
 
115
113
  def indentation
116
114
  " " * @indent
117
115
  end
118
-
119
- if "".respond_to?(:encode)
120
- def as_unicode
121
- yield
122
- end
123
- else
124
- def as_unicode
125
- old = $KCODE # rubocop:disable Style/GlobalVars
126
- $KCODE = "U" # rubocop:disable Style/GlobalVars
127
- yield
128
- ensure
129
- $KCODE = old # rubocop:disable Style/GlobalVars
130
- end
131
- end
132
116
  end
133
117
  end
134
118
  end
data/lib/thor/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  class Thor
2
- VERSION = "1.3.0"
2
+ VERSION = "1.3.1"
3
3
  end
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: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yehuda Katz
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2023-10-18 00:00:00.000000000 Z
12
+ date: 2024-02-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -85,9 +85,9 @@ licenses:
85
85
  - MIT
86
86
  metadata:
87
87
  bug_tracker_uri: https://github.com/rails/thor/issues
88
- changelog_uri: https://github.com/rails/thor/releases/tag/v1.3.0
88
+ changelog_uri: https://github.com/rails/thor/releases/tag/v1.3.1
89
89
  documentation_uri: http://whatisthor.com/
90
- source_code_uri: https://github.com/rails/thor/tree/v1.3.0
90
+ source_code_uri: https://github.com/rails/thor/tree/v1.3.1
91
91
  wiki_uri: https://github.com/rails/thor/wiki
92
92
  rubygems_mfa_required: 'true'
93
93
  post_install_message: