Class: SpigitOps::Tomcat
- Inherits:
-
Object
- Object
- SpigitOps::Tomcat
- Defined in:
- lib/spigit_ops/tomcat.rb
Instance Method Summary collapse
- #count ⇒ Object
- #exist?(service) ⇒ Boolean
- #grab_service(name) ⇒ Object
-
#initialize(serverxml_filename = SpigitOps::TC_SERVER_XML, options = {}) ⇒ Tomcat
constructor
A new instance of Tomcat.
- #save!(output_filename = SpigitOps::TC_SERVICES_FILE, options = {}) ⇒ Object
- #save_old!(output_filename = SpigitOps::TC_SERVICES_FILE) ⇒ Object
- #serverxml_filename ⇒ Object
- #services ⇒ Object
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, = {}) @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
#count ⇒ Object
22 23 24 |
# File 'lib/spigit_ops/tomcat.rb', line 22 def count puts @tomcat_services.length end |
#exist?(service) ⇒ 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, = {}) format = [: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_filename ⇒ Object
34 35 36 |
# File 'lib/spigit_ops/tomcat.rb', line 34 def serverxml_filename puts @serverxml_filename end |
#services ⇒ Object
18 19 20 |
# File 'lib/spigit_ops/tomcat.rb', line 18 def services puts @tomcat_services end |