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
 
    
        data/spec/warbler/task_spec.rb
    CHANGED
    
    | 
         @@ -8,87 +8,96 @@ 
     | 
|
| 
       8 
8 
     | 
    
         
             
            require File.dirname(__FILE__) + '/../spec_helper'
         
     | 
| 
       9 
9 
     | 
    
         | 
| 
       10 
10 
     | 
    
         
             
            describe Warbler::Task do
         
     | 
| 
       11 
     | 
    
         
            -
               
     | 
| 
      
 11 
     | 
    
         
            +
              run_in_directory "spec/sample_war"
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
              let :config do
         
     | 
| 
      
 14 
     | 
    
         
            +
                Warbler::Config.new do |config|
         
     | 
| 
      
 15 
     | 
    
         
            +
                  config.jar_name = "warbler"
         
     | 
| 
      
 16 
     | 
    
         
            +
                  config.gems = ["rake"]
         
     | 
| 
      
 17 
     | 
    
         
            +
                  config.webxml.jruby.max.runtimes = 5
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              let(:warble_task) { Warbler::Task.new "warble", config }
         
     | 
| 
      
 22 
     | 
    
         
            +
             
     | 
| 
      
 23 
     | 
    
         
            +
              def run_task(t)
         
     | 
| 
      
 24 
     | 
    
         
            +
                warble_task
         
     | 
| 
      
 25 
     | 
    
         
            +
                Rake::Task[t].invoke
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
              before :each do
         
     | 
| 
       12 
29 
     | 
    
         
             
                @rake = Rake::Application.new
         
     | 
| 
       13 
30 
     | 
    
         
             
                Rake.application = @rake
         
     | 
| 
       14 
31 
     | 
    
         
             
                verbose(false)
         
     | 
| 
       15 
     | 
    
         
            -
                @pwd = Dir.getwd
         
     | 
| 
       16 
     | 
    
         
            -
                Dir.chdir("spec/sample")
         
     | 
| 
       17 
32 
     | 
    
         
             
                mkdir_p "log"
         
     | 
| 
       18 
33 
     | 
    
         
             
                touch "log/test.log"
         
     | 
| 
       19 
     | 
    
         
            -
                @config = Warbler::Config.new do |config|
         
     | 
| 
       20 
     | 
    
         
            -
                  config.war_name = "warbler"
         
     | 
| 
       21 
     | 
    
         
            -
                  config.gems = ["rake"]
         
     | 
| 
       22 
     | 
    
         
            -
                  config.webxml.jruby.max.runtimes = 5
         
     | 
| 
       23 
     | 
    
         
            -
                end
         
     | 
| 
       24 
     | 
    
         
            -
                @task = Warbler::Task.new "warble", @config
         
     | 
| 
       25 
34 
     | 
    
         
             
              end
         
     | 
| 
       26 
35 
     | 
    
         | 
| 
       27 
     | 
    
         
            -
              after 
     | 
| 
       28 
     | 
    
         
            -
                 
     | 
| 
      
 36 
     | 
    
         
            +
              after :each do
         
     | 
| 
      
 37 
     | 
    
         
            +
                run_task "warble:clean"
         
     | 
| 
       29 
38 
     | 
    
         
             
                rm_rf "log"
         
     | 
| 
       30 
39 
     | 
    
         
             
                rm_f FileList["config.ru", "*web.xml", "config/web.xml*", "config/warble.rb",
         
     | 
| 
       31 
40 
     | 
    
         
             
                              "config/special.txt", "config/link.txt", "tmp/gems.jar",
         
     | 
| 
       32 
41 
     | 
    
         
             
                              "file.txt", 'Gemfile', 'lib/rakelib', '**/*.class']
         
     | 
| 
       33 
     | 
    
         
            -
                Dir.chdir(@pwd)
         
     | 
| 
       34 
42 
     | 
    
         
             
              end
         
     | 
| 
       35 
43 
     | 
    
         | 
| 
       36 
44 
     | 
    
         
             
              it "should define a clean task for removing the war file" do
         
     | 
| 
       37 
     | 
    
         
            -
                war_file = "#{ 
     | 
| 
      
 45 
     | 
    
         
            +
                war_file = "#{config.jar_name}.war"
         
     | 
| 
       38 
46 
     | 
    
         
             
                touch war_file
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                run_task "warble:clean"
         
     | 
| 
       40 
49 
     | 
    
         
             
                File.exist?(war_file).should == false
         
     | 
| 
       41 
50 
     | 
    
         
             
              end
         
     | 
| 
       42 
51 
     | 
    
         | 
| 
       43 
