Class: SitemapGen::Fixer

Inherits:
Object
  • Object
show all
Defined in:
lib/sitemap_gen/fixer.rb

Instance Method Summary collapse

Constructor Details

#initialize(dir_path) ⇒ Fixer



3
4
5
6
# File 'lib/sitemap_gen/fixer.rb', line 3

def initialize(dir_path)
  @dir_path = dir_path
  @html_files = Dir.glob("#{dir_path}/**/*.html").select { |f| !f.include?('index.html') && !f.match(::SitemapGen::IGNORE_DIRS_REGEX) }
end

Instance Method Details

#executeObject



8
9
10
11
12
13
14
15
16
17
# File 'lib/sitemap_gen/fixer.rb', line 8

def execute
  @html_files.each do |f|
    p f
    new_path = "#{File.dirname(f)}/#{File.basename(f, '.*')}"
    new_html_file = "#{new_path}/index.html"
    FileUtils.mkdir_p(new_path)
    FileUtils.rm_rf(new_html_file)
    FileUtils.mv(f, new_html_file)
  end
end