thor 0.15.1 → 0.15.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.
- data/.travis.yml +0 -2
- data/Gemfile +0 -4
- data/lib/thor/shell.rb +1 -1
- data/lib/thor/shell/basic.rb +121 -106
- data/lib/thor/util.rb +2 -2
- data/lib/thor/version.rb +1 -1
- data/spec/actions/create_file_spec.rb +3 -3
- data/spec/actions/create_link_spec.rb +1 -1
- data/spec/actions/directory_spec.rb +1 -1
- data/spec/actions/empty_directory_spec.rb +2 -2
- data/spec/actions/file_manipulation_spec.rb +3 -3
- data/spec/actions/inject_into_file_spec.rb +1 -1
- data/spec/actions_spec.rb +3 -3
- data/spec/base_spec.rb +1 -1
- data/spec/core_ext/hash_with_indifferent_access_spec.rb +1 -1
- data/spec/core_ext/ordered_hash_spec.rb +2 -2
- data/spec/group_spec.rb +4 -4
- data/spec/parser/options_spec.rb +6 -6
- data/spec/runner_spec.rb +4 -4
- data/spec/shell/basic_spec.rb +13 -1
- data/spec/spec_helper.rb +1 -1
- data/spec/thor_spec.rb +1 -1
- data/spec/util_spec.rb +1 -1
- metadata +2 -2
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/lib/thor/shell.rb
CHANGED
@@ -23,7 +23,7 @@ class Thor
|
|
23
23
|
end
|
24
24
|
|
25
25
|
module Shell
|
26
|
-
SHELL_DELEGATED_METHODS = [:ask, :error, :set_color, :yes?, :no?, :say, :say_status, :print_table, :print_wrapped, :file_collision]
|
26
|
+
SHELL_DELEGATED_METHODS = [:ask, :error, :set_color, :yes?, :no?, :say, :say_status, :print_in_columns, :print_table, :print_wrapped, :file_collision, :terminal_width]
|
27
27
|
|
28
28
|
autoload :Basic, 'thor/shell/basic'
|
29
29
|
autoload :Color, 'thor/shell/color'
|
data/lib/thor/shell/basic.rb
CHANGED
@@ -103,6 +103,25 @@ class Thor
|
|
103
103
|
!yes?(statement, color)
|
104
104
|
end
|
105
105
|
|
106
|
+
# Prints values in columns
|
107
|
+
#
|
108
|
+
# ==== Parameters
|
109
|
+
# Array[String, String, ...]
|
110
|
+
#
|
111
|
+
def print_in_columns(array)
|
112
|
+
return if array.empty?
|
113
|
+
colwidth = (array.map{|el| el.to_s.size}.max || 0) + 2
|
114
|
+
array.each_with_index do |value, index|
|
115
|
+
# Don't output trailing spaces when printing the last column
|
116
|
+
if (((index + 1) % (terminal_width / colwidth))).zero? && !index.zero?
|
117
|
+
stdout.puts value
|
118
|
+
else
|
119
|
+
stdout.printf("%-#{colwidth}s", value)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
stdout.puts
|
123
|
+
end
|
124
|
+
|
106
125
|
# Prints a table.
|
107
126
|
#
|
108
127
|
# ==== Parameters
|
@@ -112,8 +131,8 @@ class Thor
|
|
112
131
|
# indent<Integer>:: Indent the first column by indent value.
|
113
132
|
# colwidth<Integer>:: Force the first column to colwidth spaces wide.
|
114
133
|
#
|
115
|
-
def print_table(
|
116
|
-
return if
|
134
|
+
def print_table(array, options={})
|
135
|
+
return if array.empty?
|
117
136
|
|
118
137
|
formats, indent, colwidth = [], options[:indent].to_i, options[:colwidth]
|
119
138
|
options[:truncate] = terminal_width if options[:truncate] == true
|
@@ -121,14 +140,14 @@ class Thor
|
|
121
140
|
formats << "%-#{colwidth + 2}s" if colwidth
|
122
141
|
start = colwidth ? 1 : 0
|
123
142
|
|
124
|
-
colcount =
|
143
|
+
colcount = array.max{|a,b| a.size <=> b.size }.size
|
125
144
|
|
126
145
|
maximas = []
|
127
146
|
|
128
|
-
start.upto(colcount - 1) do |
|
129
|
-
maxima =
|
147
|
+
start.upto(colcount - 1) do |index|
|
148
|
+
maxima = array.map {|row| row[index] ? row[index].to_s.size : 0 }.max
|
130
149
|
maximas << maxima
|
131
|
-
if
|
150
|
+
if index == colcount -1
|
132
151
|
# Don't output 2 trailing spaces when printing the last column
|
133
152
|
formats << "%-s"
|
134
153
|
else
|
@@ -139,21 +158,21 @@ class Thor
|
|
139
158
|
formats[0] = formats[0].insert(0, " " * indent)
|
140
159
|
formats << "%s"
|
141
160
|
|
142
|
-
|
161
|
+
array.each do |row|
|
143
162
|
sentence = ""
|
144
163
|
|
145
|
-
row.each_with_index do |column,
|
146
|
-
maxima = maximas[
|
164
|
+
row.each_with_index do |column, index|
|
165
|
+
maxima = maximas[index]
|
147
166
|
|
148
167
|
if column.is_a?(Numeric)
|
149
|
-
if
|
168
|
+
if index == row.size - 1
|
150
169
|
# Don't output 2 trailing spaces when printing the last column
|
151
170
|
f = "%#{maxima}s"
|
152
171
|
else
|
153
172
|
f = "%#{maxima}s "
|
154
173
|
end
|
155
174
|
else
|
156
|
-
f = formats[
|
175
|
+
f = formats[index]
|
157
176
|
end
|
158
177
|
sentence << f % column.to_s
|
159
178
|
end
|
@@ -225,6 +244,19 @@ class Thor
|
|
225
244
|
end
|
226
245
|
end
|
227
246
|
|
247
|
+
# This code was copied from Rake, available under MIT-LICENSE
|
248
|
+
# Copyright (c) 2003, 2004 Jim Weirich
|
249
|
+
def terminal_width
|
250
|
+
if ENV['THOR_COLUMNS']
|
251
|
+
result = ENV['THOR_COLUMNS'].to_i
|
252
|
+
else
|
253
|
+
result = unix? ? dynamic_width : 80
|
254
|
+
end
|
255
|
+
(result < 10) ? 80 : result
|
256
|
+
rescue
|
257
|
+
80
|
258
|
+
end
|
259
|
+
|
228
260
|
# Called if something goes wrong during the execution. This is used by Thor
|
229
261
|
# internally and should not be used inside your scripts. If something went
|
230
262
|
# wrong, you can always raise an exception. If you raise a Thor::Error, it
|
@@ -241,36 +273,36 @@ class Thor
|
|
241
273
|
string
|
242
274
|
end
|
243
275
|
|
244
|
-
|
276
|
+
protected
|
245
277
|
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
278
|
+
def lookup_color(color)
|
279
|
+
return color unless color.is_a?(Symbol)
|
280
|
+
self.class.const_get(color.to_s.upcase)
|
281
|
+
end
|
250
282
|
|
251
|
-
|
252
|
-
|
253
|
-
|
283
|
+
def stdout
|
284
|
+
$stdout
|
285
|
+
end
|
254
286
|
|
255
|
-
|
256
|
-
|
257
|
-
|
287
|
+
def stdin
|
288
|
+
$stdin
|
289
|
+
end
|
258
290
|
|
259
|
-
|
260
|
-
|
261
|
-
|
291
|
+
def stderr
|
292
|
+
$stderr
|
293
|
+
end
|
262
294
|
|
263
|
-
|
264
|
-
|
295
|
+
def is?(value) #:nodoc:
|
296
|
+
value = value.to_s
|
265
297
|
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
end
|
298
|
+
if value.size == 1
|
299
|
+
/\A#{value}\z/i
|
300
|
+
else
|
301
|
+
/\A(#{value}|#{value[0,1]})\z/i
|
271
302
|
end
|
303
|
+
end
|
272
304
|
|
273
|
-
|
305
|
+
def file_collision_help #:nodoc:
|
274
306
|
<<HELP
|
275
307
|
Y - yes, overwrite
|
276
308
|
n - no, do not overwrite
|
@@ -279,96 +311,79 @@ q - quit, abort
|
|
279
311
|
d - diff, show the differences between the old and the new
|
280
312
|
h - help, show this help
|
281
313
|
HELP
|
282
|
-
|
314
|
+
end
|
283
315
|
|
284
|
-
|
285
|
-
|
316
|
+
def show_diff(destination, content) #:nodoc:
|
317
|
+
diff_cmd = ENV['THOR_DIFF'] || ENV['RAILS_DIFF'] || 'diff -u'
|
286
318
|
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
end
|
292
|
-
end
|
293
|
-
|
294
|
-
def quiet? #:nodoc:
|
295
|
-
mute? || (base && base.options[:quiet])
|
296
|
-
end
|
297
|
-
|
298
|
-
# This code was copied from Rake, available under MIT-LICENSE
|
299
|
-
# Copyright (c) 2003, 2004 Jim Weirich
|
300
|
-
def terminal_width
|
301
|
-
if ENV['THOR_COLUMNS']
|
302
|
-
result = ENV['THOR_COLUMNS'].to_i
|
303
|
-
else
|
304
|
-
result = unix? ? dynamic_width : 80
|
305
|
-
end
|
306
|
-
(result < 10) ? 80 : result
|
307
|
-
rescue
|
308
|
-
80
|
319
|
+
Tempfile.open(File.basename(destination), File.dirname(destination)) do |temp|
|
320
|
+
temp.write content
|
321
|
+
temp.rewind
|
322
|
+
system %(#{diff_cmd} "#{destination}" "#{temp.path}")
|
309
323
|
end
|
324
|
+
end
|
310
325
|
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
end
|
326
|
+
def quiet? #:nodoc:
|
327
|
+
mute? || (base && base.options[:quiet])
|
328
|
+
end
|
315
329
|
|
316
|
-
|
317
|
-
|
318
|
-
|
330
|
+
# Calculate the dynamic width of the terminal
|
331
|
+
def dynamic_width
|
332
|
+
@dynamic_width ||= (dynamic_width_stty.nonzero? || dynamic_width_tput)
|
333
|
+
end
|
319
334
|
|
320
|
-
|
321
|
-
|
322
|
-
|
335
|
+
def dynamic_width_stty
|
336
|
+
%x{stty size 2>/dev/null}.split[1].to_i
|
337
|
+
end
|
323
338
|
|
324
|
-
|
325
|
-
|
326
|
-
|
339
|
+
def dynamic_width_tput
|
340
|
+
%x{tput cols 2>/dev/null}.to_i
|
341
|
+
end
|
327
342
|
|
328
|
-
|
329
|
-
|
330
|
-
|
343
|
+
def unix?
|
344
|
+
RUBY_PLATFORM =~ /(aix|darwin|linux|(net|free|open)bsd|cygwin|solaris|irix|hpux)/i
|
345
|
+
end
|
331
346
|
|
332
|
-
|
333
|
-
|
334
|
-
|
335
|
-
|
336
|
-
|
347
|
+
def truncate(string, width)
|
348
|
+
as_unicode do
|
349
|
+
chars = string.chars.to_a
|
350
|
+
if chars.length <= width
|
351
|
+
chars.join
|
352
|
+
else
|
353
|
+
( chars[0, width-3].join ) + "..."
|
337
354
|
end
|
338
355
|
end
|
356
|
+
end
|
339
357
|
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
end
|
344
|
-
else
|
345
|
-
def as_unicode
|
346
|
-
old, $KCODE = $KCODE, "U"
|
347
|
-
yield
|
348
|
-
ensure
|
349
|
-
$KCODE = old
|
350
|
-
end
|
358
|
+
if "".respond_to?(:encode)
|
359
|
+
def as_unicode
|
360
|
+
yield
|
351
361
|
end
|
352
|
-
|
353
|
-
def
|
354
|
-
|
355
|
-
|
362
|
+
else
|
363
|
+
def as_unicode
|
364
|
+
old, $KCODE = $KCODE, "U"
|
365
|
+
yield
|
366
|
+
ensure
|
367
|
+
$KCODE = old
|
356
368
|
end
|
369
|
+
end
|
357
370
|
|
358
|
-
|
359
|
-
|
360
|
-
|
361
|
-
|
362
|
-
answer = ask_simply("#{statement} #{answer_set.inspect}", *args)
|
363
|
-
|
364
|
-
correct_answer = answer_set.include?(answer) ? answer : nil
|
365
|
-
|
366
|
-
answers = answer_set.map(&:inspect).join(", ")
|
367
|
-
say("Your response must be one of: [#{answers}]. Please try again.") unless correct_answer
|
368
|
-
end
|
371
|
+
def ask_simply(statement, color=nil)
|
372
|
+
say("#{statement} ", color)
|
373
|
+
stdin.gets.strip
|
374
|
+
end
|
369
375
|
|
370
|
-
|
376
|
+
def ask_filtered(statement, answer_set, *args)
|
377
|
+
correct_answer = nil
|
378
|
+
until correct_answer
|
379
|
+
answer = ask_simply("#{statement} #{answer_set.inspect}", *args)
|
380
|
+
correct_answer = answer_set.include?(answer) ? answer : nil
|
381
|
+
answers = answer_set.map(&:inspect).join(", ")
|
382
|
+
say("Your response must be one of: [#{answers}]. Please try again.") unless correct_answer
|
371
383
|
end
|
384
|
+
correct_answer
|
385
|
+
end
|
386
|
+
|
372
387
|
end
|
373
388
|
end
|
374
389
|
end
|
data/lib/thor/util.rb
CHANGED
@@ -225,11 +225,11 @@ class Thor
|
|
225
225
|
begin
|
226
226
|
alternate_ruby = File.join(RbConfig::CONFIG['bindir'], 'ruby')
|
227
227
|
alternate_ruby << RbConfig::CONFIG['EXEEXT']
|
228
|
-
|
228
|
+
|
229
229
|
# ruby is a symlink
|
230
230
|
if File.symlink? alternate_ruby
|
231
231
|
linked_ruby = File.readlink alternate_ruby
|
232
|
-
|
232
|
+
|
233
233
|
# symlink points to 'ruby_install_name'
|
234
234
|
ruby = alternate_ruby if linked_ruby == ruby_name || linked_ruby == ruby
|
235
235
|
end
|
data/lib/thor/version.rb
CHANGED
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
2
|
require 'thor/actions'
|
3
3
|
|
4
4
|
describe Thor::Actions::CreateFile do
|
5
|
-
before
|
5
|
+
before do
|
6
6
|
::FileUtils.rm_rf(destination_root)
|
7
7
|
end
|
8
8
|
|
@@ -63,7 +63,7 @@ describe Thor::Actions::CreateFile do
|
|
63
63
|
end
|
64
64
|
|
65
65
|
describe "when file exists" do
|
66
|
-
before
|
66
|
+
before do
|
67
67
|
create_file("doc/config.rb")
|
68
68
|
invoke!
|
69
69
|
end
|
@@ -77,7 +77,7 @@ describe Thor::Actions::CreateFile do
|
|
77
77
|
end
|
78
78
|
|
79
79
|
describe "and is not identical" do
|
80
|
-
before
|
80
|
+
before do
|
81
81
|
File.open(File.join(destination_root, 'doc/config.rb'), 'w'){ |f| f.write("FOO = 3") }
|
82
82
|
end
|
83
83
|
|
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
2
|
require 'thor/actions'
|
3
3
|
|
4
4
|
describe Thor::Actions::EmptyDirectory do
|
5
|
-
before
|
5
|
+
before do
|
6
6
|
::FileUtils.rm_rf(destination_root)
|
7
7
|
end
|
8
8
|
|
@@ -98,7 +98,7 @@ describe Thor::Actions::EmptyDirectory do
|
|
98
98
|
|
99
99
|
context "protected methods" do
|
100
100
|
describe "#convert_encoded_instructions" do
|
101
|
-
before
|
101
|
+
before do
|
102
102
|
empty_directory("test_dir")
|
103
103
|
@action.base.stub!(:file_name).and_return("expected")
|
104
104
|
end
|
@@ -23,7 +23,7 @@ describe Thor::Actions do
|
|
23
23
|
File.join(destination_root, "foo")
|
24
24
|
end
|
25
25
|
|
26
|
-
before
|
26
|
+
before do
|
27
27
|
::FileUtils.rm_rf(destination_root)
|
28
28
|
end
|
29
29
|
|
@@ -197,7 +197,7 @@ describe Thor::Actions do
|
|
197
197
|
end
|
198
198
|
|
199
199
|
describe "when changing existent files" do
|
200
|
-
before
|
200
|
+
before do
|
201
201
|
::FileUtils.cp_r(source_root, destination_root)
|
202
202
|
end
|
203
203
|
|
@@ -316,7 +316,7 @@ describe Thor::Actions do
|
|
316
316
|
end
|
317
317
|
|
318
318
|
describe "when adjusting comments" do
|
319
|
-
before
|
319
|
+
before do
|
320
320
|
::FileUtils.cp_r(source_root, destination_root)
|
321
321
|
end
|
322
322
|
|
data/spec/actions_spec.rb
CHANGED
@@ -198,7 +198,7 @@ describe Thor::Actions do
|
|
198
198
|
end
|
199
199
|
|
200
200
|
describe "#apply" do
|
201
|
-
before
|
201
|
+
before do
|
202
202
|
@template = <<-TEMPLATE
|
203
203
|
@foo = "FOO"
|
204
204
|
say_status :cool, :padding
|
@@ -248,7 +248,7 @@ describe Thor::Actions do
|
|
248
248
|
end
|
249
249
|
|
250
250
|
describe "#run" do
|
251
|
-
before
|
251
|
+
before do
|
252
252
|
runner.should_receive(:system).with("ls")
|
253
253
|
end
|
254
254
|
|
@@ -271,7 +271,7 @@ describe Thor::Actions do
|
|
271
271
|
end
|
272
272
|
|
273
273
|
describe "#run_ruby_script" do
|
274
|
-
before
|
274
|
+
before do
|
275
275
|
Thor::Util.stub!(:ruby_command).and_return("/opt/jruby")
|
276
276
|
runner.should_receive(:system).with("/opt/jruby script.rb")
|
277
277
|
end
|
data/spec/base_spec.rb
CHANGED
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
2
|
require 'thor/core_ext/hash_with_indifferent_access'
|
3
3
|
|
4
4
|
describe Thor::CoreExt::HashWithIndifferentAccess do
|
5
|
-
before
|
5
|
+
before do
|
6
6
|
@hash = Thor::CoreExt::HashWithIndifferentAccess.new :foo => 'bar', 'baz' => 'bee', :force => true
|
7
7
|
end
|
8
8
|
|
@@ -2,7 +2,7 @@ require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
2
|
require 'thor/core_ext/ordered_hash'
|
3
3
|
|
4
4
|
describe Thor::CoreExt::OrderedHash do
|
5
|
-
before
|
5
|
+
before do
|
6
6
|
@hash = Thor::CoreExt::OrderedHash.new
|
7
7
|
end
|
8
8
|
|
@@ -26,7 +26,7 @@ describe Thor::CoreExt::OrderedHash do
|
|
26
26
|
end
|
27
27
|
|
28
28
|
describe "with several items" do
|
29
|
-
before
|
29
|
+
before do
|
30
30
|
@hash[:foo] = "Foo!"
|
31
31
|
@hash[:bar] = "Bar!"
|
32
32
|
@hash[:baz] = "Baz!"
|
data/spec/group_spec.rb
CHANGED
@@ -56,7 +56,7 @@ describe Thor::Group do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
describe "#help" do
|
59
|
-
before
|
59
|
+
before do
|
60
60
|
@content = capture(:stdout){ MyCounter.help(Thor::Base.shell.new) }
|
61
61
|
end
|
62
62
|
|
@@ -76,7 +76,7 @@ describe Thor::Group do
|
|
76
76
|
end
|
77
77
|
|
78
78
|
describe "#invoke" do
|
79
|
-
before
|
79
|
+
before do
|
80
80
|
@content = capture(:stdout){ E.start }
|
81
81
|
end
|
82
82
|
|
@@ -108,7 +108,7 @@ describe Thor::Group do
|
|
108
108
|
|
109
109
|
describe "#invoke_from_option" do
|
110
110
|
describe "with default type" do
|
111
|
-
before
|
111
|
+
before do
|
112
112
|
@content = capture(:stdout){ G.start }
|
113
113
|
end
|
114
114
|
|
@@ -147,7 +147,7 @@ describe Thor::Group do
|
|
147
147
|
end
|
148
148
|
|
149
149
|
describe "with boolean type" do
|
150
|
-
before
|
150
|
+
before do
|
151
151
|
@content = capture(:stdout){ H.start }
|
152
152
|
end
|
153
153
|
|
data/spec/parser/options_spec.rb
CHANGED
@@ -151,7 +151,7 @@ describe Thor::Options do
|
|
151
151
|
end
|
152
152
|
|
153
153
|
describe "with one required and one optional switch" do
|
154
|
-
before
|
154
|
+
before do
|
155
155
|
create "--foo" => :required, "--bar" => :boolean
|
156
156
|
end
|
157
157
|
|
@@ -174,7 +174,7 @@ describe Thor::Options do
|
|
174
174
|
end
|
175
175
|
|
176
176
|
describe "with :string type" do
|
177
|
-
before
|
177
|
+
before do
|
178
178
|
create ["--foo", "-f"] => :required
|
179
179
|
end
|
180
180
|
|
@@ -220,7 +220,7 @@ describe Thor::Options do
|
|
220
220
|
end
|
221
221
|
|
222
222
|
describe "with :boolean type" do
|
223
|
-
before
|
223
|
+
before do
|
224
224
|
create "--foo" => false
|
225
225
|
end
|
226
226
|
|
@@ -271,7 +271,7 @@ describe Thor::Options do
|
|
271
271
|
end
|
272
272
|
|
273
273
|
describe "with :hash type" do
|
274
|
-
before
|
274
|
+
before do
|
275
275
|
create "--attributes" => :hash
|
276
276
|
end
|
277
277
|
|
@@ -289,7 +289,7 @@ describe Thor::Options do
|
|
289
289
|
end
|
290
290
|
|
291
291
|
describe "with :array type" do
|
292
|
-
before
|
292
|
+
before do
|
293
293
|
create "--attributes" => :array
|
294
294
|
end
|
295
295
|
|
@@ -307,7 +307,7 @@ describe Thor::Options do
|
|
307
307
|
end
|
308
308
|
|
309
309
|
describe "with :numeric type" do
|
310
|
-
before
|
310
|
+
before do
|
311
311
|
create "n" => :numeric, "m" => 5
|
312
312
|
end
|
313
313
|
|
data/spec/runner_spec.rb
CHANGED
@@ -117,7 +117,7 @@ describe Thor::Runner do
|
|
117
117
|
end
|
118
118
|
|
119
119
|
describe "tasks" do
|
120
|
-
before
|
120
|
+
before do
|
121
121
|
@location = "#{File.dirname(__FILE__)}/fixtures/task.thor"
|
122
122
|
@original_yaml = {
|
123
123
|
"random" => {
|
@@ -190,7 +190,7 @@ describe Thor::Runner do
|
|
190
190
|
end
|
191
191
|
|
192
192
|
describe "uninstall" do
|
193
|
-
before
|
193
|
+
before do
|
194
194
|
path = File.join(Thor::Util.thor_root, @original_yaml["random"][:filename])
|
195
195
|
FileUtils.should_receive(:rm_rf).with(path)
|
196
196
|
end
|
@@ -201,7 +201,7 @@ describe Thor::Runner do
|
|
201
201
|
end
|
202
202
|
|
203
203
|
describe "installed" do
|
204
|
-
before
|
204
|
+
before do
|
205
205
|
Dir.should_receive(:[]).and_return([])
|
206
206
|
end
|
207
207
|
|
@@ -213,7 +213,7 @@ describe Thor::Runner do
|
|
213
213
|
end
|
214
214
|
|
215
215
|
describe "install/update" do
|
216
|
-
before
|
216
|
+
before do
|
217
217
|
FileUtils.stub!(:mkdir_p)
|
218
218
|
FileUtils.stub!(:touch)
|
219
219
|
$stdin.stub!(:gets).and_return("Y")
|
data/spec/shell/basic_spec.rb
CHANGED
@@ -120,8 +120,20 @@ describe Thor::Shell::Basic do
|
|
120
120
|
end
|
121
121
|
end
|
122
122
|
|
123
|
+
describe "#print_in_columns" do
|
124
|
+
before do
|
125
|
+
@array = [1234567890]
|
126
|
+
@array += ('a'..'e').to_a
|
127
|
+
end
|
128
|
+
|
129
|
+
it "prints in columns" do
|
130
|
+
content = capture(:stdout){ shell.print_in_columns(@array) }
|
131
|
+
content.rstrip.should == "1234567890 a b c d e"
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
123
135
|
describe "#print_table" do
|
124
|
-
before
|
136
|
+
before do
|
125
137
|
@table = []
|
126
138
|
@table << ["abc", "#123", "first three"]
|
127
139
|
@table << ["", "#0", "empty"]
|
data/spec/spec_helper.rb
CHANGED
data/spec/thor_spec.rb
CHANGED
data/spec/util_spec.rb
CHANGED
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.15.
|
4
|
+
version: 0.15.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-05-
|
13
|
+
date: 2012-05-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|