Class: Warbler::Config
- Inherits:
-
Object
- Object
- Warbler::Config
- Defined in:
- lib/warbler/config.rb
Overview
Warbler war file assembly configuration class.
Constant Summary collapse
- TOP_DIRS =
%w(app config lib log vendor)
- FILE =
"config/warble.rb"
- DEFAULT_GEM_PATH =
'/WEB-INF/gems'
- BUILD_GEMS =
%w(warbler rake rcov)
Instance Attribute Summary collapse
-
#autodeploy_dir ⇒ Object
Directory where the war file will be written.
-
#bundle_without ⇒ Object
An array of Bundler groups to avoid including in the war file.
-
#bundler ⇒ Object
Use Bundler to locate gems if Gemfile is found.
-
#compiled_ruby_files ⇒ Object
List of ruby files to compile to class files.
-
#dirs ⇒ Object
Top-level directories to be copied into WEB-INF.
-
#exclude_logs ⇒ Object
Whether to exclude */.log files (default is true).
-
#excludes ⇒ Object
Files to exclude from the WEB-INF directory.
-
#features ⇒ Object
Features: additional options controlling how the jar is built.
-
#gem_dependencies ⇒ Object
Whether to include dependent gems (default true).
-
#gem_excludes ⇒ Object
Array of regular expressions matching relative paths in gems to be excluded from the war.
-
#gem_path ⇒ Object
Path to the pre-bundled gem directory inside the war file.
-
#gems ⇒ Object
Rubygems to install into the webapp.
-
#includes ⇒ Object
Additional files beyond the top-level directories to include in the WEB-INF directory.
-
#init_contents ⇒ Object
Array containing filenames or StringIO’s to be concatenated together to form the init file.
-
#init_filename ⇒ Object
Warbler writes an “init” file into the war at this location.
-
#java_classes ⇒ Object
Java classes and other files to copy to WEB-INF/classes.
-
#java_libs ⇒ Object
Java libraries to copy to WEB-INF/lib.
-
#manifest_file ⇒ Object
Name of a MANIFEST.MF template to use.
-
#pathmaps ⇒ Object
Container of pathmaps used for specifying source-to-destination transformations under various situations (
public_html
andjava_classes
are two entries in this structure). -
#public_html ⇒ Object
Public HTML directory file list, to be copied into the root of the war.
-
#staging_dir ⇒ Object
Deprecated: No longer has any effect.
-
#war_name ⇒ Object
Name of war file (without the .war), defaults to the directory name containing the Rails application.
-
#webinf_files ⇒ Object
Files for WEB-INF directory (next to web.xml).
-
#webxml ⇒ Object
Extra configuration for web.xml.
Instance Method Summary collapse
-
#initialize(warbler_home = WARBLER_HOME) {|_self| ... } ⇒ Config
constructor
A new instance of Config.
- #relative_gem_path ⇒ Object
Constructor Details
#initialize(warbler_home = WARBLER_HOME) {|_self| ... } ⇒ Config
Returns a new instance of Config.
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 |
# File 'lib/warbler/config.rb', line 133 def initialize(warbler_home = WARBLER_HOME) @warbler_home = warbler_home @warbler_templates = "#{WARBLER_HOME}/lib/warbler/templates" @features = [] @dirs = TOP_DIRS.select {|d| File.directory?(d)} @includes = FileList[] @excludes = FileList[] @java_libs = default_jar_files @java_classes = FileList[] @gems = Warbler::Gems.new @gem_path = DEFAULT_GEM_PATH @gem_dependencies = true @gem_excludes = [] @exclude_logs = true @public_html = FileList["public/**/*"] @pathmaps = default_pathmaps @webxml = default_webxml_config @rails_root = default_rails_root @war_name = File.basename(@rails_root) @bundler = true @bundle_without = ["development", "test"] @webinf_files = default_webinf_files @init_filename = 'META-INF/init.rb' @init_contents = ["#{@warbler_templates}/config.erb"] auto_detect_frameworks yield self if block_given? update_gem_path detect_bundler_gems framework_init = "#{@warbler_templates}/#{@webxml.booter}.erb" @init_contents << framework_init if File.exist?(framework_init) @compiled_ruby_files ||= FileList[*@dirs.map {|d| "#{d}/**/*.rb"}] @excludes += ["tmp/war"] if File.directory?("tmp/war") @excludes += warbler_vendor_excludes(warbler_home) @excludes += FileList["**/*.log"] if @exclude_logs end |
Instance Attribute Details
#autodeploy_dir ⇒ Object
Directory where the war file will be written. Can be used to direct Warbler to place your war file directly in your application server’s autodeploy directory. Defaults to the root of the application directory.
31 32 33 |
# File 'lib/warbler/config.rb', line 31 def autodeploy_dir @autodeploy_dir end |
#bundle_without ⇒ Object
An array of Bundler groups to avoid including in the war file. Defaults to [“development”, “test”].
87 88 89 |
# File 'lib/warbler/config.rb', line 87 def bundle_without @bundle_without end |
#bundler ⇒ Object
Use Bundler to locate gems if Gemfile is found. Default is true.
83 84 85 |
# File 'lib/warbler/config.rb', line 83 def bundler @bundler end |
#compiled_ruby_files ⇒ Object
List of ruby files to compile to class files. Default is to compile all .rb files in the application.
95 96 97 |
# File 'lib/warbler/config.rb', line 95 def compiled_ruby_files @compiled_ruby_files end |
#dirs ⇒ Object
Top-level directories to be copied into WEB-INF. Defaults to names in TOP_DIRS
35 36 37 |
# File 'lib/warbler/config.rb', line 35 def dirs @dirs end |
#exclude_logs ⇒ Object
Whether to exclude */.log files (default is true)
61 62 63 |
# File 'lib/warbler/config.rb', line 61 def exclude_logs @exclude_logs end |
#excludes ⇒ Object
Files to exclude from the WEB-INF directory
42 43 44 |
# File 'lib/warbler/config.rb', line 42 def excludes @excludes end |
#features ⇒ Object
Features: additional options controlling how the jar is built. Currently the following features are supported:
-
gemjar: package the gem repository in a jar file in WEB-INF/lib
-
executable: embed a web server and make the war executable
-
compiled: compile .rb files to .class files
23 24 25 |
# File 'lib/warbler/config.rb', line 23 def features @features end |
#gem_dependencies ⇒ Object
Whether to include dependent gems (default true)
54 55 56 |
# File 'lib/warbler/config.rb', line 54 def gem_dependencies @gem_dependencies end |
#gem_excludes ⇒ Object
Array of regular expressions matching relative paths in gems to be excluded from the war. Default contains no exclusions.
58 59 60 |
# File 'lib/warbler/config.rb', line 58 def gem_excludes @gem_excludes end |
#gem_path ⇒ Object
Path to the pre-bundled gem directory inside the war file. Default is ‘/WEB-INF/gems’. This also sets ‘gem.path’ inside web.xml.
91 92 93 |
# File 'lib/warbler/config.rb', line 91 def gem_path @gem_path end |
#gems ⇒ Object
Rubygems to install into the webapp.
51 52 53 |
# File 'lib/warbler/config.rb', line 51 def gems @gems end |
#includes ⇒ Object
Additional files beyond the top-level directories to include in the WEB-INF directory
39 40 41 |
# File 'lib/warbler/config.rb', line 39 def includes @includes end |
#init_contents ⇒ Object
Array containing filenames or StringIO’s to be concatenated together to form the init file. If the filename ends in .erb the file will be expanded the same way web.xml.erb is; see below.
103 104 105 |
# File 'lib/warbler/config.rb', line 103 def init_contents @init_contents end |
#init_filename ⇒ Object
Warbler writes an “init” file into the war at this location. JRuby-Rack and possibly other launchers may use this to initialize the Ruby environment.
99 100 101 |
# File 'lib/warbler/config.rb', line 99 def init_filename @init_filename end |
#java_classes ⇒ Object
Java classes and other files to copy to WEB-INF/classes
45 46 47 |
# File 'lib/warbler/config.rb', line 45 def java_classes @java_classes end |
#java_libs ⇒ Object
Java libraries to copy to WEB-INF/lib
48 49 50 |
# File 'lib/warbler/config.rb', line 48 def java_libs @java_libs end |
#manifest_file ⇒ Object
Name of a MANIFEST.MF template to use.
76 77 78 |
# File 'lib/warbler/config.rb', line 76 def manifest_file @manifest_file end |
#pathmaps ⇒ Object
Container of pathmaps used for specifying source-to-destination transformations under various situations (public_html
and java_classes
are two entries in this structure).
69 70 71 |
# File 'lib/warbler/config.rb', line 69 def pathmaps @pathmaps end |
#public_html ⇒ Object
Public HTML directory file list, to be copied into the root of the war
64 65 66 |
# File 'lib/warbler/config.rb', line 64 def public_html @public_html end |
#staging_dir ⇒ Object
Deprecated: No longer has any effect.
26 27 28 |
# File 'lib/warbler/config.rb', line 26 def staging_dir @staging_dir end |
#war_name ⇒ Object
Name of war file (without the .war), defaults to the directory name containing the Rails application
73 74 75 |
# File 'lib/warbler/config.rb', line 73 def war_name @war_name end |
#webinf_files ⇒ Object
Files for WEB-INF directory (next to web.xml). Contains web.xml by default. If there are .erb files they will be processed with webxml config.
80 81 82 |
# File 'lib/warbler/config.rb', line 80 def webinf_files @webinf_files end |
#webxml ⇒ Object
Extra configuration for web.xml. Controls how the dynamically-generated web.xml file is generated.
-
webxml.jndi
– the name of one or more JNDI data sources name to be available to the application. Places appropriate <resource-ref> entries in the file. -
webxml.ignored
– array of key names that will be not used to generate a context param. Defaults to [‘jndi’, ‘booter’]
Any other key/value pair placed in the open structure will be dumped as a context parameter in the web.xml file. Some of the recognized values are:
-
webxml.rails.env
– the Rails environment to use for the running application, usually either development or production (the default). -
webxml.gem.path
– the path to your bundled gem directory -
webxml.jruby.min.runtimes
– minimum number of pooled runtimes to keep around during idle time -
webxml.jruby.max.runtimes
– maximum number of pooled Rails application runtimes
Note that if you attempt to access webxml configuration keys in a conditional, you might not obtain the result you want. For example:
<%= webxml.maybe.present.key || 'default' %>
doesn’t yield the right result. Instead, you need to generate the context parameters:
<%= webxml.context_params['maybe.present.key'] || 'default' %>
131 132 133 |
# File 'lib/warbler/config.rb', line 131 def webxml @webxml end |
Instance Method Details
#relative_gem_path ⇒ Object
175 176 177 |
# File 'lib/warbler/config.rb', line 175 def relative_gem_path @gem_path[1..-1] end |