lib/ganapati/client.rb in ganapati-0.0.4 vs lib/ganapati/client.rb in ganapati-0.0.5
- old
+ new
@@ -101,12 +101,14 @@
def stat(path)
@client.stat pname(path)
end
- def ls(path, details=false)
+ def ls(path, details=false, recursive=false)
statuses = @client.listStatus pname(path)
- (details) ? statuses : statuses.map { |s| s.path }
+ paths = (details) ? statuses : statuses.map { |s| s.path }
+ return paths if not recursive
+ paths + statuses.select { |s| s.isdir }.map { |s| ls(s.path, details, recursive) }.flatten
end
def chmod(path, mode)
@client.chmod pname(path), mode
end