52 
     | 
    
         
             
              it "should define a make_gemjar task for storing gems in a jar file" do
         
     | 
| 
       44 
     | 
    
         
            -
                silence {  
     | 
| 
      
 53 
     | 
    
         
            +
                silence { run_task "warble:gemjar"; run_task "warble:files" }
         
     | 
| 
       45 
54 
     | 
    
         
             
                File.exist?("tmp/gems.jar").should == true
         
     | 
| 
       46 
     | 
    
         
            -
                 
     | 
| 
       47 
     | 
    
         
            -
                 
     | 
| 
      
 55 
     | 
    
         
            +
                warble_task.jar.files.keys.should_not include(%r{WEB-INF\/gems})
         
     | 
| 
      
 56 
     | 
    
         
            +
                warble_task.jar.files.keys.should include("WEB-INF/lib/gems.jar")
         
     | 
| 
       48 
57 
     | 
    
         
             
              end
         
     | 
| 
       49 
58 
     | 
    
         | 
| 
       50 
59 
     | 
    
         
             
              it "should define a war task for bundling up everything" do
         
     | 
| 
       51 
60 
     | 
    
         
             
                files_ran = false; task "warble:files" do; files_ran = true; end
         
     | 
| 
       52 
61 
     | 
    
         
             
                jar_ran = false; task "warble:jar" do; jar_ran = true; end
         
     | 
| 
       53 
     | 
    
         
            -
                silence {  
     | 
| 
      
 62 
     | 
    
         
            +
                silence { run_task "warble" }
         
     | 
| 
       54 
63 
     | 
    
         
             
                files_ran.should == true
         
     | 
| 
       55 
64 
     | 
    
         
             
                jar_ran.should == true
         
     | 
| 
       56 
65 
     | 
    
         
             
              end
         
     | 
| 
       57 
66 
     | 
    
         | 
| 
       58 
67 
     | 
    
         
             
              it "should define a jar task for creating the .war" do
         
     | 
| 
       59 
68 
     | 
    
         
             
                touch "file.txt"
         
     | 
| 
       60 
     | 
    
         
            -
                 
     | 
| 
       61 
     | 
    
         
            -
                silence {  
     | 
| 
       62 
     | 
    
         
            -
                File.exist?("#{ 
     | 
| 
      
 69 
     | 
    
         
            +
                warble_task.jar.files["file.txt"] = "file.txt"
         
     | 
| 
      
 70 
     | 
    
         
            +
                silence { run_task "warble:jar" }
         
     | 
| 
      
 71 
     | 
    
         
            +
                File.exist?("#{config.jar_name}.war").should == true
         
     | 
| 
       63 
72 
     | 
    
         
             
              end
         
     | 
| 
       64 
73 
     | 
    
         | 
| 
       65 
74 
     | 
    
         
             
              it "should invoke feature tasks configured in config.features" do
         
     | 
| 
       66 
     | 
    
         
            -
                 
     | 
| 
       67 
     | 
    
         
            -
                silence {  
     | 
| 
       68 
     | 
    
         
            -
                 
     | 
| 
      
 75 
     | 
    
         
            +
                config.features << "gemjar"
         
     | 
| 
      
 76 
     | 
    
         
            +
                silence { run_task "warble" }
         
     | 
| 
      
 77 
     | 
    
         
            +
                warble_task.jar.files.keys.should include("WEB-INF/lib/gems.jar")
         
     | 
| 
       69 
78 
     | 
    
         
             
              end
         
     | 
| 
       70 
79 
     | 
    
         | 
| 
       71 
80 
     | 
    
         
             
              it "should warn and skip unknown features configured in config.features" do
         
     | 
| 
       72 
     | 
    
         
            -
                 
     | 
| 
       73 
     | 
    
         
            -
                capture {  
     | 
| 
      
 81 
     | 
    
         
            +
                config.features << "bogus"
         
     | 
| 
      
 82 
     | 
    
         
            +
                capture { run_task "warble" }.should =~ /unknown feature `bogus'/
         
     | 
| 
       74 
83 
     | 
    
         
             
              end
         
     | 
| 
       75 
84 
     | 
    
         | 
| 
       76 
85 
     | 
    
         
             
              it "should define an executable task for embedding a server in the war file" do
         
     | 
| 
       77 
     | 
    
         
            -
                silence {  
     | 
| 
       78 
     | 
    
         
            -
                 
     | 
| 
      
 86 
     | 
    
         
            +
                silence { run_task "warble:executable"; run_task "warble:files" }
         
     | 
| 
      
 87 
     | 
    
         
            +
                warble_task.jar.files.keys.should include('WEB-INF/winstone.jar')
         
     | 
| 
       79 
88 
     | 
    
         
             
              end
         
     | 
| 
       80 
89 
     | 
    
         | 
| 
       81 
90 
     | 
    
         
             
              it "should be able to define all tasks successfully" do
         
     | 
| 
       82 
     | 
    
         
            -
                Warbler::Task.new "warble",  
     | 
| 
      
 91 
     | 
    
         
            +
                Warbler::Task.new "warble", config
         
     | 
| 
       83 
92 
     | 
    
         
             
              end
         
     | 
| 
       84 
93 
     | 
    
         | 
| 
       85 
94 
     | 
    
         
             
              it "should compile any ruby files specified" do
         
     | 
| 
       86 
     | 
    
         
            -
                 
     | 
| 
       87 
     | 
    
         
            -
                silence {  
     | 
| 
      
 95 
     | 
    
         
            +
                config.features << "compiled"
         
     | 
| 
      
 96 
     | 
    
         
            +
                silence { run_task "warble" }
         
     | 
| 
       88 
97 
     | 
    
         | 
| 
       89 
98 
     | 
    
         
             
                java_class_magic_number = [0xCA,0xFE,0xBA,0xBE].map { |magic_char| magic_char.chr }.join
         
     | 
| 
       90 
99 
     | 
    
         | 
| 
       91 
     | 
    
         
            -
                Zip::ZipFile.open("#{ 
     | 
| 
      
 100 
     | 
    
         
            +
                Zip::ZipFile.open("#{config.jar_name}.war") do |zf|
         
     | 
| 
       92 
101 
     | 
    
         
             
                  java_class_header     = zf.get_input_stream('WEB-INF/app/helpers/application_helper.class') {|io| io.read }[0..3]
         
     | 
| 
       93 
102 
     | 
    
         
             
                  ruby_class_definition = zf.get_input_stream('WEB-INF/app/helpers/application_helper.rb') {|io| io.read }
         
     | 
| 
       94 
103 
     | 
    
         | 
| 
         @@ -97,11 +106,17 @@ describe Warbler::Task do 
     | 
|
| 
       97 
106 
     | 
    
         
             
                end
         
     | 
| 
       98 
107 
     | 
    
         
             
              end
         
     | 
| 
       99 
108 
     | 
    
         | 
| 
      
 109 
     | 
    
         
            +
              it "should delete .class files after finishing the jar" do
         
     | 
| 
      
 110 
     | 
    
         
            +
                config.features << "compiled"
         
     | 
| 
      
 111 
     | 
    
         
            +
                silence { run_task "warble" }
         
     | 
| 
      
 112 
     | 
    
         
            +
                File.exist?('app/helpers/application_helper.class').should be_false
         
     | 
| 
      
 113 
     | 
    
         
            +
              end
         
     | 
| 
      
 114 
     | 
    
         
            +
             
     | 
| 
       100 
115 
     | 
    
         
             
              it "should process symlinks by storing a file in the archive that has the same contents as the source" do
         
     | 
| 
       101 
116 
     | 
    
         
             
                File.open("config/special.txt", "wb") {|f| f << "special"}
         
     | 
| 
       102 
117 
     | 
    
         
             
                Dir.chdir("config") { ln_s "special.txt", "link.txt" }
         
     | 
| 
       103 
     | 
    
         
            -
                silence {  
     | 
| 
       104 
     | 
    
         
            -
                Zip::ZipFile.open("#{ 
     | 
| 
      
 118 
     | 
    
         
            +
                silence { run_task "warble" }
         
     | 
| 
      
 119 
     | 
    
         
            +
                Zip::ZipFile.open("#{config.jar_name}.war") do |zf|
         
     | 
| 
       105 
120 
     | 
    
         
             
                  special = zf.get_input_stream('WEB-INF/config/special.txt') {|io| io.read }
         
     | 
| 
       106 
121 
     | 
    
         
             
                  link = zf.get_input_stream('WEB-INF/config/link.txt') {|io| io.read }
         
     | 
| 
       107 
122 
     | 
    
         
             
                  link.should == special
         
     | 
| 
         @@ -110,8 +125,8 @@ describe Warbler::Task do 
     | 
|
| 
       110 
125 
     | 
    
         | 
| 
       111 
126 
     | 
    
         
             
              it "should process directory symlinks by copying the whole subdirectory" do
         
     | 
| 
       112 
127 
     | 
    
         
             
                Dir.chdir("lib") { ln_s "tasks", "rakelib" }
         
     | 
| 
       113 
     | 
    
         
            -
                silence {  
     | 
| 
       114 
     | 
    
         
            -
                Zip::ZipFile.open("#{ 
     | 
| 
      
 128 
     | 
    
         
            +
                silence { run_task "warble" }
         
     | 
| 
      
 129 
     | 
    
         
            +
                Zip::ZipFile.open("#{config.jar_name}.war") do |zf|
         
     | 
| 
       115 
130 
     | 
    
         
             
                  zf.find_entry("WEB-INF/lib/tasks/utils.rake").should_not be_nil
         
     | 
| 
       116 
131 
     | 
    
         
             
                  zf.find_entry("WEB-INF/lib/rakelib/").should_not be_nil
         
     | 
| 
       117 
132 
     | 
    
         
             
                  zf.find_entry("WEB-INF/lib/rakelib/utils.rake").should_not be_nil if defined?(JRUBY_VERSION)
         
     | 
| 
         @@ -120,17 +135,17 @@ describe Warbler::Task do 
     | 
|
| 
       120 
135 
     | 
    
         | 
| 
       121 
136 
     | 
    
         
             
              it "should use a Bundler Gemfile to include gems" do
         
     | 
| 
       122 
137 
     | 
    
         
             
                File.open("Gemfile", "w") {|f| f << "gem 'rspec'"}
         
     | 
| 
       123 
     | 
    
         
            -
                 
     | 
| 
       124 
     | 
    
         
            -
                 
     | 
| 
       125 
     | 
    
         
            -
             
     | 
| 
       126 
     | 
    
         
            -
                Zip::ZipFile.open("#{@config.war_name}.war") do |zf|
         
     | 
| 
       127 
     | 
    
         
            -
                  rspec_version = @config.gems.keys.detect {|k| k.name == 'rspec'}.version
         
     | 
| 
      
 138 
     | 
    
         
            +
                silence { run_task "warble" }
         
     | 
| 
      
 139 
     | 
    
         
            +
                Zip::ZipFile.open("#{config.jar_name}.war") do |zf|
         
     | 
| 
      
 140 
     | 
    
         
            +
                  rspec_version = config.gems.keys.detect {|k| k.name == 'rspec'}.version
         
     | 
| 
       128 
141 
     | 
    
         
             
                  zf.find_entry("WEB-INF/gems/specifications/rspec-#{rspec_version}.gemspec").should_not be_nil
         
     | 
| 
       129 
142 
     | 
    
         
             
                end
         
     | 
| 
       130 
143 
     | 
    
         
             
              end
         
     | 
| 
       131 
144 
     | 
    
         
             
            end
         
     | 
| 
       132 
145 
     | 
    
         | 
| 
       133 
146 
     | 
    
         
             
            describe "Debug targets" do
         
     | 
| 
      
 147 
     | 
    
         
            +
              run_in_directory "spec/sample_war"
         
     | 
| 
      
 148 
     | 
    
         
            +
             
     | 
| 
       134 
149 
     | 
    
         
             
              before(:each) do
         
     | 
| 
       135 
150 
     | 
    
         
             
                @rake = Rake::Application.new
         
     | 
| 
       136 
151 
     | 
    
         
             
                Rake.application = @rake
         
     | 
| 
         @@ -0,0 +1,16 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            #--
         
     | 
| 
      
 2 
     | 
    
         
            +
            # Copyright (c) 2010 Engine Yard, Inc.
         
     | 
| 
      
 3 
     | 
    
         
            +
            # This source code is available under the MIT license.
         
     | 
| 
      
 4 
     | 
    
         
            +
            # See the file LICENSE.txt for details.
         
     | 
| 
      
 5 
     | 
    
         
            +
            #++
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
      
 7 
     | 
    
         
            +
            require File.dirname(__FILE__) + '/../spec_helper'
         
     | 
| 
      
 8 
     | 
    
         
            +
             
     | 
| 
      
 9 
     | 
    
         
            +
            describe Warbler::Traits do
         
     | 
| 
      
 10 
     | 
    
         
            +
              it "are ordered by fewer dependencies first" do
         
     | 
| 
      
 11 
     | 
    
         
            +
                traits = [Warbler::Traits::War, Warbler::Traits::Bundler, Warbler::Traits::Rails]
         
     | 
| 
      
 12 
     | 
    
         
            +
                result = traits.shuffle.sort
         
     | 
| 
      
 13 
     | 
    
         
            +
                result.index(Warbler::Traits::War).should < result.index(Warbler::Traits::Bundler)
         
     | 
| 
      
 14 
     | 
    
         
            +
                result.index(Warbler::Traits::War).should < result.index(Warbler::Traits::Rails)
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
            end
         
     |