Class: SpigitOps::Tomcat

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

Instance Method Summary collapse

Constructor Details

#initialize(serverxml_filename = SpigitOps::TC_SERVER_XML, options = {}) ⇒ Tomcat

Returns a new instance of Tomcat.



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/spigit_ops/tomcat.rb', line 5

def initialize(serverxml_filename = SpigitOps::TC_SERVER_XML, options= {})
   @serverxml_filename = serverxml_filename

   if ! FileTest.exist? @serverxml_filename
		raise "#{@serverxml_filename} doesn't exist."
elsif ! FileTest.readable? @serverxml_filename
     raise "#{@serverxml_filename} isn't readable."
	end

	@serverxml_xml = Nokogiri::XML(File.open(@serverxml_filename))
   build_tomcat_services
end

Instance Method Details

#countObject



22
23
24
# File 'lib/spigit_ops/tomcat.rb', line 22

def count
  puts @tomcat_services.length
end

#exist?(service) ⇒ Boolean

Returns:

  • (Boolean)


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

def exist?(service)

end

#grab_service(name) ⇒ Object



30
31
32
# File 'lib/spigit_ops/tomcat.rb', line 30

def grab_service(name)
  puts @tomcat_services[name]
end

#save!(output_filename = SpigitOps::TC_SERVICES_FILE, options = {}) ⇒ Object



38
39
40
41
42
43
44
45
46
# File 'lib/spigit_ops/tomcat.rb', line 38

def save!(output_filename = SpigitOps::TC_SERVICES_FILE, options = {})
  format = options[:format]

  if format == 'old'
    File.open(output_filename, 'w') { |f| @old_tomcat_services.each { |x| f.puts x } }
  else
    File.open(output_filename, 'w') { |f| @tomcat_services.each { |key, value| f.puts value } }
  end
end

#save_old!(output_filename = SpigitOps::TC_SERVICES_FILE) ⇒ Object



48
49
50
# File 'lib/spigit_ops/tomcat.rb', line 48

def save_old!(output_filename = SpigitOps::TC_SERVICES_FILE)
  self.save!(output_filename, format: 'old')
end

#serverxml_filenameObject



34
35
36
# File 'lib/spigit_ops/tomcat.rb', line 34

def serverxml_filename
  puts @serverxml_filename
end

#servicesObject



18
19
20
# File 'lib/spigit_ops/tomcat.rb', line 18

def services
	puts @tomcat_services
end