warbler 1.2.1 → 1.3.0.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +8 -5
- data/History.txt +5 -0
- data/Manifest.txt +43 -23
- data/README.txt +67 -26
- data/Rakefile +17 -6
- data/ext/JarMain.java +147 -0
- data/ext/{Main.java → WarMain.java} +4 -4
- data/ext/{WarblerWar.java → WarblerJar.java} +79 -13
- data/ext/{WarblerWarService.java → WarblerJarService.java} +2 -2
- data/lib/warbler/application.rb +9 -9
- data/lib/warbler/config.rb +58 -204
- data/lib/warbler/gems.rb +2 -2
- data/lib/warbler/jar.rb +247 -0
- data/lib/warbler/task.rb +28 -60
- data/lib/warbler/templates/config.erb +1 -1
- data/lib/warbler/templates/rack.erb +1 -1
- data/lib/warbler/templates/rails.erb +1 -1
- data/lib/warbler/traits/bundler.rb +58 -0
- data/lib/warbler/traits/gemspec.rb +64 -0
- data/lib/warbler/traits/jar.rb +53 -0
- data/lib/warbler/traits/merb.rb +34 -0
- data/lib/warbler/traits/nogemspec.rb +41 -0
- data/lib/warbler/traits/rack.rb +31 -0
- data/lib/warbler/traits/rails.rb +57 -0
- data/lib/warbler/traits/war.rb +191 -0
- data/lib/warbler/traits.rb +105 -0
- data/lib/warbler/version.rb +1 -1
- data/lib/warbler/war.rb +1 -247
- data/lib/warbler.rb +2 -5
- data/lib/warbler_jar.jar +0 -0
- data/spec/sample_jar/History.txt +6 -0
- data/spec/sample_jar/Manifest.txt +8 -0
- data/spec/sample_jar/README.txt +30 -0
- data/spec/sample_jar/lib/sample_jar.rb +6 -0
- data/spec/sample_jar/sample_jar.gemspec +41 -0
- data/spec/sample_jar/test/test_sample_jar.rb +8 -0
- data/spec/{sample → sample_war}/app/controllers/application.rb +0 -0
- data/spec/{sample → sample_war}/app/helpers/application_helper.rb +0 -0
- data/spec/{sample → sample_war}/config/boot.rb +0 -0
- data/spec/{sample → sample_war}/config/database.yml +0 -0
- data/spec/{sample → sample_war}/config/environment.rb +0 -0
- data/spec/{sample → sample_war}/config/environments/development.rb +0 -0
- data/spec/{sample → sample_war}/config/environments/production.rb +0 -0
- data/spec/{sample → sample_war}/config/environments/test.rb +0 -0
- data/spec/{sample → sample_war}/config/initializers/inflections.rb +0 -0
- data/spec/{sample → sample_war}/config/initializers/mime_types.rb +0 -0
- data/spec/{sample → sample_war}/config/initializers/new_rails_defaults.rb +0 -0
- data/spec/{sample → sample_war}/config/routes.rb +0 -0
- data/spec/{sample → sample_war}/lib/tasks/utils.rake +0 -0
- data/spec/{sample → sample_war}/public/404.html +0 -0
- data/spec/{sample → sample_war}/public/422.html +0 -0
- data/spec/{sample → sample_war}/public/500.html +0 -0
- data/spec/{sample → sample_war}/public/favicon.ico +0 -0
- data/spec/{sample → sample_war}/public/index.html +0 -0
- data/spec/{sample → sample_war}/public/robots.txt +0 -0
- data/spec/spec_helper.rb +40 -0
- data/spec/warbler/application_spec.rb +2 -9
- data/spec/warbler/config_spec.rb +101 -83
- data/spec/warbler/jar_spec.rb +763 -0
- data/spec/warbler/task_spec.rb +56 -41
- data/spec/warbler/traits_spec.rb +16 -0
- data/spec/warbler/war_spec.rb +2 -492
- data/warble.rb +36 -32
- metadata +57 -35
- 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
|
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
|
data/spec/warbler/config_spec.rb
CHANGED
@@ -12,101 +12,119 @@ describe Warbler::Config do
|
|
12
12
|
verbose(false)
|
13
13
|
end
|
14
14
|
|
15
|
-
|
16
|
-
|
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
|
-
|
27
|
-
|
28
|
-
|
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
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
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
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
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
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
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
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
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
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
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
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
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
|
-
|
104
|
-
|
105
|
-
|
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
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
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&.c'].should == "123<hi>456"
|
128
|
+
end
|
111
129
|
end
|
112
130
|
end
|