warbler 0.9.11 → 0.9.12

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,21 @@
1
+ == 0.9.12
2
+
3
+ * Allow framework auto-detection to be disabled. Set
4
+ `Warbler.framework_detection = false` at the top of config/warble.rb
5
+ or uncomment the line from a newly generated config.
6
+ * Add configuration option to set manifest file (thanks Tommy McGuire)
7
+ * Mitigate RubyGems 1.3 compatibility issue (thanks Jens Norrgrann)
8
+ * Add experimental `war:exploded` task. This allows you to deploy your
9
+ application in an exploded mode, thus allowing continual development
10
+ without re-warring and re-deploying. Feedback is appreciated if you
11
+ try this feature; it may not work in all application servers and for
12
+ applications other than Rails.
13
+ * Handle Rails gem dependencies better (thanks Laszlo Bacsi)
14
+ * Auto-detect Merb dependencies (Merb >= 1.0 only). Please give
15
+ feedback if you try Warbler with a Merb 1.0 app.
16
+ * Ignore gem development dependencies
17
+ * Upgrade to JRuby 1.1.6 and JRuby-Rack 0.9.3
18
+
1
19
  == 0.9.11
2
20
 
3
21
  * Auto-detect Rails and Merb and configure appropriately
@@ -74,4 +92,4 @@
74
92
  minimal, flexible, ruby-like way to bundle up all of your application files for deployment to a
75
93
  Java application server.
76
94
  * Bundled versions: goldspike-1.4-SNAPSHOT and jruby-complete-1.0.1
77
- * Works as both a gem (rake application) or a plugin
95
+ * Works as both a gem (rake application) or a plugin
data/Manifest.txt CHANGED
@@ -9,14 +9,25 @@ generators/warble
9
9
  generators/warble/templates
10
10
  generators/warble/templates/warble.rb
11
11
  generators/warble/warble_generator.rb
12
- lib/jruby-complete-1.1.4.jar
13
- lib/jruby-rack-0.9.2.jar
12
+ lib/jruby-complete-1.1.6.jar
13
+ lib/jruby-rack-0.9.3.jar
14
14
  lib/warbler
15
15
  lib/warbler/config.rb
16
16
  lib/warbler/gems.rb
17
17
  lib/warbler/task.rb
18
18
  lib/warbler/version.rb
19
19
  lib/warbler.rb
20
+ spec/sample/app/controllers/application.rb
21
+ spec/sample/app/helpers/application_helper.rb
22
+ spec/sample/config/boot.rb
23
+ spec/sample/config/environment.rb
24
+ spec/sample/config/environments/development.rb
25
+ spec/sample/config/environments/production.rb
26
+ spec/sample/config/environments/test.rb
27
+ spec/sample/config/initializers/inflections.rb
28
+ spec/sample/config/initializers/mime_types.rb
29
+ spec/sample/config/initializers/new_rails_defaults.rb
30
+ spec/sample/config/routes.rb
20
31
  spec/spec_helper.rb
21
32
  spec/warbler/config_spec.rb
22
33
  spec/warbler/gems_spec.rb
data/README.txt CHANGED
@@ -56,7 +56,7 @@ The following items are set up for you:
56
56
 
57
57
  === Merb applications
58
58
 
59
- Merb applications are detected automatically, and the merb gem and its
59
+ Merb applications are detected automatically, and the merb-core gem and its
60
60
  dependencies are packaged.
61
61
 
62
62
  === Other Rack-based applications
@@ -69,8 +69,12 @@ config/warble.rb.
69
69
  See http://github.com/nicksieger/jruby-rack/tree/master/examples for examples
70
70
  of how to configure Warbler to package Camping and Sinatra apps.
71
71
 
72
- === Configuration auto-detect TODOs
72
+ === Configuration auto-detect notes
73
73
 
74
+ * If you don't have database access in the environment where you package your
75
+ application, you may wish to set `Warbler.framework_detection` to false at
76
+ the top of config.rb. In this case you may need to specify additional
77
+ details such as booter, gems and other settings.
74
78
  * A more accurate way of detecting a Merb application's gems is needed. Until
75
79
  then, you will have to specify them in config/warble.rb. See below.
76
80
  * Is it possible to more generally detect what gems an application uses?
@@ -1,3 +1,6 @@
1
+ # Disable automatic framework detection by uncommenting/setting to false
2
+ # Warbler.framework_detection = false
3
+
1
4
  # Warbler web application assembly configuration file
2
5
  Warbler::Config.new do |config|
3
6
  # Temporary directory where the application is staged
@@ -59,6 +62,10 @@ Warbler::Config.new do |config|
59
62
  # of RAILS_ROOT
60
63
  # config.war_name = "mywar"
61
64
 
65
+ # Name of the MANIFEST.MF template for the war file. Defaults to the
66
+ # MANIFEST.MF normally generated by `jar cf`.
67
+ # config.manifest_file = "config/MANIFEST.MF"
68
+
62
69
  # Value of RAILS_ENV for the webapp -- default as shown below
