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



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

def create_file=( file_to_create )
	@file_to_create = file_to_create
   #puts @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,linux")
	@file_h.puts("}")	
end

#examine_file=(filetocheck) ⇒ Object



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

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

#get_filesObject



29
30
31
32
33
34
35
36
# File 'lib/one_conf_compare.rb', line 29

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

#get_fullpathObject



56
57
58
# File 'lib/one_conf_compare.rb', line 56

def get_fullpath
	@fullpath
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