rubysl-fileutils 1.0.0 → 2.0.0
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 +4 -4
- data/.travis.yml +2 -2
- data/lib/rubysl/fileutils/fileutils.rb +183 -75
- data/lib/rubysl/fileutils/version.rb +1 -1
- data/rubysl-fileutils.gemspec +2 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 173d0166bae6fc09c6d92734779f6154ab902977
|
4
|
+
data.tar.gz: 94834b7147331eb2267fdb562f8a36fb20e0f6e5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1ad8a03fc6f39ad60cd1ccdbe7f3be92c5a3c125b2740b3ec2a7401b255b4fd03319f99f9676909e6480369bf919f9212ec2cc8b72b054f1d71250846add46bd
|
7
|
+
data.tar.gz: bc42abdd8c74f0a52d4a262b340f801bfc74abfc55818e55d6fcb550ad14856ef7144971cd735c29326d459e55c0dcb6ac4546e7e8196b68dc157acf4382cecc
|
data/.travis.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# = fileutils.rb
|
3
3
|
#
|
4
|
-
# Copyright (c) 2000-
|
4
|
+
# Copyright (c) 2000-2007 Minero Aoki
|
5
5
|
#
|
6
6
|
# This program is free software.
|
7
7
|
# You can distribute/modify this program under the same terms of ruby.
|
@@ -115,6 +115,10 @@ module FileUtils
|
|
115
115
|
#
|
116
116
|
# FileUtils.cd('/', :verbose => true) # chdir and report it
|
117
117
|
#
|
118
|
+
# FileUtils.cd('/') do # chdir
|
119
|
+
# [...] # do something
|
120
|
+
# end # return to original directory
|
121
|
+
#
|
118
122
|
def cd(dir, options = {}, &block) # :yield: dir
|
119
123
|
fu_check_options options, OPT_TABLE['cd']
|
120
124
|
fu_output_message "cd #{dir}" if options[:verbose]
|
@@ -198,7 +202,7 @@ module FileUtils
|
|
198
202
|
fu_output_message "mkdir -p #{options[:mode] ? ('-m %03o ' % options[:mode]) : ''}#{list.join ' '}" if options[:verbose]
|
199
203
|
return *list if options[:noop]
|
200
204
|
|
201
|
-
list.map {|path| path.
|
205
|
+
list.map {|path| path.chomp(?/) }.each do |path|
|
202
206
|
# optimize for the most common case
|
203
207
|
begin
|
204
208
|
fu_mkdir path, options[:mode]
|
@@ -212,11 +216,11 @@ module FileUtils
|
|
212
216
|
stack.push path
|
213
217
|
path = File.dirname(path)
|
214
218
|
end
|
215
|
-
stack.reverse_each do |
|
219
|
+
stack.reverse_each do |dir|
|
216
220
|
begin
|
217
|
-
fu_mkdir
|
218
|
-
rescue SystemCallError
|
219
|
-
raise unless File.directory?(
|
221
|
+
fu_mkdir dir, options[:mode]
|
222
|
+
rescue SystemCallError
|
223
|
+
raise unless File.directory?(dir)
|
220
224
|
end
|
221
225
|
end
|
222
226
|
end
|
@@ -235,7 +239,7 @@ module FileUtils
|
|
235
239
|
OPT_TABLE['makedirs'] = [:mode, :noop, :verbose]
|
236
240
|
|
237
241
|
def fu_mkdir(path, mode) #:nodoc:
|
238
|
-
path = path.
|
242
|
+
path = path.chomp(?/)
|
239
243
|
if mode
|
240
244
|
Dir.mkdir path, mode
|
241
245
|
File.chmod mode, path
|
@@ -258,15 +262,24 @@ module FileUtils
|
|
258
262
|
def rmdir(list, options = {})
|
259
263
|
fu_check_options options, OPT_TABLE['rmdir']
|
260
264
|
list = fu_list(list)
|
261
|
-
|
265
|
+
parents = options[:parents]
|
266
|
+
fu_output_message "rmdir #{parents ? '-p ' : ''}#{list.join ' '}" if options[:verbose]
|
262
267
|
return if options[:noop]
|
263
268
|
list.each do |dir|
|
264
|
-
|
269
|
+
begin
|
270
|
+
Dir.rmdir(dir = dir.chomp(?/))
|
271
|
+
if parents
|
272
|
+
until (parent = File.dirname(dir)) == '.' or parent == dir
|
273
|
+
Dir.rmdir(dir)
|
274
|
+
end
|
275
|
+
end
|
276
|
+
rescue Errno::ENOTEMPTY, Errno::ENOENT
|
277
|
+
end
|
265
278
|
end
|
266
279
|
end
|
267
280
|
module_function :rmdir
|
268
281
|
|
269
|
-
OPT_TABLE['rmdir'] = [:noop, :verbose]
|
282
|
+
OPT_TABLE['rmdir'] = [:parents, :noop, :verbose]
|
270
283
|
|
271
284
|
#
|
272
285
|
# Options: force noop verbose
|
@@ -472,7 +485,7 @@ module FileUtils
|
|
472
485
|
# +dest+ must respond to #write(str).
|
473
486
|
#
|
474
487
|
def copy_stream(src, dest)
|
475
|
-
|
488
|
+
IO.copy_stream(src, dest)
|
476
489
|
end
|
477
490
|
module_function :copy_stream
|
478
491
|
|
@@ -480,7 +493,7 @@ module FileUtils
|
|
480
493
|
# Options: force noop verbose
|
481
494
|
#
|
482
495
|
# Moves file(s) +src+ to +dest+. If +file+ and +dest+ exist on the different
|
483
|
-
# disk partition, the file is copied
|
496
|
+
# disk partition, the file is copied then the original file is removed.
|
484
497
|
#
|
485
498
|
# FileUtils.mv 'badname.rb', 'goodname.rb'
|
486
499
|
# FileUtils.mv 'stuff.rb', '/notexist/lib/ruby', :force => true # no error
|
@@ -526,7 +539,7 @@ module FileUtils
|
|
526
539
|
OPT_TABLE['move'] = [:force, :noop, :verbose, :secure]
|
527
540
|
|
528
541
|
def rename_cannot_overwrite_file? #:nodoc:
|
529
|
-
/
|
542
|
+
/cygwin|mswin|mingw|bccwin|emx/ =~ RUBY_PLATFORM
|
530
543
|
end
|
531
544
|
private_module_function :rename_cannot_overwrite_file?
|
532
545
|
|
@@ -687,7 +700,7 @@ module FileUtils
|
|
687
700
|
end
|
688
701
|
# is a directory.
|
689
702
|
parent_st = File.stat(File.dirname(fullpath))
|
690
|
-
unless
|
703
|
+
unless parent_st.world_writable?
|
691
704
|
remove_entry path, force
|
692
705
|
return
|
693
706
|
end
|
@@ -730,12 +743,7 @@ module FileUtils
|
|
730
743
|
end
|
731
744
|
module_function :remove_entry_secure
|
732
745
|
|
733
|
-
def
|
734
|
-
(st.mode & 0002) != 0
|
735
|
-
end
|
736
|
-
private_module_function :fu_world_writable?
|
737
|
-
|
738
|
-
def fu_have_symlink? #:nodoc
|
746
|
+
def fu_have_symlink? #:nodoc:
|
739
747
|
File.symlink nil, nil
|
740
748
|
rescue NotImplementedError
|
741
749
|
return false
|
@@ -843,10 +851,9 @@ module FileUtils
|
|
843
851
|
fu_check_options options, OPT_TABLE['install']
|
844
852
|
fu_output_message "install -c#{options[:preserve] && ' -p'}#{options[:mode] ? (' -m 0%o' % options[:mode]) : ''} #{[src,dest].flatten.join ' '}" if options[:verbose]
|
845
853
|
return if options[:noop]
|
846
|
-
fu_each_src_dest(src, dest) do |s, d|
|
854
|
+
fu_each_src_dest(src, dest) do |s, d, st|
|
847
855
|
unless File.exist?(d) and compare_file(s, d)
|
848
856
|
remove_file d, true
|
849
|
-
st = File.stat(s) if options[:preserve]
|
850
857
|
copy_file s, d
|
851
858
|
File.utime st.atime, st.mtime, d if options[:preserve]
|
852
859
|
File.chmod options[:mode], d if options[:mode]
|
@@ -857,23 +864,110 @@ module FileUtils
|
|
857
864
|
|
858
865
|
OPT_TABLE['install'] = [:mode, :preserve, :noop, :verbose]
|
859
866
|
|
867
|
+
def user_mask(target) #:nodoc:
|
868
|
+
mask = 0
|
869
|
+
target.each_byte do |byte_chr|
|
870
|
+
case byte_chr.chr
|
871
|
+
when "u"
|
872
|
+
mask |= 04700
|
873
|
+
when "g"
|
874
|
+
mask |= 02070
|
875
|
+
when "o"
|
876
|
+
mask |= 01007
|
877
|
+
when "a"
|
878
|
+
mask |= 07777
|
879
|
+
end
|
880
|
+
end
|
881
|
+
mask
|
882
|
+
end
|
883
|
+
private_module_function :user_mask
|
884
|
+
|
885
|
+
def mode_mask(mode, path) #:nodoc:
|
886
|
+
mask = 0
|
887
|
+
mode.each_byte do |byte_chr|
|
888
|
+
case byte_chr.chr
|
889
|
+
when "r"
|
890
|
+
mask |= 0444
|
891
|
+
when "w"
|
892
|
+
mask |= 0222
|
893
|
+
when "x"
|
894
|
+
mask |= 0111
|
895
|
+
when "X"
|
896
|
+
mask |= 0111 if FileTest::directory? path
|
897
|
+
when "s"
|
898
|
+
mask |= 06000
|
899
|
+
when "t"
|
900
|
+
mask |= 01000
|
901
|
+
end
|
902
|
+
end
|
903
|
+
mask
|
904
|
+
end
|
905
|
+
private_module_function :mode_mask
|
906
|
+
|
907
|
+
def symbolic_modes_to_i(modes, path) #:nodoc:
|
908
|
+
current_mode = (File.stat(path).mode & 07777)
|
909
|
+
modes.split(/,/).inject(0) do |mode, mode_sym|
|
910
|
+
mode_sym = "a#{mode_sym}" if mode_sym =~ %r!^[+-=]!
|
911
|
+
target, mode = mode_sym.split %r![+-=]!
|
912
|
+
user_mask = user_mask(target)
|
913
|
+
mode_mask = mode_mask(mode ? mode : "", path)
|
914
|
+
|
915
|
+
case mode_sym
|
916
|
+
when /=/
|
917
|
+
current_mode &= ~(user_mask)
|
918
|
+
current_mode |= user_mask & mode_mask
|
919
|
+
when /\+/
|
920
|
+
current_mode |= user_mask & mode_mask
|
921
|
+
when /-/
|
922
|
+
current_mode &= ~(user_mask & mode_mask)
|
923
|
+
end
|
924
|
+
end
|
925
|
+
end
|
926
|
+
private_module_function :symbolic_modes_to_i
|
927
|
+
|
928
|
+
def fu_mode(mode, path) #:nodoc:
|
929
|
+
mode.is_a?(String) ? symbolic_modes_to_i(mode, path) : mode
|
930
|
+
end
|
931
|
+
private_module_function :fu_mode
|
932
|
+
|
860
933
|
#
|
861
934
|
# Options: noop verbose
|
862
935
|
#
|
863
936
|
# Changes permission bits on the named files (in +list+) to the bit pattern
|
864
937
|
# represented by +mode+.
|
865
938
|
#
|
939
|
+
# +mode+ is the symbolic and absolute mode can be used.
|
940
|
+
#
|
941
|
+
# Absolute mode is
|
866
942
|
# FileUtils.chmod 0755, 'somecommand'
|
867
943
|
# FileUtils.chmod 0644, %w(my.rb your.rb his.rb her.rb)
|
868
944
|
# FileUtils.chmod 0755, '/usr/bin/ruby', :verbose => true
|
869
945
|
#
|
946
|
+
# Symbolic mode is
|
947
|
+
# FileUtils.chmod "u=wrx,go=rx", 'somecommand'
|
948
|
+
# FileUtils.chmod "u=wr,go=rr", %w(my.rb your.rb his.rb her.rb)
|
949
|
+
# FileUtils.chmod "u=wrx,go=rx", '/usr/bin/ruby', :verbose => true
|
950
|
+
#
|
951
|
+
# "a" is user, group, other mask.
|
952
|
+
# "u" is user's mask.
|
953
|
+
# "g" is group's mask.
|
954
|
+
# "o" is other's mask.
|
955
|
+
# "w" is write permission.
|
956
|
+
# "r" is read permission.
|
957
|
+
# "x" is execute permission.
|
958
|
+
# "s" is uid, gid.
|
959
|
+
# "t" is sticky bit.
|
960
|
+
# "+" is added to a class given the specified mode.
|
961
|
+
# "-" Is removed from a given class given mode.
|
962
|
+
# "=" Is the exact nature of the class will be given a specified mode.
|
963
|
+
|
870
964
|
def chmod(mode, list, options = {})
|
871
965
|
fu_check_options options, OPT_TABLE['chmod']
|
872
966
|
list = fu_list(list)
|
873
967
|
fu_output_message sprintf('chmod %o %s', mode, list.join(' ')) if options[:verbose]
|
874
968
|
return if options[:noop]
|
875
969
|
list.each do |path|
|
876
|
-
Entry_.new(path).chmod
|
970
|
+
Entry_.new(path).chmod(fu_mode(mode, path))
|
877
971
|
end
|
878
972
|
end
|
879
973
|
module_function :chmod
|
@@ -887,6 +981,7 @@ module FileUtils
|
|
887
981
|
# to the bit pattern represented by +mode+.
|
888
982
|
#
|
889
983
|
# FileUtils.chmod_R 0700, "/tmp/app.#{$$}"
|
984
|
+
# FileUtils.chmod_R "u=wrx", "/tmp/app.#{$$}"
|
890
985
|
#
|
891
986
|
def chmod_R(mode, list, options = {})
|
892
987
|
fu_check_options options, OPT_TABLE['chmod_R']
|
@@ -898,7 +993,7 @@ module FileUtils
|
|
898
993
|
list.each do |root|
|
899
994
|
Entry_.new(root).traverse do |ent|
|
900
995
|
begin
|
901
|
-
ent.chmod
|
996
|
+
ent.chmod(fu_mode(mode, ent.path))
|
902
997
|
rescue
|
903
998
|
raise unless options[:force]
|
904
999
|
end
|
@@ -980,20 +1075,26 @@ module FileUtils
|
|
980
1075
|
|
981
1076
|
def fu_get_uid(user) #:nodoc:
|
982
1077
|
return nil unless user
|
983
|
-
|
984
|
-
|
985
|
-
|
986
|
-
|
1078
|
+
case user
|
1079
|
+
when Integer
|
1080
|
+
user
|
1081
|
+
when /\A\d+\z/
|
1082
|
+
user.to_i
|
1083
|
+
else
|
1084
|
+
Etc.getpwnam(user).uid
|
987
1085
|
end
|
988
1086
|
end
|
989
1087
|
private_module_function :fu_get_uid
|
990
1088
|
|
991
1089
|
def fu_get_gid(group) #:nodoc:
|
992
1090
|
return nil unless group
|
993
|
-
|
994
|
-
|
995
|
-
|
996
|
-
|
1091
|
+
case group
|
1092
|
+
when Integer
|
1093
|
+
group
|
1094
|
+
when /\A\d+\z/
|
1095
|
+
group.to_i
|
1096
|
+
else
|
1097
|
+
Etc.getgrnam(group).gid
|
997
1098
|
end
|
998
1099
|
end
|
999
1100
|
private_module_function :fu_get_gid
|
@@ -1027,7 +1128,7 @@ module FileUtils
|
|
1027
1128
|
created = nocreate = options[:nocreate]
|
1028
1129
|
t = options[:mtime]
|
1029
1130
|
if options[:verbose]
|
1030
|
-
fu_output_message "touch #{nocreate ? '
|
1131
|
+
fu_output_message "touch #{nocreate ? '-c ' : ''}#{t ? t.strftime('-t %Y%m%d%H%M.%S ') : ''}#{list.join ' '}"
|
1031
1132
|
end
|
1032
1133
|
return if options[:noop]
|
1033
1134
|
list.each do |path|
|
@@ -1054,14 +1155,11 @@ module FileUtils
|
|
1054
1155
|
private
|
1055
1156
|
|
1056
1157
|
def fu_windows?
|
1057
|
-
/mswin|mingw|bccwin|
|
1158
|
+
/mswin|mingw|bccwin|emx/ =~ RUBY_PLATFORM
|
1058
1159
|
end
|
1059
1160
|
|
1060
|
-
def fu_copy_stream0(src, dest, blksize) #:nodoc:
|
1061
|
-
|
1062
|
-
while s = src.read(blksize)
|
1063
|
-
dest.write s
|
1064
|
-
end
|
1161
|
+
def fu_copy_stream0(src, dest, blksize = nil) #:nodoc:
|
1162
|
+
IO.copy_stream(src, dest)
|
1065
1163
|
end
|
1066
1164
|
|
1067
1165
|
def fu_stream_blksize(*streams)
|
@@ -1110,7 +1208,7 @@ module FileUtils
|
|
1110
1208
|
|
1111
1209
|
def path
|
1112
1210
|
if @path
|
1113
|
-
@path
|
1211
|
+
File.path(@path)
|
1114
1212
|
else
|
1115
1213
|
join(@prefix, @rel)
|
1116
1214
|
end
|
@@ -1175,7 +1273,9 @@ module FileUtils
|
|
1175
1273
|
end
|
1176
1274
|
|
1177
1275
|
def entries
|
1178
|
-
|
1276
|
+
opts = {}
|
1277
|
+
opts[:encoding] = ::Encoding::UTF_8 if fu_windows?
|
1278
|
+
Dir.entries(path(), opts)\
|
1179
1279
|
.reject {|n| n == '.' or n == '..' }\
|
1180
1280
|
.map {|n| Entry_.new(prefix(), join(rel(), n.untaint)) }
|
1181
1281
|
end
|
@@ -1237,6 +1337,9 @@ module FileUtils
|
|
1237
1337
|
when file?
|
1238
1338
|
copy_file dest
|
1239
1339
|
when directory?
|
1340
|
+
if !File.exist?(dest) and descendant_diretory?(dest, path)
|
1341
|
+
raise ArgumentError, "cannot copy directory %s to itself %s" % [path, dest]
|
1342
|
+
end
|
1240
1343
|
begin
|
1241
1344
|
Dir.mkdir dest
|
1242
1345
|
rescue
|
@@ -1264,12 +1367,11 @@ module FileUtils
|
|
1264
1367
|
end
|
1265
1368
|
|
1266
1369
|
def copy_file(dest)
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
}
|
1370
|
+
File.open(path()) do |s|
|
1371
|
+
File.open(dest, 'wb', s.stat.mode) do |f|
|
1372
|
+
IO.copy_stream(s, f)
|
1373
|
+
end
|
1374
|
+
end
|
1273
1375
|
end
|
1274
1376
|
|
1275
1377
|
def copy_metadata(path)
|
@@ -1295,7 +1397,7 @@ module FileUtils
|
|
1295
1397
|
|
1296
1398
|
def remove_dir1
|
1297
1399
|
platform_support {
|
1298
|
-
Dir.rmdir path().
|
1400
|
+
Dir.rmdir path().chomp(?/)
|
1299
1401
|
}
|
1300
1402
|
end
|
1301
1403
|
|
@@ -1385,60 +1487,58 @@ module FileUtils
|
|
1385
1487
|
end
|
1386
1488
|
|
1387
1489
|
def join(dir, base)
|
1388
|
-
return dir
|
1389
|
-
return base
|
1490
|
+
return File.path(dir) if not base or base == '.'
|
1491
|
+
return File.path(base) if not dir or dir == '.'
|
1390
1492
|
File.join(dir, base)
|
1391
1493
|
end
|
1494
|
+
|
1495
|
+
if File::ALT_SEPARATOR
|
1496
|
+
DIRECTORY_TERM = "(?=[/#{Regexp.quote(File::ALT_SEPARATOR)}]|\\z)".freeze
|
1497
|
+
else
|
1498
|
+
DIRECTORY_TERM = "(?=/|\\z)".freeze
|
1499
|
+
end
|
1500
|
+
SYSCASE = File::FNM_SYSCASE.nonzero? ? "-i" : ""
|
1501
|
+
|
1502
|
+
def descendant_diretory?(descendant, ascendant)
|
1503
|
+
/\A(?#{SYSCASE}:#{Regexp.quote(ascendant)})#{DIRECTORY_TERM}/ =~ File.dirname(descendant)
|
1504
|
+
end
|
1392
1505
|
end # class Entry_
|
1393
1506
|
|
1394
1507
|
def fu_list(arg) #:nodoc:
|
1395
|
-
[arg].flatten.map {|path| path
|
1508
|
+
[arg].flatten.map {|path| File.path(path) }
|
1396
1509
|
end
|
1397
1510
|
private_module_function :fu_list
|
1398
1511
|
|
1399
1512
|
def fu_each_src_dest(src, dest) #:nodoc:
|
1400
1513
|
fu_each_src_dest0(src, dest) do |s, d|
|
1401
1514
|
raise ArgumentError, "same file: #{s} and #{d}" if fu_same?(s, d)
|
1402
|
-
yield s, d
|
1515
|
+
yield s, d, File.stat(s)
|
1403
1516
|
end
|
1404
1517
|
end
|
1405
1518
|
private_module_function :fu_each_src_dest
|
1406
1519
|
|
1407
1520
|
def fu_each_src_dest0(src, dest) #:nodoc:
|
1408
|
-
if
|
1409
|
-
|
1410
|
-
s = s
|
1521
|
+
if tmp = Array.try_convert(src)
|
1522
|
+
tmp.each do |s|
|
1523
|
+
s = File.path(s)
|
1411
1524
|
yield s, File.join(dest, File.basename(s))
|
1412
1525
|
end
|
1413
1526
|
else
|
1414
|
-
src = src
|
1527
|
+
src = File.path(src)
|
1415
1528
|
if File.directory?(dest)
|
1416
1529
|
yield src, File.join(dest, File.basename(src))
|
1417
1530
|
else
|
1418
|
-
yield src, dest
|
1531
|
+
yield src, File.path(dest)
|
1419
1532
|
end
|
1420
1533
|
end
|
1421
1534
|
end
|
1422
1535
|
private_module_function :fu_each_src_dest0
|
1423
1536
|
|
1424
1537
|
def fu_same?(a, b) #:nodoc:
|
1425
|
-
|
1426
|
-
st1 = File.stat(a)
|
1427
|
-
st2 = File.stat(b)
|
1428
|
-
st1.dev == st2.dev and st1.ino == st2.ino
|
1429
|
-
else
|
1430
|
-
File.expand_path(a) == File.expand_path(b)
|
1431
|
-
end
|
1432
|
-
rescue Errno::ENOENT
|
1433
|
-
return false
|
1538
|
+
File.identical?(a, b)
|
1434
1539
|
end
|
1435
1540
|
private_module_function :fu_same?
|
1436
1541
|
|
1437
|
-
def fu_have_st_ino? #:nodoc:
|
1438
|
-
not fu_windows?
|
1439
|
-
end
|
1440
|
-
private_module_function :fu_have_st_ino?
|
1441
|
-
|
1442
1542
|
def fu_check_options(options, optdecl) #:nodoc:
|
1443
1543
|
h = options.dup
|
1444
1544
|
optdecl.each do |opt|
|
@@ -1449,8 +1549,8 @@ module FileUtils
|
|
1449
1549
|
private_module_function :fu_check_options
|
1450
1550
|
|
1451
1551
|
def fu_update_option(args, new) #:nodoc:
|
1452
|
-
if args.last
|
1453
|
-
args[-1] =
|
1552
|
+
if tmp = Hash.try_convert(args.last)
|
1553
|
+
args[-1] = tmp.dup.update(new)
|
1454
1554
|
else
|
1455
1555
|
args.push new
|
1456
1556
|
end
|
@@ -1516,8 +1616,14 @@ module FileUtils
|
|
1516
1616
|
OPT_TABLE.keys.select {|m| OPT_TABLE[m].include?(opt) }
|
1517
1617
|
end
|
1518
1618
|
|
1519
|
-
|
1520
|
-
|
1619
|
+
LOW_METHODS = singleton_methods(false) - collect_method(:noop).map(&:intern)
|
1620
|
+
module LowMethods
|
1621
|
+
module_eval("private\n" + ::FileUtils::LOW_METHODS.map {|name| "def #{name}(*)end"}.join("\n"),
|
1622
|
+
__FILE__, __LINE__)
|
1623
|
+
end
|
1624
|
+
|
1625
|
+
METHODS = singleton_methods() - [:private_module_function,
|
1626
|
+
:commands, :options, :have_option?, :options_of, :collect_method]
|
1521
1627
|
|
1522
1628
|
#
|
1523
1629
|
# This module has all methods of FileUtils module, but it outputs messages
|
@@ -1551,6 +1657,7 @@ module FileUtils
|
|
1551
1657
|
#
|
1552
1658
|
module NoWrite
|
1553
1659
|
include FileUtils
|
1660
|
+
include LowMethods
|
1554
1661
|
@fileutils_output = $stderr
|
1555
1662
|
@fileutils_label = ''
|
1556
1663
|
::FileUtils.collect_method(:noop).each do |name|
|
@@ -1577,6 +1684,7 @@ module FileUtils
|
|
1577
1684
|
#
|
1578
1685
|
module DryRun
|
1579
1686
|
include FileUtils
|
1687
|
+
include LowMethods
|
1580
1688
|
@fileutils_output = $stderr
|
1581
1689
|
@fileutils_label = ''
|
1582
1690
|
::FileUtils.collect_method(:noop).each do |name|
|
data/rubysl-fileutils.gemspec
CHANGED
@@ -16,6 +16,8 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
17
17
|
spec.require_paths = ["lib"]
|
18
18
|
|
19
|
+
spec.add_runtime_dependency "redcard", "~> 1.0"
|
20
|
+
|
19
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
20
22
|
spec.add_development_dependency "rake", "~> 10.0"
|
21
23
|
end
|
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubysl-fileutils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Shirai
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-08-
|
11
|
+
date: 2013-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: redcard
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: bundler
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|