warbler 1.2.1 → 1.3.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. data/Gemfile +8 -5
  2. data/History.txt +5 -0
  3. data/Manifest.txt +43 -23
  4. data/README.txt +67 -26
  5. data/Rakefile +17 -6
  6. data/ext/JarMain.java +147 -0
  7. data/ext/{Main.java → WarMain.java} +4 -4
  8. data/ext/{WarblerWar.java → WarblerJar.java} +79 -13
  9. data/ext/{WarblerWarService.java → WarblerJarService.java} +2 -2
  10. data/lib/warbler/application.rb +9 -9
  11. data/lib/warbler/config.rb +58 -204
  12. data/lib/warbler/gems.rb +2 -2
  13. data/lib/warbler/jar.rb +247 -0
  14. data/lib/warbler/task.rb +28 -60
  15. data/lib/warbler/templates/config.erb +1 -1
  16. data/lib/warbler/templates/rack.erb +1 -1
  17. data/lib/warbler/templates/rails.erb +1 -1
  18. data/lib/warbler/traits/bundler.rb +58 -0
  19. data/lib/warbler/traits/gemspec.rb +64 -0
  20. data/lib/warbler/traits/jar.rb +53 -0
  21. data/lib/warbler/traits/merb.rb +34 -0
  22. data/lib/warbler/traits/nogemspec.rb +41 -0
  23. data/lib/warbler/traits/rack.rb +31 -0
  24. data/lib/warbler/traits/rails.rb +57 -0
  25. data/lib/warbler/traits/war.rb +191 -0
  26. data/lib/warbler/traits.rb +105 -0
  27. data/lib/warbler/version.rb +1 -1
  28. data/lib/warbler/war.rb +1 -247
  29. data/lib/warbler.rb +2 -5
  30. data/lib/warbler_jar.jar +0 -0
  31. data/spec/sample_jar/History.txt +6 -0
  32. data/spec/sample_jar/Manifest.txt +8 -0
  33. data/spec/sample_jar/README.txt +30 -0
  34. data/spec/sample_jar/lib/sample_jar.rb +6 -0
  35. data/spec/sample_jar/sample_jar.gemspec +41 -0
  36. data/spec/sample_jar/test/test_sample_jar.rb +8 -0
  37. data/spec/{sample → sample_war}/app/controllers/application.rb +0 -0
  38. data/spec/{sample → sample_war}/app/helpers/application_helper.rb +0 -0
  39. data/spec/{sample → sample_war}/config/boot.rb +0 -0
  40. data/spec/{sample → sample_war}/config/database.yml +0 -0
  41. data/spec/{sample → sample_war}/config/environment.rb +0 -0
  42. data/spec/{sample → sample_war}/config/environments/development.rb +0 -0
  43. data/spec/{sample → sample_war}/config/environments/production.rb +0 -0
  44. data/spec/{sample → sample_war}/config/environments/test.rb +0 -0
  45. data/spec/{sample → sample_war}/config/initializers/inflections.rb +0 -0
  46. data/spec/{sample → sample_war}/config/initializers/mime_types.rb +0 -0
  47. data/spec/{sample → sample_war}/config/initializers/new_rails_defaults.rb +0 -0
  48. data/spec/{sample → sample_war}/config/routes.rb +0 -0
  49. data/spec/{sample → sample_war}/lib/tasks/utils.rake +0 -0
  50. data/spec/{sample → sample_war}/public/404.html +0 -0
  51. data/spec/{sample → sample_war}/public/422.html +0 -0
  52. data/spec/{sample → sample_war}/public/500.html +0 -0
  53. data/spec/{sample → sample_war}/public/favicon.ico +0 -0
  54. data/spec/{sample → sample_war}/public/index.html +0 -0
  55. data/spec/{sample → sample_war}/public/robots.txt +0 -0
  56. data/spec/spec_helper.rb +40 -0
  57. data/spec/warbler/application_spec.rb +2 -9
  58. data/spec/warbler/config_spec.rb +101 -83
  59. data/spec/warbler/jar_spec.rb +763 -0
  60. data/spec/warbler/task_spec.rb +56 -41
  61. data/spec/warbler/traits_spec.rb +16 -0
  62. data/spec/warbler/war_spec.rb +2 -492
  63. data/warble.rb +36 -32
  64. metadata +57 -35
  65. data/lib/warbler_war.jar +0 -0
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
data/spec/spec_helper.rb CHANGED
@@ -33,6 +33,46 @@ def capture(&block)
33
33
  io.string
