Class: Sparrowhawk::WebXmlEntry

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ WebXmlEntry

Returns a new instance of WebXmlEntry.



8
9
10
11
12
# File 'lib/sparrowhawk/web_xml_entry.rb', line 8

def initialize options={}
  @name = 'WEB-INF/web.xml'
  @runtimes = options[:runtimes] || (1..1)
  @environment = options[:environment] || 'development'
end

Instance Attribute Details

#environmentObject (readonly)

Returns the value of attribute environment.



6
7
8
# File 'lib/sparrowhawk/web_xml_entry.rb', line 6

def environment
  @environment
end

#nameObject (readonly)

Returns the value of attribute name.



6
7
8
# File 'lib/sparrowhawk/web_xml_entry.rb', line 6

def name
  @name
end

Instance Method Details

#contentObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sparrowhawk/web_xml_entry.rb', line 14

def content
  xml = Builder::XmlMarkup.new
  xml.instruct!
  xml.declare!(:DOCTYPE, 'web-app'.to_sym, :PUBLIC,
               "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN",
               "http://java.sun.com/dtd/web-app_2_3.dtd")
  xml.tag! 'web-app' do |xml|
    xml << context_param('rails.env', environment)
    xml << context_param('public.root', '/')
    xml << context_param('jruby.min.runtimes', min_runtimes)
    xml << context_param('jruby.max.runtimes', max_runtimes)
    xml << filter(:name  => 'RackFilter',
                  :class => 'org.jruby.rack.RackFilter',
                  :url   => '/*')
    xml << listener('org.jruby.rack.rails.RailsServletContextListener')
  end
  xml.target!
end

#max_runtimesObject



33
34
35
# File 'lib/sparrowhawk/web_xml_entry.rb', line 33

def max_runtimes
  @runtimes.end.to_s
end

#min_runtimesObject



37
38
39
# File 'lib/sparrowhawk/web_xml_entry.rb', line 37

def min_runtimes
  @runtimes.begin.to_s
end