63
70
  # config.webxml.rails.env = ENV['RAILS_ENV'] || 'production'
64
71
 
@@ -79,4 +86,4 @@ Warbler::Config.new do |config|
79
86
 
80
87
  # JNDI data source name
81
88
  # config.webxml.jndi = 'jdbc/rails'
82
- end
89
+ end
Binary file
@@ -59,6 +59,10 @@ module Warbler
59
59
  # the Rails application
60
60
  attr_accessor :war_name
61
61
 
62
+ # Name of the MANIFEST.MF template. Defaults to the MANIFEST.MF normally generated
63
+ # by jar -cf....
64
+ attr_accessor :manifest_file
65
+
62
66
  # Extra configuration for web.xml. Controls how the dynamically-generated web.xml
63
67
  # file is generated.
64
68
  #
@@ -143,12 +147,12 @@ module Warbler
143
147
  end
144
148
 
145
149
  def auto_detect_frameworks
146
- auto_detect_rails || auto_detect_merb || auto_detect_rackup
150
+ !Warbler.framework_detection || auto_detect_rails || auto_detect_merb || auto_detect_rackup
147
151
  end
148
152
 
149
153
  def auto_detect_rails
150
154
  return false unless task = Warbler.project_application.lookup("environment")
151
- task.invoke
155
+ task.invoke rescue nil
152
156
  return false unless defined?(::Rails)
153
157
  @dirs << "tmp" if File.directory?("tmp")
154
158
  @webxml.booter = :rails
@@ -156,7 +160,7 @@ module Warbler
156
160
  @gems["rails"] = Rails::VERSION::STRING
157
161
  end
158
162
  if defined?(Rails.configuration.gems)
159
- Rails.configuration.gems.each {|g| @gems[g.name] = g.version }
163
+ Rails.configuration.gems.each {|g| @gems << Gem::Dependency.new(g.name, g.requirement) }
160
164
  end
161
165
  @webxml.jruby.max.runtimes = 1 if defined?(Rails.configuration.threadsafe!)
162
166
  true
@@ -164,10 +168,14 @@ module Warbler
164
168
 
165
169
  def auto_detect_merb
166
170
  return false unless task = Warbler.project_application.lookup("merb_env")
167
- task.invoke
171
+ task.invoke rescue nil
168
172
  return false unless defined?(::Merb)
169
173
  @webxml.booter = :merb
170
- @gems["merb"] = Merb::VERSION
174
+ if defined?(Merb::BootLoader::Dependencies.dependencies)
175
+ Merb::BootLoader::Dependencies.dependencies.each {|g| @gems << g }
176
+ else
177
+ warn "unable to auto-detect Merb dependencies; upgrade to Merb 1.0 or greater"
178
+ end
171
179
  true
172
180
  end
173
181
 
@@ -229,4 +237,4 @@ module Warbler
229
237
  "No value for '#@key' found"
230
238
  end
231
239
  end
232
- end
240
+ end
data/lib/warbler/gems.rb CHANGED
@@ -25,10 +25,12 @@ module Warbler
25
25
 
26
26
  def +(other)
27
27
  other.each {|g| self[g] ||= ANY_VERSION }
28
+ self
28
29
  end
29
30
 
30
31
  def -(other)
31
32
  other.each {|g| self.delete(g)}
33
+ self
32
34
  end
33
35
  end
34
- end
36
+ end
data/lib/warbler/task.rb CHANGED
@@ -13,9 +13,12 @@ module Warbler
13
13
  def project_application
14
14
  @project_application || Rake.application
15
15
  end
16
+
17
+ attr_accessor :framework_detection
16
18
  end
19
+ self.framework_detection = true
17
20
 
18
- # Warbler Rake task. Allows defining multiple configurations inside the same
21
+ # Warbler Rake task. Allows defining multiple configurations inside the same
19
22
  # Rakefile by using different task names.
20
23
  class Task < Rake::TaskLib
21
24
  COPY_PROC = proc {|t| cp t.prerequisites.last, t.name }
@@ -54,6 +57,7 @@ module Warbler
54
57
  define_webxml_task
55
58
  define_app_task
56
59
  define_jar_task
60
+ define_exploded_task
57
61
  define_debug_task
58
62
  end
59
63
 
@@ -87,7 +91,7 @@ module Warbler
87
91
 
88
92
  def define_gems_task
89
93
  directory "#{config.staging_dir}/#{apply_pathmaps("sources-0.0.1.gem", :gems).pathmap("%d")}"
90
- targets = define_copy_gems_tasks
94
+ targets = define_copy_gems_task
91
95
  with_namespace_and_config do
92
96
  desc "Unpack all gems into WEB-INF/gems"
93
97
  task "gems" => targets
@@ -113,7 +117,7 @@ module Warbler
113
117
  end
114
118
  require 'erb'
115
119
  erb = ERB.new(File.open(erb) {|f| f.read })
