Sha256: 971591f88882e68f23eb184f91e14cb5944d9908f34facec3a76a579c294ff53

Contents?: true

Size: 713 Bytes

Versions: 1

Compression:

Stored size: 713 Bytes

Contents

require 'find'
require_relative 'nginxconfig'

module Ykxutils
  class Nginxconfigfiles
    def get_file_list(start_dir, re)
      @file_list = []

      Find.find(start_dir) { |x|
        if x =~ re
          # puts x
          @file_list << x
          Find.prune
        end
      }
      @file_list
    end

    def output(file_list)
      file_list.map { |fname|
        parent_dir_pn = Pathname.new(fname).cleanpath.parent
        vdomain = parent_dir_pn.basename
        output_fname = "#{vdomain}.conf"
        cli = ::Ykxutils::Nginxconfig.new(fname)
        scope = nil
        File.open(output_fname, "w") { |f|
          x = cli.extract(scope)
          f.write(x)
        }
      }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ykxutils-0.1.8 lib/ykxutils/nginxconfigfiles.rb