Class: Warbler::Config

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(warbler_home = WARBLER_HOME) {|_self| ... } ⇒ Config

Returns a new instance of Config.

Yields:

  • (_self)

Yield Parameters:



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/warbler/config.rb', line 115

def initialize(warbler_home = WARBLER_HOME)
  @warbler_home = warbler_home
  @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
  @exclude_logs = true
  @public_html = FileList["public/**/*"]
  @pathmaps    = default_pathmaps
  @webxml      = default_webxml_config
  @rails_root  = File.expand_path(defined?(RAILS_ROOT) ? RAILS_ROOT : Dir.getwd)
  @war_name    = File.basename(@rails_root)
  @bundler     = true
  @webinf_files = default_webinf_files
  @compiled_ruby_files = FileList[]
  auto_detect_frameworks
  yield self if block_given?
  update_gem_path
  detect_bundler_gems
  @excludes += warbler_vendor_excludes(warbler_home)
  @excludes += FileList["**/*.log"] if @exclude_logs
end

Instance Attribute Details

#autodeploy_dirObject

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 Rails directory.



30
31
32
# File 'lib/warbler/config.rb', line 30

def autodeploy_dir
  @autodeploy_dir
end

#bundlerObject

Use Bundler to locate gems if Gemfile is found. Default is true.



78
79
80
# File 'lib/warbler/config.rb', line 78

def bundler
  @bundler
end

#compiled_ruby_filesObject

FileList of ruby files to compile to class files



85
86
87
# File 'lib/warbler/config.rb', line 85

def compiled_ruby_files
  @compiled_ruby_files
end

#dirsObject

Top-level directories to be copied into WEB-INF. Defaults to names in TOP_DIRS



34
35
36
# File 'lib/warbler/config.rb', line 34

def dirs
  @dirs
end

#exclude_logsObject

Whether to exclude */.log files (default is true)



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

def exclude_logs
  @exclude_logs
end

#excludesObject

Files to exclude from the WEB-INF directory



41
42
43
# File 'lib/warbler/config.rb', line 41

def excludes
  @excludes
end

#featuresObject

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



22
23
24
# File 'lib/warbler/config.rb', line 22

def features
  @features
end

#gem_dependenciesObject

Whether to include dependent gems (default true)



53
54
55
# File 'lib/warbler/config.rb', line 53

def gem_dependencies
  @gem_dependencies
end

#gem_pathObject

Path to the pre-bundled gem directory inside the war file. Default is ‘/WEB-INF/gems’. This also sets ‘gem.path’ inside web.xml.



82
83
84
# File 'lib/warbler/config.rb', line 82

def gem_path
  @gem_path
end

#gemsObject

Rubygems to install into the webapp.



50
51
52
# File 'lib/warbler/config.rb', line 50

def gems
  @gems
end

#includesObject

Additional files beyond the top-level directories to include in the WEB-INF directory



38
39
40
# File 'lib/warbler/config.rb', line 38

def includes
  @includes
end

#java_classesObject

Java classes and other files to copy to WEB-INF/classes



44
45
46
# File 'lib/warbler/config.rb', line 44

def java_classes
  @java_classes
end

#java_libsObject

Java libraries to copy to WEB-INF/lib



47
48
49
# File 'lib/warbler/config.rb', line 47

def java_libs
  @java_libs
end

#manifest_fileObject

Name of a MANIFEST.MF template to use.



71
72
73
# File 'lib/warbler/config.rb', line 71

def manifest_file
  @manifest_file
end

#pathmapsObject

Container of pathmaps used for specifying source-to-destination transformations under various situations (public_html and java_classes are two entries in this structure).



64
65
66
# File 'lib/warbler/config.rb', line 64

def pathmaps
  @pathmaps
end

#public_htmlObject

Public HTML directory file list, to be copied into the root of the war



59
60
61
# File 'lib/warbler/config.rb', line 59

def public_html
  @public_html
end

#staging_dirObject

Deprecated: No longer has any effect.



25
26
27
# File 'lib/warbler/config.rb', line 25

def staging_dir
  @staging_dir
end

#war_nameObject

Name of war file (without the .war), defaults to the directory name containing the Rails application



68
69
70
# File 'lib/warbler/config.rb', line 68

def war_name
  @war_name
end

#webinf_filesObject

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.



75
76
77
# File 'lib/warbler/config.rb', line 75

def webinf_files
  @webinf_files
end

#webxmlObject

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' %>


113
114
115
# File 'lib/warbler/config.rb', line 113

def webxml
  @webxml
end

Instance Method Details

#relative_gem_pathObject



147
148
149
# File 'lib/warbler/config.rb', line 147

def relative_gem_path
  @gem_path[1..-1]
end