116
- File.open("#{config.staging_dir}/WEB-INF/web.xml", "w") do |f|
120
+ File.open("#{config.staging_dir}/WEB-INF/web.xml", "w") do |f|
117
121
  f << erb.result(erb_binding(config.webxml))
118
122
  end
119
123
  end
@@ -171,7 +175,34 @@ module Warbler
171
175
  task "jar" do
172
176
  war_path = "#{config.war_name}.war"
173
177
  war_path = File.join(config.autodeploy_dir, war_path) if config.autodeploy_dir
174
- sh "jar cf #{war_path} -C #{config.staging_dir} ."
178
+ flags, manifest = config.manifest_file ? ["cfm", config.manifest_file] : ["cf", ""]
179
+ sh "jar #{flags} #{war_path} #{manifest} -C #{config.staging_dir} ."
180
+ end
181
+ end
182
+ end
183
+
184
+ def define_exploded_task
185
+ with_namespace_and_config do |name,config|
186
+ libs = define_java_libs_task
187
+ desc "Create an exploded war in the app's public directory"
188
+ task "exploded" => ["webxml", "java_classes", "gems", *libs] do
189
+ cp "#{@config.staging_dir}/WEB-INF/web.xml", "."
190
+ cp File.join(WARBLER_HOME, "sun-web.xml"), "." unless File.exists?("sun-web.xml")
191
+ ln_sf "#{@config.staging_dir}/WEB-INF/gems", "."
192
+ if File.directory?("#{@config.staging_dir}/WEB-INF/classes")
193
+ ln_sf "#{@config.staging_dir}/WEB-INF/classes", "."
194
+ end
195
+ mkdir_p "lib"
196
+ libs.each {|l| ln_sf l, "lib/#{File.basename(l)}"}
197
+ ln_sf "..", "public/WEB-INF"
198
+ end
199
+
200
+ task "clean:exploded" do
201
+ (libs.map {|l| "lib/#{File.basename(l)}" } +
202
+ ["gems", "public/WEB-INF", "classes"]).each do |l|
203
+ rm_f l if File.exist?(l) && File.symlink?(l)
204
+ end
205
+ rm_f "*web.xml"
175
206
  end
176
207
  end
177
208
  end
@@ -238,7 +269,7 @@ module Warbler
238
269
  end
239
270
  end
240
271
 
241
- def define_copy_gems_tasks
272
+ def define_copy_gems_task
242
273
  targets = []
243
274
  @config.gems.each do |gem, version|
244
275
  define_single_gem_tasks(gem, targets, version)
@@ -251,12 +282,16 @@ module Warbler
251
282
  when Gem::Dependency
252
283
  gem_pattern
253
284
  else
254
- Gem::Dependency.new(gem_pattern, version)
285
+ Gem::Dependency.new(gem_pattern, Gem::Requirement.create(version))
255
286
  end
287
+
288
+ # skip development dependencies
289
+ return if gem.respond_to?(:type) and gem.type != :runtime
290
+
256
291
  matched = Gem.source_index.search(gem)
257
292
  fail "gem '#{gem}' not installed" if matched.empty?
258
293
  spec = matched.last
259
-
294
+
260
295
  gem_name = "#{spec.name}-#{spec.version}"
261
296
  unless spec.platform.nil? || spec.platform == Gem::Platform::RUBY
262
297
  [spec.platform, spec.original_platform].each do |p|
@@ -288,7 +323,7 @@ module Warbler
288
323
 
289
324
  if @config.gem_dependencies
290
325
  spec.dependencies.each do |dep|
291
- define_single_gem_tasks(dep.name, targets, dep.version_requirements)
326
+ define_single_gem_tasks(dep, targets)
292
327
  end
293
328
  end
294
329
  end
@@ -305,4 +340,4 @@ module Warbler
305
340
  file
306
341
  end
307
342
  end
308
- end
343
+ end
@@ -5,5 +5,5 @@
5
5
  #++
6
6
 
7
7
  module Warbler
8
- VERSION = "0.9.11"
8
+ VERSION = "0.9.12"
9
9
  end
