class DeployDir
This class extends Dir to add Deploy ad hoc feature for dealing with deploy folders
Could be simply extend Dir class with extra functions but this class meant to be a Deploy System Directory class handler
- Author
-
Jose A Pio (josetonyp@gmail.com)
- Copyright
-
Copyright © 2011
- License
-
Distributes under the same terms as Ruby
Public Class Methods
rotate_folders(folder , limit)
click to toggle source
Rotate old folders and reduce it number by the limit
Params:¶ ↑
folder
-
String A valid folder for deploys
limit
-
Integer Limit the folders left in deploy folder
# File lib/deploy_dir.rb, line 14 def self.rotate_folders(folder , limit) raise(ArgumentError, "Invalid directory #{folder}") unless exists?(folder) glob(folder.join("*")).select {|file| file =~ /\d+?/ }.tap do |list| FileUtils.rm_rf(list.reverse.slice(limit.to_i, list.length)) if list.length > limit.to_i end end