Class: Kscript::KkVcsCleanerUtils
- Inherits:
-
Base
- Object
- Base
- Kscript::KkVcsCleanerUtils
show all
- Defined in:
- lib/kscript/plugins/kk_vcs_cleaner_utils.rb
Constant Summary
collapse
- DEFAULT_RETAIN_VERSIONS =
10
Instance Attribute Summary collapse
Attributes inherited from Base
#logger
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#human_output?, inherited, #with_error_handling
Constructor Details
Initialize the cleaner with path and retention settings
19
20
21
22
23
|
# File 'lib/kscript/plugins/kk_vcs_cleaner_utils.rb', line 19
def initialize(*args, **opts)
super
@source_path = args[0] || '/data/sources/*/**'
@retain_count = args[1] || DEFAULT_RETAIN_VERSIONS
end
|
Instance Attribute Details
#retain_count ⇒ Object
Returns the value of attribute retain_count.
14
15
16
|
# File 'lib/kscript/plugins/kk_vcs_cleaner_utils.rb', line 14
def retain_count
@retain_count
end
|
#source_path ⇒ Object
Returns the value of attribute source_path.
14
15
16
|
# File 'lib/kscript/plugins/kk_vcs_cleaner_utils.rb', line 14
def source_path
@source_path
end
|
Class Method Details
.arguments ⇒ Object
38
39
40
|
# File 'lib/kscript/plugins/kk_vcs_cleaner_utils.rb', line 38
def self.arguments
'[src_path]'
end
|
.author ⇒ Object
50
51
52
|
# File 'lib/kscript/plugins/kk_vcs_cleaner_utils.rb', line 50
def self.author
'kk'
end
|
.description ⇒ Object
54
55
56
|
# File 'lib/kscript/plugins/kk_vcs_cleaner_utils.rb', line 54
def self.description
'Clean old source code versions, keep N latest.'
end
|
.group ⇒ Object
46
47
48
|
# File 'lib/kscript/plugins/kk_vcs_cleaner_utils.rb', line 46
def self.group
'project'
end
|
.usage ⇒ Object
42
43
44
|
# File 'lib/kscript/plugins/kk_vcs_cleaner_utils.rb', line 42
def self.usage
"kscript vcs_cleaner ~/projects/src\nkscript vcs_cleaner . --exclude=vendor"
end
|
Instance Method Details
#clean ⇒ Object
Clean old versions while keeping the specified number of recent versions
32
33
34
35
36
|
# File 'lib/kscript/plugins/kk_vcs_cleaner_utils.rb', line 32
def clean
Dir.glob(@source_path).each do |app_path|
process_application(app_path)
end
end
|
#run ⇒ Object
25
26
27
28
29
|
# File 'lib/kscript/plugins/kk_vcs_cleaner_utils.rb', line 25
def run
with_error_handling do
clean
end
end
|