34
34
  end
35
35
 
36
+ module Spec::Example::ExampleGroupMethods
37
+ def run_in_directory(dir)
38
+ before :each do
39
+ @pwd = Dir.getwd
40
+ Dir.chdir(dir)
41
+ end
42
+
43
+ after :each do
44
+ Dir.chdir(@pwd)
45
+ end
46
+ end
47
+
48
+ def use_fresh_rake_application
49
+ before :each do
50
+ @rake = Rake::Application.new
51
+ Rake.application = @rake
52
+ verbose(false)
53
+ end
54
+ end
55
+
56
+ def use_fresh_environment
57
+ before(:each) do
58
+ @env_save = {}
59
+ (ENV.keys.grep(/BUNDLE/) + ["RUBYOPT", "GEM_PATH"]).each {|k| @env_save[k] = ENV[k]; ENV[k] = nil}
60
+ end
61
+
62
+ after(:each) do
63
+ @env_save.keys.each {|k| ENV[k] = @env_save[k]}
64
+ end
65
+ end
66
+
67
+ def cleanup_temp_files
68
+ after(:each) do
69
+ rm_rf FileList["log", ".bundle", "tmp/war"]
70
+ rm_f FileList["*.war", "*.foobar", "**/config.ru", "*web.xml*", "config/web.xml*", "config/warble.rb",
71
+ "file.txt", 'manifest', 'Gemfile*', 'MANIFEST.MF*', 'init.rb*', '**/*.class']
72
+ end
73
+ end
74
+ end
75
+
36
76
  Spec::Runner.configure do |config|
37
77
  config.after(:each) do
38
78
  class << Object
@@ -8,10 +8,10 @@
8
8
  require File.dirname(__FILE__) + '/../spec_helper'
9
9
 
10
10
  describe Warbler::Application do
11
+ run_in_directory "spec/sample_war"
12
+
11
13
  before :each do
12
14
  verbose(false)
13
- @pwd = Dir.getwd
14
- Dir.chdir("spec/sample")
15
15
  @argv = ARGV.dup
16
16
  ARGV.clear
17
17
  @app = Rake.application
@@ -27,7 +27,6 @@ describe Warbler::Application do
27
27
  Warbler.framework_detection = @detection
28
28
  @argv.reverse.each {|a| ARGV.unshift a}
29
29
  rm_rf FileList['vendor/plugins/warbler']
30
- Dir.chdir(@pwd)
31
30
  end
32
31
 
33
32
  it "should be able to list its tasks" do
@@ -84,10 +83,4 @@ describe Warbler::Application do
84
83
  it "should provide a means to load the project Rakefile" do
85
84
  Warbler::Application.new.load_project_rakefile
86
85
  end
87
-
88
- it "should define a gemjar task for setting up gem packaging inside a jar" do
89
- ARGV.unshift "gemjar"
90
- Warbler::Application.new.run
91
- Rake::Task['war:jar'].prerequisites.should include('war:make_gemjar')
92
- end
93
86
  end
@@ -12,101 +12,119 @@ describe Warbler::Config do
12
12
  verbose(false)
13
13
  end
14
14
 
15
- it "should have suitable default values" do
16
- config = Warbler::Config.new
17
- config.dirs.should include(*Warbler::Config::TOP_DIRS.select{|d| File.directory?(d)})
18
- config.includes.should be_empty
19
- config.java_libs.should_not be_empty
20
- config.war_name.size.should > 0
21
- config.webxml.should be_kind_of(OpenStruct)
22
- config.pathmaps.should be_kind_of(OpenStruct)
23
- config.pathmaps.public_html.should == ["%{public/,}p"]
24
- end
15
+ context "in an unknown application" do
16
+ run_in_directory 'spec/sample_war/tmp'
25
17
 
26
- it "should allow configuration through an initializer block" do
27
- config = Warbler::Config.new do |c|
28
- c.war_name = "mywar"
18
+ it "has suitable default values" do
19
+ config = Warbler::Config.new
20
+ config.includes.should be_empty
21
+ config.jar_name.size.should > 0
29
22
  end
