Class: HtmlMockup::Release::Cleaner
- Inherits:
-
Object
- Object
- HtmlMockup::Release::Cleaner
- Defined in:
- lib/html_mockup/release/cleaner.rb
Instance Method Summary collapse
- #call(release, options = {}) ⇒ Object
-
#initialize(pattern) ⇒ Cleaner
constructor
A new instance of Cleaner.
Constructor Details
#initialize(pattern) ⇒ Cleaner
Returns a new instance of Cleaner.
3 4 5 |
# File 'lib/html_mockup/release/cleaner.rb', line 3 def initialize(pattern) @pattern = pattern end |
Instance Method Details
#call(release, options = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/html_mockup/release/cleaner.rb', line 7 def call(release, = {}) # We switch to the build path and append the globbed files for safety, so even if you manage to sneak in a # pattern like "/**/*" it won't do you any good as it will be reappended to the path Dir.chdir(release.build_path.to_s) do Dir.glob(@pattern).each do |file| path = File.join(release.build_path.to_s, file) if is_inside_build_path(release.build_path, path) release.log(self, "Cleaning up \"#{path}\" in build") rm_rf(path) else release.log(self, "FAILED cleaning up \"#{path}\" in build") end end end end |