Class: DirectoryScan

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

Instance Method Summary collapse

Instance Method Details

#create_file=(file_to_create) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/one_conf_compare.rb', line 58

def create_file=( file_to_create )
	@file_to_create = file_to_create
	File.new(@file_to_create, "w")
	@file_h = File.open(@file_to_create,"w")
	@file_h.puts("define host{")
	@file_h.puts("		use linux-server")
	@file_h.puts("		host_name " + @filetocheck)
	@file_h.puts("		alias	  " + @filetocheck)
	@file_h.puts("		hostgroups appnode")
	@file_h.puts("}")	
end

#examine_fileObject



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/one_conf_compare.rb', line 40

def examine_file
	@filetocheck = @file
	if @filetocheck.match /[a-z0-9]+-[0-9]+-[prod|stg|test]+-[nydc1|ladc1|chidc1|test|nyc].[nydc1|ladc1|chidc1|test|nyc]/
		@dc =  @filetocheck.split('.')
		@app = @filetocheck.split('-')
		if @app[2] == "test"
		  @dc[1] = "nydc1"
		end
    		        if @dc[1] == "nyc"
       	 	  return nil
                       end
		@directory = @dir + @dc[1] + "/" + @app[0]
		if ! File.directory? @directory
			Dir.mkdir(@directory)
		end
	  	@fullpath = @directory + "/" + @filetocheck + ".cfg"
	end
end

#get_filesObject



32
33
34
35
36
37
38
39
# File 'lib/one_conf_compare.rb', line 32

def get_files
	config_files = []
	Dir.glob(@dir + "/**/*.cfg") do |e|
        	file = e.gsub(/\.cfg/,"")
		config_files << File.basename(file)
	end
	config_files	
end

#setdirObject



23
24
25
# File 'lib/one_conf_compare.rb', line 23

def setdir
	@dir
end

#setdir=(dir) ⇒ Object



26
27
28
# File 'lib/one_conf_compare.rb', line 26

def setdir=( dir )
	@dir = dir
end

#setfile=(file) ⇒ Object



29
30
31
# File 'lib/one_conf_compare.rb', line 29

def setfile=( file )
	@file = file
end