30
- config.war_name.should == "mywar"
31
23
  end
32
24
 
33
- it "should allow gems to be added/changed with =, +=, -=, <<" do
34
- config = Warbler::Config.new do |c|
35
- c.gems += ["activerecord-jdbc-adapter"]
36
- c.gems -= ["rails"]
37
- c.gems << "tzinfo"
38
- c.gems = ["camping"]
25
+ context "in a web application" do
26
+ run_in_directory 'spec/sample_war'
27
+
28
+ after :each do
29
+ rm_f "vendor/test.log"
39
30
  end
40
- end
41
31
 
42
- it "should exclude log files by default" do
43
- mkdir_p "vendor"
44
- touch "vendor/test.log"
45
- config = Warbler::Config.new
46
- config.exclude_logs.should == true
47
- config.excludes.include?("vendor/test.log").should == true
48
- end
32
+ it "should have suitable default values" do
33
+ config = Warbler::Config.new
34
+ config.dirs.should include(*Warbler::Config::TOP_DIRS.select{|d| File.directory?(d)})
35
+ config.includes.should be_empty
36
+ config.java_libs.should_not be_empty
37
+ config.jar_name.size.should > 0
38
+ config.webxml.should be_kind_of(OpenStruct)
39
+ config.pathmaps.should be_kind_of(OpenStruct)
40
+ config.pathmaps.public_html.should == ["%{public/,}p"]
41
+ end
49
42
 
50
- it "should include log files if exclude_logs is false" do
51
- mkdir_p "vendor"
52
- touch "vendor/test.log"
53
- config = Warbler::Config.new {|c| c.exclude_logs = false }
54
- config.exclude_logs.should == false
55
- config.excludes.include?("vendor/test.log").should == false
56
- end
43
+ it "should allow configuration through an initializer block" do
44
+ config = Warbler::Config.new do |c|
45
+ c.jar_name = "mywar"
46
+ end
47
+ config.jar_name.should == "mywar"
48
+ end
57
49
 
58
- it "should exclude Warbler itself when run as a plugin" do
59
- config = Warbler::Config.new
60
- config.excludes.include?("vendor/plugins/warbler").should == false
61
- config = Warbler::Config.new File.join(Dir.getwd, "vendor", "plugins", "warbler")
62
- config.excludes.include?("vendor/plugins/warbler").should == true
63
- end
50
+ it "should allow gems to be added/changed with =, +=, -=, <<" do
51
+ config = Warbler::Config.new do |c|
52
+ c.gems += ["activerecord-jdbc-adapter"]
53
+ c.gems -= ["rails"]
54
+ c.gems << "tzinfo"
55
+ c.gems = ["camping"]
56
+ end
57
+ end
64
58
 
65
- it "should generate context parameters from the webxml openstruct" do
66
- config = Warbler::Config.new
67
- config.webxml.a.b.c = "123"
68
- config.webxml.com.example.config = "blah"
69
- config.webxml.rails.env = 'staging'
70
- config.webxml.jruby.min.runtimes = 2
71
- config.webxml.jruby.max.runtimes = 4
72
- config.webxml['org']['jruby']['rack'] = "rails"
73
- params = config.webxml.context_params
74
- params.should have_key('a.b.c')
75
- params.should have_key('rails.env')
76
- params.should have_key('jruby.min.runtimes')
77
- params.should have_key('jruby.max.runtimes')
78
- params['a.b.c'].should == "123"
79
- params['com.example.config'].should == "blah"
80
- params['rails.env'].should == "staging"
81
- params['jruby.min.runtimes'].should == "2"
82
- params['jruby.max.runtimes'].should == "4"
83
- params['org.jruby.rack'].should == "rails"
84
- end
59
+ it "should exclude log files by default" do
60
+ mkdir_p "vendor"
61
+ touch "vendor/test.log"
62
+ config = Warbler::Config.new
63
+ config.exclude_logs.should == true
64
+ config.excludes.include?("vendor/test.log").should == true
65
+ end
85
66
 
