Class: Ykutils::Nginxconfigfiles

Inherits:
Object
  • Object
show all
Defined in:
lib/ykutils/nginxconfigfiles.rb

Instance Method Summary collapse

Instance Method Details

#get_file_list(start_dir, re) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/ykutils/nginxconfigfiles.rb', line 4

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

#output(file_list) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ykutils/nginxconfigfiles.rb', line 17

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 = Nginxconfig.new(fname)
    scope = nil
    File.open(output_fname, "w") { |f|
      x = cli.extract(scope)
      f.write(x)
    }
  }
end