@@ -0,0 +1,15 @@
1
+ # Filters added to this controller apply to all controllers in the application.
2
+ # Likewise, all the methods added will be available for all controllers.
3
+
4
+ class ApplicationController < ActionController::Base
5
+ helper :all # include all helpers, all the time
6
+
7
+ # See ActionController::RequestForgeryProtection for details
8
+ # Uncomment the :secret if you're not using the cookie session store
9
+ protect_from_forgery # :secret => '9eae08a7d153857faa33c1101e411ce1'
10
+
11
+ # See ActionController::Base for details
12
+ # Uncomment this to filter the contents of submitted sensitive data parameters
13
+ # from your application log (in this case, all fields with names like "password").
14
+ # filter_parameter_logging :password
15
+ end
@@ -0,0 +1,3 @@
1
+ # Methods added to this helper will be available to all templates in the application.
2
+ module ApplicationHelper
3
+ end
@@ -0,0 +1,109 @@
1
+ # Don't change this file!
2
+ # Configure your app in config/environment.rb and config/environments/*.rb
3
+
4
+ RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
5
+
6
+ module Rails
7
+ class << self
8
+ def boot!
9
+ unless booted?
10
+ preinitialize
11
+ pick_boot.run
12
+ end
13
+ end
14
+
15
+ def booted?
16
+ defined? Rails::Initializer
17
+ end
18
+
19
+ def pick_boot
20
+ (vendor_rails? ? VendorBoot : GemBoot).new
21
+ end
22
+
23
+ def vendor_rails?
24
+ File.exist?("#{RAILS_ROOT}/vendor/rails")
25
+ end
26
+
27
+ def preinitialize
28
+ load(preinitializer_path) if File.exist?(preinitializer_path)
29
+ end
30
+
31
+ def preinitializer_path
32
+ "#{RAILS_ROOT}/config/preinitializer.rb"
33
+ end
34
+ end
35
+
36
+ class Boot
37
+ def run
38
+ load_initializer
39
+ Rails::Initializer.run(:set_load_path)
40
+ end
41
+ end
42
+
43
+ class VendorBoot < Boot
44
+ def load_initializer
45
+ require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
46
+ Rails::Initializer.run(:install_gem_spec_stubs)
47
+ end
48
+ end
49
+
50
+ class GemBoot < Boot
51
+ def load_initializer
52
+ self.class.load_rubygems
53
+ load_rails_gem
54
+ require 'initializer'
55
+ end
56
+
57
+ def load_rails_gem
58
+ if version = self.class.gem_version
59
+ gem 'rails', version
60
+ else
61
+ gem 'rails'
62
+ end
63
+ rescue Gem::LoadError => load_error
64
+ $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
65
+ exit 1
66
+ end
67
+
68
+ class << self
69
+ def rubygems_version
70
+ Gem::RubyGemsVersion if defined? Gem::RubyGemsVersion
71
+ end
72
+
73
+ def gem_version
74
+ if defined? RAILS_GEM_VERSION
75
+ RAILS_GEM_VERSION
76
+ elsif ENV.include?('RAILS_GEM_VERSION')
77
+ ENV['RAILS_GEM_VERSION']
78
+ else
79
+ parse_gem_version(read_environment_rb)
80
+ end
81
+ end
82
+
83
+ def load_rubygems
84
+ require 'rubygems'
85
+
86
+ unless rubygems_version >= '0.9.4'
87
+ $stderr.puts %(Rails requires RubyGems >= 0.9.4 (you have #{rubygems_version}). Please `gem update --system` and try again.)
88
+ exit 1
89
+ end
90
+
91
+ rescue LoadError
92
+ $stderr.puts %(Rails requires RubyGems >= 0.9.4. Please install RubyGems and try again: http://rubygems.rubyforge.org)
93
+ exit 1
94
+ end
95
+
96
+ def parse_gem_version(text)
97
+ $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
98
+ end
99
+
100
+ private
101
+ def read_environment_rb
102
+ File.read("#{RAILS_ROOT}/config/environment.rb")
103
+ end
104
+ end
105
+ end
106
+ end
107
+
108
+ # All that for this:
109
+ Rails.boot!
@@ -0,0 +1,67 @@
1
+ # Be sure to restart your server when you modify this file
2
+
3
+ # Uncomment below to force Rails into production mode when
4
+ # you don't control web/app server and can't set it the proper way
5
+ # ENV['RAILS_ENV'] ||= 'production'
6
+
7
+ # Specifies gem version of Rails to use when vendor/rails is not present
8
+ RAILS_GEM_VERSION = '2.1.0' unless defined? RAILS_GEM_VERSION
9
+
10
+ # Bootstrap the Rails environment, frameworks, and default configuration
11
+ require File.join(File.dirname(__FILE__), 'boot')
12
+
13
+ Rails::Initializer.run do |config|
14
+ # Settings in config/environments/* take precedence over those specified here.
15
+ # Application configuration should go into files in config/initializers
16
+ # -- all .rb files in that directory are automatically loaded.
17
+ # See Rails::Configuration for more options.
18
+
19
+ # Skip frameworks you're not going to use. To use Rails without a database
20
+ # you must remove the Active Record framework.
21
+ # config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
22
+
23
+ # Specify gems that this application depends on.
24
+ # They can then be installed with "rake gems:install" on new installations.
25
+ # config.gem "bj"
26
+ # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
27
+ # config.gem "aws-s3", :lib => "aws/s3"
28
+
29
+ # Only load the plugins named here, in the order given. By default, all plugins
30
+ # in vendor/plugins are loaded in alphabetical order.
31
+ # :all can be used as a placeholder for all plugins not explicitly named
32
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
33
+
34
+ # Add additional load paths for your own custom dirs
35
+ # config.load_paths += %W( #{RAILS_ROOT}/extras )
36
+
37
+ # Force all environments to use the same logger level
38
+ # (by default production uses :info, the others :debug)
39
+ # config.log_level = :debug
40
+
41
+ # Make Time.zone default to the specified zone, and make Active Record store time values
42
+ # in the database in UTC, and return them converted to the specified local zone.
43
+ # Run "rake -D time" for a list of tasks for finding time zone names. Uncomment to use default local time.
44
+ config.time_zone = 'UTC'
45
+
46
+ # Your secret key for verifying cookie session data integrity.
47
+ # If you change this key, all old sessions will become invalid!
48
+ # Make sure the secret is at least 30 characters and all random,
49
+ # no regular words or you'll be exposed to dictionary attacks.
50
+ config.action_controller.session = {
51
+ :session_key => '_sample_session',
52
+ :secret => 'e747620fa6b20fae99c5fe0797091fe35a84dd367f4031d1a37cd61376ecce0537b5ae22c5d606e30be2a05ef303ee2aa39813080e6fdd6bb3bd932552313c5c'
53
+ }
54
+
55
+ # Use the database for sessions instead of the cookie-based default,
56
+ # which shouldn't be used to store highly confidential information
57
+ # (create the session table with "rake db:sessions:create")
58
+ # config.action_controller.session_store = :active_record_store
59
+
60
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
61
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
62
+ # like if you have constraints or database-specific column types
63
+ # config.active_record.schema_format = :sql
64
+
65
+ # Activate observers that should always be running
66
+ # config.active_record.observers = :cacher, :garbage_collector
67
+ end
@@ -0,0 +1,17 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # In the development environment your application's code is reloaded on
4
+ # every request. This slows down response time but is perfect for development
5
+ # since you don't have to restart the webserver when you make code changes.
6
+ config.cache_classes = false
7
+
8
+ # Log error messages when you accidentally call methods on nil.
9
+ config.whiny_nils = true
10
+
11
+ # Show full error reports and disable caching
12
+ config.action_controller.consider_all_requests_local = true
13
+ config.action_view.debug_rjs = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Don't care if the mailer can't send
17
+ config.action_mailer.raise_delivery_errors = false
@@ -0,0 +1,22 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # The production environment is meant for finished, "live" apps.
4
+ # Code is not reloaded between requests
5
+ config.cache_classes = true
6
+
7
+ # Use a different logger for distributed setups
8
+ # config.logger = SyslogLogger.new
9
+
10
+ # Full error reports are disabled and caching is turned on
11
+ config.action_controller.consider_all_requests_local = false
12
+ config.action_controller.perform_caching = true
13
+ config.action_view.cache_template_loading = true
14
+
15
+ # Use a different cache store in production
16
+ # config.cache_store = :mem_cache_store
17
+
18
+ # Enable serving of images, stylesheets, and javascripts from an asset server
19
+ # config.action_controller.asset_host = "http://assets.example.com"
20
+
21
+ # Disable delivery errors, bad email addresses will be ignored
22
+ # config.action_mailer.raise_delivery_errors = false
@@ -0,0 +1,22 @@
1
+ # Settings specified here will take precedence over those in config/environment.rb
2
+
3
+ # The test environment is used exclusively to run your application's
4
+ # test suite. You never need to work with it otherwise. Remember that
5
+ # your test database is "scratch space" for the test suite and is wiped
6
+ # and recreated between test runs. Don't rely on the data there!
7
+ config.cache_classes = true
8
+
9
+ # Log error messages when you accidentally call methods on nil.
10
+ config.whiny_nils = true
11
+
12
+ # Show full error reports and disable caching
13
+ config.action_controller.consider_all_requests_local = true
14
+ config.action_controller.perform_caching = false
15
+
16
+ # Disable request forgery protection in test environment
17
+ config.action_controller.allow_forgery_protection = false
18
+
19
+ # Tell Action Mailer not to deliver emails to the real world.
20
+ # The :test delivery method accumulates sent emails in the
21
+ # ActionMailer::Base.deliveries array.
22
+ config.action_mailer.delivery_method = :test
@@ -0,0 +1,10 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format
4
+ # (all these examples are active by default):
5
+ # Inflector.inflections do |inflect|
6
+ # inflect.plural /^(ox)$/i, '\1en'
7
+ # inflect.singular /^(ox)en/i, '\1'
8
+ # inflect.irregular 'person', 'people'
9
+ # inflect.uncountable %w( fish sheep )
10
+ # end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,15 @@
1
+ # These settings change the behavior of Rails 2 apps and will be defaults
2
+ # for Rails 3. You can remove this initializer when Rails 3 is released.
3
+
4
+ # Include Active Record class name as root for JSON serialized output.
5
+ ActiveRecord::Base.include_root_in_json = true
6
+
7
+ # Store the full class name (including module namespace) in STI type column.
8
+ ActiveRecord::Base.store_full_sti_class = true
9
+
10
+ # Use ISO 8601 format for JSON serialized times and dates.
11
+ ActiveSupport.use_standard_json_time_format = true
12
+
13
+ # Don't escape HTML entities in JSON, leave that for the #json_escape helper.
14
+ # if you're including raw json in an HTML page.
15
+ ActiveSupport.escape_html_entities_in_json = false
@@ -0,0 +1,41 @@
1
+ ActionController::Routing::Routes.draw do |map|
2
+ # The priority is based upon order of creation: first created -> highest priority.
3
+
4
+ # Sample of regular route:
5
+ # map.connect 'products/:id', :controller => 'catalog', :action => 'view'
6
+ # Keep in mind you can assign values other than :controller and :action
7
+
8
+ # Sample of named route:
9
+ # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
10
+ # This route can be invoked with purchase_url(:id => product.id)
11
+
12
+ # Sample resource route (maps HTTP verbs to controller actions automatically):
13
+ # map.resources :products
14
+
15
+ # Sample resource route with options:
16
+ # map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
17
+
18
+ # Sample resource route with sub-resources:
19
+ # map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
20
+
21
+ # Sample resource route with more complex sub-resources
22
+ # map.resources :products do |products|
23
+ # products.resources :comments
24
+ # products.resources :sales, :collection => { :recent => :get }
25
+ # end
26
+
27
+ # Sample resource route within a namespace:
28
+ # map.namespace :admin do |admin|
29
+ # # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
30
+ # admin.resources :products
31
+ # end
32
+
33
+ # You can have the root of your site routed with map.root -- just remember to delete public/index.html.
34
+ # map.root :controller => "welcome"
35
+
36
+ # See how all your routes lay out with "rake routes"
37
+
38
+ # Install the default routes as the lowest priority.
39
+ map.connect ':controller/:action/:id'
40
+ map.connect ':controller/:action/:id.:format'
41
+ end
@@ -107,10 +107,4 @@ describe Warbler::Config do
107
107
  config.webxml.a["b&"].c = "123<hi>456"
108
108
  config.webxml.context_params['a.b&amp;.c'].should == "123&lt;hi&gt;456"
109
109
  end
110
-
111
- #it "should automatically gems used by the web application" do
112
- # gem "actionpack"
113
- # config = Warbler::Config.new
114
- # config.gems.should include("actionpack")
115
- #end
116
110
  end
@@ -9,24 +9,31 @@ require File.dirname(__FILE__) + '/../spec_helper'
9
9
  describe Warbler::Gems do
10
10
  it "should accept a hash for initialization" do
11
11
  gems = Warbler::Gems.new({"actionpack" => "1.2.3"})
12
- gems.should include("actionpack")
12
+ gems.should have_key("actionpack")
13
13
  gems["actionpack"].should == "1.2.3"
14
14
  end
15
-
15
+
16
16
  it "should accept an array for initialization" do
17
17
  gems = Warbler::Gems.new ["activerecord"]
18
- gems.should include("activerecord")
18
+ gems.should have_key("activerecord")
19
19
  end
20
-
20
+
21
21
  it "should allow gems with a version" do
22
22
  gems = Warbler::Gems.new
23
23
  gems["actionpack"] = "> 1.2.3"
24
24
  gems["actionpack"].should == "> 1.2.3"
25
25
  end
26
-
26
+
27
27
  it "should allow gems without an explicit version" do
28
28
  gems = Warbler::Gems.new
29
29
  gems << "actionpack"
30
- gems.should include("actionpack")
31
- end
30
+ gems.should have_key("actionpack")
31
+ end
32
+
33
+ it "should allow to add gems" do
34
+ gems = Warbler::Gems.new
35
+ gems << "rails"
36
+ gems += ["activerecord-jdbcmysql-adapter", "jdbc-mysql", "jruby-openssl"]
37
+ ["rails", "activerecord-jdbcmysql-adapter", "jdbc-mysql", "jruby-openssl"].each {|g| gems.should have_key(g)}
38
+ end
32
39
  end
@@ -10,28 +10,25 @@ describe Warbler::Task do
10
10
  before(:each) do
11
11
  @rake = Rake::Application.new
12
12
  Rake.application = @rake
13
- mkdir_p "public"
13
+ verbose(false)
14
+ @pwd = Dir.getwd
15
+ Dir.chdir("spec/sample")
14
16
  mkdir_p "log"
15
- touch "public/index.html"
16
17
  touch "log/test.log"
17
18
  @config = Warbler::Config.new do |config|
18
- config.staging_dir = "pkg/tmp/war"
19
+ config.staging_dir = "tmp/war"
19
20
  config.war_name = "warbler"
20
21
  config.gems = ["rake"]
21
- config.dirs = %w(bin generators log lib)
22
- config.public_html = FileList["public/**/*", "tasks/**/*"]
23
22
  config.webxml.jruby.max.runtimes = 5
24
23
  end
25
- verbose(false)
26
24
  end
27
25
 
28
26
  after(:each) do
29
27
  define_tasks "clean"
30
28
  Rake::Task["warble:clean"].invoke
31
- rm_rf "public"
32
- rm_rf "config"
33
29
  rm_rf "log"
34
- rm_f "config.ru"
30
+ rm_f FileList["config.ru", "*web.xml", "config/web.xml*", "config/warble.rb"]
31
+ Dir.chdir(@pwd)
35
32
  end
36
33
 
37
34
  def define_tasks(*tasks)
@@ -62,7 +59,6 @@ describe Warbler::Task do
62
59
  define_tasks "public"
63
60
  Rake::Task["warble:public"].invoke
64
61
  file_list(%r{^#{@config.staging_dir}/index\.html}).should_not be_empty
65
- file_list(%r{tasks/warbler\.rake}).should_not be_empty
66
62
  end
67
63
 
68
64
  it "should define a gems task for unpacking gems" do
@@ -177,9 +173,9 @@ describe Warbler::Task do
177
173
  end
178
174
  define_tasks "app"
179
175
  Rake::Task["warble:app"].invoke
180
- file_list(%r{WEB-INF/bin/warble$}).should_not be_empty
181
- file_list(%r{WEB-INF/generators/warble/warble_generator\.rb$}).should_not be_empty
182
- file_list(%r{WEB-INF/lib/warbler\.rb$}).should_not be_empty
176
+ file_list(%r{WEB-INF/app$}).should_not be_empty
177
+ file_list(%r{WEB-INF/config$}).should_not be_empty
178
+ file_list(%r{WEB-INF/lib$}).should_not be_empty
183
179
  gems_ran.should == true
184
180
  end
185
181
 
@@ -191,6 +187,18 @@ describe Warbler::Task do
191
187
  File.exist?("warbler.war").should == true
192
188
  end
193
189
 
190
+ it "should define an exploded task for creating an exploded Rails app" do
191
+ @config.java_classes = ["Rakefile"]
192
+ @config.java_libs = []
193
+ define_tasks "webxml", "exploded", "java_classes", "gems"
194
+ Rake::Task['warble:exploded'].invoke
195
+ File.exist?("web.xml").should == true
196
+ File.exist?("sun-web.xml").should == true
197
+ File.symlink?("gems").should == true
198
+ File.symlink?("public/WEB-INF").should == true
199
+ Rake::Task['warble:clean:exploded'].invoke
200
+ end
201
+
194
202
  it "should accept an autodeploy directory where the war should be created" do
195
203
  define_tasks "jar"
196
204
  require 'tempfile'
@@ -215,12 +223,11 @@ describe Warbler::Task do
215
223
  end
216
224
 
217
225
  it "should be able to exclude files from the .war" do
218
- @config.dirs << "spec"
219
- @config.excludes += FileList['spec/spec_helper.rb']
226
+ @config.excludes += FileList['lib/tasks/utils.rake']
220
227
  task "warble:gems" do; end
221
228
  define_tasks "app"
222
229
  Rake::Task["warble:app"].invoke
223
- file_list(%r{spec/spec_helper.rb}).should be_empty
230
+ file_list(%r{lib/tasks/utils.rake}).should be_empty
224
231
  end
225
232
 
226
233
  it "should be able to define all tasks successfully" do
@@ -298,6 +305,25 @@ describe Warbler::Task do
298
305
  rails
299
306
  end
300
307
 
308
+ def mock_merb_module
309
+ merb = Module.new
310
+ Object.const_set("Merb", merb)
311
+ boot_loader = Module.new
312
+ merb.const_set("BootLoader", boot_loader)
313
+ merb.const_set("VERSION", "1.0")
314
+ dependencies = Class.new do
315
+ @@dependencies = []
316
+ def self.dependencies
317
+ @@dependencies
318
+ end
319
+ def self.dependencies=(deps)
320
+ @@dependencies = deps
321
+ end
322
+ end
323
+ boot_loader.const_set("Dependencies", dependencies)
324
+ dependencies
325
+ end
326
+
301
327
  it "should auto-detect a Rails application" do
302
328
  task :environment do
303
329
  mock_rails_module
@@ -314,7 +340,7 @@ describe Warbler::Task do
314
340
  end
315
341
 
316
342
  config = Warbler::Config.new
317
- config.gems.should include("rails")
343
+ config.gems.should have_key("rails")
318
344
 
319
345
  mkdir_p "vendor/rails"
320
346
  config = Warbler::Config.new
@@ -326,15 +352,26 @@ describe Warbler::Task do
326
352
  config.gems.should be_empty
327
353
  end
328
354
 
355
+ it "should not try to autodetect frameworks when Warbler.framework_detection is false" do
356
+ begin
357
+ Warbler.framework_detection = false
358
+ task :environment
359
+ config = Warbler::Config.new
360
+ config.webxml.booter.should_not == :rails
361
+ t = Rake::Task['environment']
362
+ class << t; public :instance_variable_get; end
363
+ t.instance_variable_get("@already_invoked").should == false
364
+ ensure
365
+ Warbler.framework_detection = true
366
+ end
367
+ end
368
+
329
369
  it "should auto-detect a Merb application" do
330
370
  task :merb_env do
331
- merb = Module.new
332
- Object.const_set("Merb", merb)
333
- merb.const_set("VERSION", "0.9.3")
371
+ mock_merb_module
334
372
  end
335
373
  @config = Warbler::Config.new
336
374
  @config.webxml.booter.should == :merb
337
- @config.gems["merb"].should == "0.9.3"
338
375
  @config.gems.keys.should_not include("rails")
339
376
  end
340
377
 
@@ -353,13 +390,41 @@ describe Warbler::Task do
353
390
  rails.stub!(:configuration).and_return(config)
354
391
  gem = mock "gem"
355
392
  gem.stub!(:name).and_return "hpricot"
356
- gem.stub!(:version).and_return "=0.6"
393
+ gem.stub!(:requirement).and_return Gem::Requirement.new("=0.6")
357
394
  config.stub!(:gems).and_return [gem]
358
395
  end
359
396
 
360
397
  @config = Warbler::Config.new
361
398
  @config.webxml.booter.should == :rails
362
- @config.gems["hpricot"].should == "=0.6"
399
+ @config.gems.keys.should include(Gem::Dependency.new("hpricot", Gem::Requirement.new("=0.6")))
400
+ end
401
+
402
+ it "should automatically add Merb::BootLoader::Dependencies.dependencies to the list of gems" do
403
+ task :merb_env do
404
+ deps = mock_merb_module
405
+ deps.dependencies = [Gem::Dependency.new("merb-core", ">= 1.0.6.1")]
406
+ end
407
+ @config = Warbler::Config.new
408
+ @config.webxml.booter.should == :merb
409
+ @config.gems.keys.should include(Gem::Dependency.new("merb-core", ">= 1.0.6.1"))
410
+ end
411
+
412
+ it "should skip Merb development dependencies" do
413
+ task :merb_env do
414
+ deps = mock_merb_module
415
+ deps.dependencies = [Gem::Dependency.new("rake", "= #{RAKEVERSION}", :development)]
416
+ end
417
+ @config = Warbler::Config.new
418
+ define_tasks "copy_gems"
419
+ Rake.application.lookup("gem:rake-#{RAKEVERSION}").should be_nil
420
+ end
421
+
422
+ it "should warn about using Merb < 1.0" do
423
+ task :merb_env do
424
+ Object.const_set("Merb", Module.new)
425
+ end
426
+ @config = Warbler::Config.new
427
+ @config.webxml.booter.should == :merb
363
428
  end
364
429
 
365
430
  it "should set the jruby max runtimes to 1 when MT Rails is detected" do
@@ -379,6 +444,7 @@ describe "The warbler.rake file" do
379
444
  it "should be able to list its contents" do
380
445
  output = `#{FileUtils::RUBY} -S rake -f #{Warbler::WARBLER_HOME}/tasks/warbler.rake -T`
381
446
  output.should =~ /war\s/
447
+ output.should =~ /war:exploded/
382
448
  output.should =~ /war:app/
383
449
  output.should =~ /war:clean/
384
450
  output.should =~ /war:gems/
@@ -407,4 +473,4 @@ describe "Debug targets" do
407
473
  capture { Rake::Task["war:debug:excludes"].invoke }.should =~ /exclude/
408
474
  capture { Rake::Task["war:debug"].invoke }.should =~ /Config/
409
475
  end
410
- end
476
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: warbler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.11
4
+ version: 0.9.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Sieger
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-09-04 00:00:00 +02:00
12
+ date: 2008-12-18 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -45,14 +45,25 @@ files:
45
45
  - generators/warble/templates
46
46
  - generators/warble/templates/warble.rb
47
47
  - generators/warble/warble_generator.rb
48
- - lib/jruby-complete-1.1.4.jar
49
- - lib/jruby-rack-0.9.2.jar
48
+ - lib/jruby-complete-1.1.6.jar
49
+ - lib/jruby-rack-0.9.3.jar
50
50
  - lib/warbler
51
51
  - lib/warbler/config.rb
52
52
  - lib/warbler/gems.rb
53
53
  - lib/warbler/task.rb
54
54
  - lib/warbler/version.rb
55
55
  - lib/warbler.rb
56
+ - spec/sample/app/controllers/application.rb
57
+ - spec/sample/app/helpers/application_helper.rb
58
+ - spec/sample/config/boot.rb
59
+ - spec/sample/config/environment.rb
60
+ - spec/sample/config/environments/development.rb
61
+ - spec/sample/config/environments/production.rb
62
+ - spec/sample/config/environments/test.rb
63
+ - spec/sample/config/initializers/inflections.rb
64
+ - spec/sample/config/initializers/mime_types.rb
65
+ - spec/sample/config/initializers/new_rails_defaults.rb
66
+ - spec/sample/config/routes.rb
56
67
  - spec/spec_helper.rb
57
68
  - spec/warbler/config_spec.rb
58
69
  - spec/warbler/gems_spec.rb
@@ -81,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
81
92
  requirements: []
82
93
 
83
94
  rubyforge_project: caldersphere
84
- rubygems_version: 1.2.0
95
+ rubygems_version: 1.3.1
85
96
  signing_key:
86
97
  specification_version: 2
87
98
  summary: Warbler chirpily constructs .war files of your Rails applications.
Binary file