86
- it "should determine the context listener from the webxml.booter parameter" do
87
- config = Warbler::Config.new
88
- config.webxml.booter = :rack
89
- config.webxml.servlet_context_listener.should == "org.jruby.rack.RackServletContextListener"
90
- config = Warbler::Config.new
91
- config.webxml.booter = :merb
92
- config.webxml.servlet_context_listener.should == "org.jruby.rack.merb.MerbServletContextListener"
93
- config = Warbler::Config.new
94
- config.webxml.servlet_context_listener.should == "org.jruby.rack.rails.RailsServletContextListener"
95
- end
67
+ it "should include log files if exclude_logs is false" do
68
+ mkdir_p "vendor"
69
+ touch "vendor/test.log"
70
+ config = Warbler::Config.new {|c| c.exclude_logs = false }
71
+ config.exclude_logs.should == false
72
+ config.excludes.include?("vendor/test.log").should == false
73
+ end
96
74
 
97
- it "should not include ignored webxml keys in the context params hash" do
98
- Warbler::Config.new.webxml.context_params.should_not have_key('ignored')
99
- Warbler::Config.new.webxml.context_params.should_not have_key('jndi')
100
- Warbler::Config.new.webxml.context_params.should_not have_key('booter')
101
- end
75
+ it "should exclude Warbler itself when run as a plugin" do
76
+ config = Warbler::Config.new
77
+ config.excludes.include?("vendor/plugins/warbler").should == false
78
+ config = Warbler::Config.new File.join(Dir.getwd, "vendor", "plugins", "warbler")
79
+ config.excludes.include?("vendor/plugins/warbler").should == true
80
+ end
102
81
 
103
- it "should have a helpful string representation for an empty key" do
104
- Warbler::Config.new.webxml.missing_key.to_s.should =~ /No value for 'missing_key' found/
105
- end
82
+ it "should generate context parameters from the webxml openstruct" do
83
+ config = Warbler::Config.new
84
+ config.webxml.a.b.c = "123"
85
+ config.webxml.com.example.config = "blah"
86
+ config.webxml.rails.env = 'staging'
87
+ config.webxml.jruby.min.runtimes = 2
88
+ config.webxml.jruby.max.runtimes = 4
89
+ config.webxml['org']['jruby']['rack'] = "rails"
90
+ params = config.webxml.context_params
91
+ params.should have_key('a.b.c')
92
+ params.should have_key('rails.env')
93
+ params.should have_key('jruby.min.runtimes')
94
+ params.should have_key('jruby.max.runtimes')
95
+ params['a.b.c'].should == "123"
96
+ params['com.example.config'].should == "blah"
97
+ params['rails.env'].should == "staging"
98
+ params['jruby.min.runtimes'].should == "2"
99
+ params['jruby.max.runtimes'].should == "4"
100
+ params['org.jruby.rack'].should == "rails"
101
+ end
102
+
103
+ it "should determine the context listener from the webxml.booter parameter" do
104
+ config = Warbler::Config.new
105
+ config.webxml.booter = :rack
106
+ config.webxml.servlet_context_listener.should == "org.jruby.rack.RackServletContextListener"
107
+ config = Warbler::Config.new
108
+ config.webxml.booter = :merb
109
+ config.webxml.servlet_context_listener.should == "org.jruby.rack.merb.MerbServletContextListener"
110
+ config = Warbler::Config.new
111
+ config.webxml.servlet_context_listener.should == "org.jruby.rack.rails.RailsServletContextListener"
112
+ end
113
+
114
+ it "should not include ignored webxml keys in the context params hash" do
115
+ Warbler::Config.new.webxml.context_params.should_not have_key('ignored')
116
+ Warbler::Config.new.webxml.context_params.should_not have_key('jndi')
117
+ Warbler::Config.new.webxml.context_params.should_not have_key('booter')
118
+ end
106
119
 
107
- it "should HTML-escape all webxml keys and values" do
108
- config = Warbler::Config.new
109
- config.webxml.a["b&"].c = "123<hi>456"
110
- config.webxml.context_params['a.b&amp;.c'].should == "123&lt;hi&gt;456"
120
+ it "should have a helpful string representation for an empty key" do
121
+ Warbler::Config.new.webxml.missing_key.to_s.should =~ /No value for 'missing_key' found/
122
+ end
123
+
124
+ it "should HTML-escape all webxml keys and values" do
125
+ config = Warbler::Config.new
126
+ config.webxml.a["b&"].c = "123<hi>456"
127
+ config.webxml.context_params['a.b&amp;.c'].should == "123&lt;hi&gt;456"
128
+ end
111
129
  end
112
130
  end