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.
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
@@ -0,0 +1,191 @@
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 'ostruct'
8
+
9
+ module Warbler
10
+ module Traits
11
+ # The War trait sets up the layout and generates web.xml for the war project.
12
+ class War
13
+ include Trait
14
+
15
+ DEFAULT_GEM_PATH = '/WEB-INF/gems'
16
+
17
+ def self.detect?
18
+ Traits::Rails.detect? || Traits::Merb.detect? || Traits::Rack.detect?
19
+ end
20
+
21
+ def before_configure
22
+ config.gem_path = DEFAULT_GEM_PATH
23
+ config.pathmaps = default_pathmaps
24
+ config.webxml = default_webxml_config
25
+ config.webinf_files = default_webinf_files
26
+ config.java_libs = default_jar_files
27
+ config.public_html = FileList["public/**/*"]
28
+ config.jar_extension = 'war'
29
+ end
30
+
31
+ def after_configure
32
+ update_gem_path(DEFAULT_GEM_PATH)
33
+ end
34
+
35
+ def default_pathmaps
36
+ p = OpenStruct.new
37
+ p.public_html = ["%{public/,}p"]
38
+ p.java_libs = ["WEB-INF/lib/%f"]
39
+ p.java_classes = ["WEB-INF/classes/%p"]
40
+ p.application = ["WEB-INF/%p"]
41
+ p.webinf = ["WEB-INF/%{.erb$,}f"]
42
+ p.gemspecs = ["#{config.relative_gem_path}/specifications/%f"]
43
+ p.gems = ["#{config.relative_gem_path}/gems/%p"]
44
+ p
45
+ end
46
+
47
+ def default_webxml_config
48
+ c = WebxmlOpenStruct.new
49
+ c.rails.env = ENV['RAILS_ENV'] || 'production'
50
+ c.public.root = '/'
51
+ c.jndi = nil
52
+ c.ignored = %w(jndi booter)
53
+ c
54
+ end
55
+
56
+ def default_webinf_files
57
+ webxml = if File.exist?("config/web.xml")
58
+ "config/web.xml"
59
+ elsif File.exist?("config/web.xml.erb")
60
+ "config/web.xml.erb"
61
+ else
62
+ "#{WARBLER_HOME}/web.xml.erb"
63
+ end
64
+ FileList[webxml]
65
+ end
66
+
67
+ def default_jar_files
68
+ require 'jruby-jars'
69
+ require 'jruby-rack'
70
+ FileList[JRubyJars.core_jar_path, JRubyJars.stdlib_jar_path, JRubyJars.jruby_rack_jar_path]
71
+ end
72
+
73
+ def update_archive(jar)
74
+ add_public_files(jar)
75
+ add_webxml(jar)
76
+ add_executables(jar) if config.features.include?("executable")
77
+ add_gemjar(jar) if config.features.include?("gemjar")
78
+ end
79
+
80
+ # Add public/static assets to the root of the war file.
81
+ def add_public_files(jar)
82
+ config.public_html.map {|f| jar.add_with_pathmaps(config, f, :public_html) }
83
+ end
84
+
85
+ # Add web.xml and other WEB-INF configuration files from
86
+ # config.webinf_files to the war file.
87
+ def add_webxml(jar)
88
+ config.webinf_files.each do |wf|
89
+ if wf =~ /\.erb$/
90
+ jar.files[jar.apply_pathmaps(config, wf, :webinf)] = jar.expand_erb(wf, config)
91
+ else
92
+ jar.files[jar.apply_pathmaps(config, wf, :webinf)] = wf
93
+ end
94
+ end
95
+ end
96
+
97
+ def add_executables(jar)
98
+ winstone_type = ENV["WINSTONE"] || "winstone-lite"
99
+ winstone_version = ENV["WINSTONE_VERSION"] || "0.9.10"
100
+ winstone_path = "net/sourceforge/winstone/#{winstone_type}/#{winstone_version}/#{winstone_type}-#{winstone_version}.jar"
101
+ winstone_jar = File.expand_path("~/.m2/repository/#{winstone_path}")
102
+ unless File.exist?(winstone_jar)
103
+ # Not always covered in tests as these lines may not get
104
+ # executed every time if the jar is cached.
105
+ puts "Downloading #{winstone_type}.jar" #:nocov:
106
+ mkdir_p File.dirname(t.name) #:nocov:
107
+ require 'open-uri' #:nocov:
108
+ maven_repo = ENV["MAVEN_REPO"] || "http://repo2.maven.org/maven2" #:nocov:
109
+ open("#{maven_repo}/#{winstone_path}") do |stream| #:nocov:
110
+ File.open(t.name, "wb") do |f| #:nocov:
111
+ while buf = stream.read(4096) #:nocov:
112
+ f << buf #:nocov:
113
+ end #:nocov:
114
+ end #:nocov:
115
+ end #:nocov:
116
+ end
117
+
118
+ jar.files['META-INF/MANIFEST.MF'] = StringIO.new(Warbler::Jar::DEFAULT_MANIFEST.chomp + "Main-Class: WarMain\n")
119
+ jar.files['WarMain.class'] = jar.entry_in_jar("#{WARBLER_HOME}/lib/warbler_jar.jar", 'WarMain.class')
120
+ jar.files['WEB-INF/winstone.jar'] = winstone_jar
121
+ end
122
+
123
+ def add_gemjar(jar)
124
+ gem_jar = Warbler::Jar.new
125
+ gem_path = Regexp::quote(config.relative_gem_path)
126
+ gems = jar.files.select{|k,v| k =~ %r{#{gem_path}/} }
127
+ gems.each do |k,v|
128
+ gem_jar.files[k.sub(%r{#{gem_path}/}, '')] = v
129
+ end
130
+ jar.files["WEB-INF/lib/gems.jar"] = "tmp/gems.jar"
131
+ jar.files.reject!{|k,v| k =~ /#{gem_path}/ || k == "WEB-INF/tmp/gems.jar"}
132
+ mkdir_p "tmp"
133
+ gem_jar.add_manifest
134
+ gem_jar.create("tmp/gems.jar")
135
+ end
136
+
137
+ # Helper class for holding arbitrary config.webxml values for injecting into +web.xml+.
138
+ class WebxmlOpenStruct < OpenStruct
139
+ %w(java com org javax gem).each {|name| undef_method name if Object.methods.include?(name) }
140
+
141
+ def initialize(key = 'webxml')
142
+ @key = key
143
+ @table = Hash.new {|h,k| h[k] = WebxmlOpenStruct.new(k) }
144
+ end
145
+
146
+ def servlet_context_listener
147
+ case self.booter
148
+ when :rack
149
+ "org.jruby.rack.RackServletContextListener"
150
+ when :merb
151
+ "org.jruby.rack.merb.MerbServletContextListener"
152
+ else # :rails, default
153
+ "org.jruby.rack.rails.RailsServletContextListener"
154
+ end
155
+ end
156
+
157
+ def [](key)
158
+ new_ostruct_member(key)
159
+ send(key)
160
+ end
161
+
162
+ def []=(key, value)
163
+ new_ostruct_member(key)
164
+ send("#{key}=", value)
165
+ end
166
+
167
+ def context_params(escape = true)
168
+ require 'cgi'
169
+ params = {}
170
+ @table.each do |k,v|
171
+ case v
172
+ when WebxmlOpenStruct
173
+ nested_params = v.context_params
174
+ nested_params.each do |nk,nv|
175
+ params["#{escape ? CGI::escapeHTML(k.to_s) : k.to_s}.#{nk}"] = nv
176
+ end
177
+ else
178
+ params[escape ? CGI::escapeHTML(k.to_s) : k.to_s] = escape ? CGI::escapeHTML(v.to_s) : v.to_s
179
+ end
180
+ end
181
+ params.delete_if {|k,v| ['ignored', *ignored].include?(k.to_s) }
182
+ params
183
+ end
184
+
185
+ def to_s
186
+ "No value for '#@key' found"
187
+ end
188
+ end
189
+ end
190
+ end
191
+ end
@@ -0,0 +1,105 @@
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 'stringio'
8
+
9
+ module Warbler
10
+ # Traits are project configuration characteristics that correspond
11
+ # to the framework or project layout. Each trait corresponds to a
12
+ # class in Warbler::Traits that contains baked-in knowledge about
13
+ # the kind of project and how it should be packed into the jar or
14
+ # war file.
15
+ module Traits
16
+ attr_accessor :traits
17
+
18
+ def initialize
19
+ @traits = auto_detect_traits
20
+ end
21
+
22
+ def auto_detect_traits
23
+ Traits.constants.map {|t| Traits.const_get(t)}.select {|tc| tc.detect? }.sort
24
+ end
25
+
26
+ def before_configure
27
+ trait_objects.each {|t| t.before_configure }
28
+ end
29
+
30
+ def after_configure
31
+ trait_objects.each {|t| t.after_configure }
32
+ end
33
+
34
+ def trait_objects
35
+ @trait_objects ||= @traits.map {|klass| klass.new(self) }
36
+ end
37
+
38
+ def update_archive(jar)
39
+ trait_objects.each {|t| t.update_archive(jar) }
40
+ end
41
+
42
+ def dump_traits
43
+ @trait_objects = nil
44
+ @traits.collect! {|t| t.name }
45
+ end
46
+ end
47
+
48
+ # Each trait class includes this module to receive shared functionality.
49
+ module Trait
50
+ module ClassMethods
51
+ def <=>(o)
52
+ requires?(o) ? 1 : (o.requires?(self) ? -1 : 0)
53
+ end
54
+
55
+ def requires?(t)
56
+ false
57
+ end
58
+ end
59
+
60
+ def self.included(base)
61
+ base.extend ClassMethods
62
+ end
63
+
64
+ attr_reader :config
65
+ def initialize(config)
66
+ @config = config
67
+ end
68
+
69
+ def before_configure
70
+ end
71
+
72
+ def after_configure
73
+ end
74
+
75
+ def update_archive(jar)
76
+ end
77
+
78
+ def add_init_load_path(path)
79
+ config.init_contents << StringIO.new("$LOAD_PATH.unshift __FILE__.sub(/!.*/, '!/#{path}')\n")
80
+ end
81
+
82
+ def add_main_rb(jar, bin_path)
83
+ jar.files['META-INF/main.rb'] = StringIO.new("load '#{bin_path}'")
84
+ end
85
+
86
+ def update_gem_path(default_gem_path)
87
+ if config.gem_path != default_gem_path
88
+ config.gem_path = "/#{config.gem_path}" unless config.gem_path =~ %r{^/}
89
+ sub_gem_path = config.gem_path[1..-1]
90
+ config.pathmaps.gemspecs.each {|p| p.sub!(default_gem_path[1..-1], sub_gem_path)}
91
+ config.pathmaps.gems.each {|p| p.sub!(default_gem_path[1..-1], sub_gem_path)}
92
+ config.webxml["gem"]["path"] = config.gem_path if config.webxml
93
+ end
94
+ end
95
+ end
96
+ end
97
+
98
+ require 'warbler/traits/jar'
99
+ require 'warbler/traits/war'
100
+ require 'warbler/traits/rails'
101
+ require 'warbler/traits/merb'
102
+ require 'warbler/traits/rack'
103
+ require 'warbler/traits/bundler'
104
+ require 'warbler/traits/gemspec'
105
+ require 'warbler/traits/nogemspec'
@@ -6,5 +6,5 @@
6
6
  #++
7
7
 
8
8
  module Warbler
9
- VERSION = "1.2.1"
9
+ VERSION = "1.3.0.beta1"
10
10
  end
data/lib/warbler/war.rb CHANGED
@@ -1,247 +1 @@
1
- require 'zip/zip'
2
-
3
- module Warbler
4
- # Class that holds the files that will be stored in the war file.
5
- # The #files attribute contains a hash of pathnames inside the war
6
- # file to their contents. Contents can be one of:
7
- # * +nil+ representing a directory entry
8
- # * Any object responding to +read+ representing an in-memory blob
9
- # * A String filename pointing to a file on disk
10
- class War
11
- DEFAULT_MANIFEST = %{Manifest-Version: 1.0\nCreated-By: Warbler #{Warbler::VERSION}\n\n}
12
-
13
- attr_reader :files
14
- attr_reader :webinf_filelist
15
-
16
- def initialize
17
- @files = {}
18
- end
19
-
20
- def compile(config)
21
- # Compiling all Ruby files we can find -- do we need to allow an
22
- # option to configure what gets compiled?
23
- return if config.compiled_ruby_files.nil? || config.compiled_ruby_files.empty?
24
-
25
- run_javac(config, config.compiled_ruby_files)
26
- replace_compiled_ruby_files(config, config.compiled_ruby_files)
27
- end
28
-
29
- def run_javac(config, compiled_ruby_files)
30
- # Need to use the version of JRuby in the application to compile it
31
- %x{java -classpath #{config.java_libs.join(File::PATH_SEPARATOR)} org.jruby.Main -S jrubyc \"#{compiled_ruby_files.join('" "')}\"}
32
- end
33
-
34
- def replace_compiled_ruby_files(config, compiled_ruby_files)
35
- # Exclude the rb files and recreate them. This
36
- # prevents the original contents being used.
37
- config.excludes += compiled_ruby_files
38
-
39
- compiled_ruby_files.each do |ruby_source|
40
- files[apply_pathmaps(config, ruby_source, :application)] = StringIO.new("require __FILE__.sub(/\.rb$/, '.class')")
41
- end
42
- end
43
-
44
- # Apply the information in a Warbler::Config object in order to
45
- # look for files to put into this war file.
46
- def apply(config)
47
- find_webinf_files(config)
48
- find_java_libs(config)
49
- find_java_classes(config)
50
- find_gems_files(config)
51
- find_public_files(config)
52
- add_webxml(config)
53
- add_manifest(config)
54
- add_bundler_files(config)
55
- add_init_file(config)
56
- end
57
-
58
- # Create the war file. The single argument can either be a
59
- # Warbler::Config or a filename of the war file to create.
60
- def create(config_or_path)
61
- war_path = config_or_path
62
- if Warbler::Config === config_or_path
63
- war_path = "#{config_or_path.war_name}.war"
64
- war_path = File.join(config_or_path.autodeploy_dir, war_path) if config_or_path.autodeploy_dir
65
- end
66
- rm_f war_path
67
- ensure_directory_entries
68
- puts "Creating #{war_path}"
69
- create_war war_path, @files
70
- end
71
-
72
- # Add web.xml and other WEB-INF configuration files from
73
- # config.webinf_files to the war file.
74
- def add_webxml(config)
75
- config.webinf_files.each do |wf|
76
- if wf =~ /\.erb$/
77
- @files[apply_pathmaps(config, wf, :webinf)] = expand_erb(wf, config)
78
- else
79
- @files[apply_pathmaps(config, wf, :webinf)] = wf
80
- end
81
- end
82
- end
83
-
84
- # Add a manifest file either from config or by making a default manifest.
85
- def add_manifest(config = nil)
86
- unless @files.keys.detect{|k| k =~ /^META-INF\/MANIFEST\.MF$/i}
87
- if config && config.manifest_file
88
- @files['META-INF/MANIFEST.MF'] = config.manifest_file
89
- else
90
- @files['META-INF/MANIFEST.MF'] = StringIO.new(DEFAULT_MANIFEST)
91
- end
92
- end
93
- end
94
-
95
- # Add java libraries to WEB-INF/lib.
96
- def find_java_libs(config)
97
- config.java_libs.map {|lib| add_with_pathmaps(config, lib, :java_libs) }
98
- end
99
-
100
- # Add java classes to WEB-INF/classes.
101
- def find_java_classes(config)
102
- config.java_classes.map {|f| add_with_pathmaps(config, f, :java_classes) }
103
- end
104
-
105
- # Add public/static assets to the root of the war file.
106
- def find_public_files(config)
107
- config.public_html.map {|f| add_with_pathmaps(config, f, :public_html) }
108
- end
109
-
110
- # Add gems to WEB-INF/gems
111
- def find_gems_files(config)
112
- config.gems.each {|gem, version| find_single_gem_files(config, gem, version) }
113
- end
114
-
115
- # Add a single gem to WEB-INF/gems
116
- def find_single_gem_files(config, gem_pattern, version = nil)
117
- if Gem::Specification === gem_pattern
118
- spec = gem_pattern
119
- else
120
- gem = case gem_pattern
121
- when Gem::Dependency
122
- gem_pattern
123
- else
124
- Gem::Dependency.new(gem_pattern, Gem::Requirement.create(version))
125
- end
126
-
127
- # skip development dependencies
128
- return if gem.respond_to?(:type) and gem.type != :runtime
129
-
130
- matched = Gem.source_index.search(gem)
131
- fail "gem '#{gem}' not installed" if matched.empty?
132
- spec = matched.last
133
- end
134
-
135
- # skip gems with no load path
136
- return if spec.loaded_from == ""
137
-
138
- add_with_pathmaps(config, spec.loaded_from, :gemspecs)
139
- spec.files.each do |f|
140
- next if config.gem_excludes && config.gem_excludes.any? {|rx| f =~ rx }
141
- src = File.join(spec.full_gem_path, f)
142
- # some gemspecs may have incorrect file listings
143
- next unless File.exist?(src)
144
- @files[apply_pathmaps(config, File.join(spec.full_name, f), :gems)] = src
145
- end
146
-
147
- spec.dependencies.each {|dep| find_single_gem_files(config, dep) } if config.gem_dependencies
148
- end
149
-
150
- # Add all application directories and files to WEB-INF.
151
- def find_webinf_files(config)
152
- config.dirs.select do |d|
153
- exists = File.directory?(d)
154
- warn "warning: application directory `#{d}' does not exist or is not a directory; skipping" unless exists
155
- exists
156
- end.each do |d|
157
- @files[apply_pathmaps(config, d, :application)] = nil
158
- end
159
- @webinf_filelist = FileList[*(config.dirs.map{|d| "#{d}/**/*"})]
160
- @webinf_filelist.include *(config.includes.to_a)
161
- @webinf_filelist.exclude *(config.excludes.to_a)
162
- @webinf_filelist.map {|f| add_with_pathmaps(config, f, :application) }
163
- end
164
-
165
- # Add Bundler Gemfiles to the war file.
166
- def add_bundler_files(config)
167
- if config.bundler
168
- @files[apply_pathmaps(config, 'Gemfile', :application)] = 'Gemfile'
169
- if File.exist?('Gemfile.lock')
170
- @files[apply_pathmaps(config, 'Gemfile.lock', :application)] = 'Gemfile.lock'
171
- end
172
- end
173
- end
174
-
175
- # Add init.rb file to the war file.
176
- def add_init_file(config)
177
- if config.init_contents
178
- contents = ''
179
- config.init_contents.each do |file|
180
- if file.respond_to?(:read)
181
- contents << file.read
182
- elsif File.extname(file) == '.erb'
183
- contents << expand_erb(file, config).read
184
- else
185
- contents << File.read(file)
186
- end
187
- end
188
- @files[config.init_filename] = StringIO.new(contents)
189
- end
190
- end
191
-
192
- private
193
- def add_with_pathmaps(config, f, map_type)
194
- @files[apply_pathmaps(config, f, map_type)] = f
195
- end
196
-
197
- def expand_erb(file, config)
198
- require 'erb'
199
- erb = ERB.new(File.open(file) {|f| f.read })
200
- StringIO.new(erb.result(erb_binding(config.webxml)))
201
- end
202
-
203
- def erb_binding(webxml)
204
- binding
205
- end
206
-
207
- def apply_pathmaps(config, file, pathmaps)
208
- pathmaps = config.pathmaps.send(pathmaps)
209
- pathmaps.each do |p|
210
- file = file.pathmap(p)
211
- end if pathmaps
212
- file
213
- end
214
-
215
- def ensure_directory_entries
216
- files.select {|k,v| !v.nil? }.each do |k,v|
217
- dir = File.dirname(k)
218
- while dir != "." && !files.has_key?(dir)
219
- files[dir] = nil
220
- dir = File.dirname(dir)
221
- end
222
- end
223
- end
224
-
225
- def create_war(war_file, entries)
226
- Zip::ZipFile.open(war_file, Zip::ZipFile::CREATE) do |zipfile|
227
- entries.keys.sort.each do |entry|
228
- src = entries[entry]
229
- if src.respond_to?(:read)
230
- zipfile.get_output_stream(entry) {|f| f << src.read }
231
- elsif src.nil? || File.directory?(src)
232
- warn "directory symlinks are not followed unless using JRuby; #{entry} contents not in archive" \
233
- if File.symlink?(entry) && !defined?(JRUBY_VERSION)
234
- zipfile.mkdir(entry)
235
- elsif File.symlink?(src)
236
- zipfile.get_output_stream(entry) {|f| f << File.read(src) }
237
- else
238
- zipfile.add(entry, src)
239
- end
240
- end
241
- end
242
- end
243
-
244
- # Java-boosted war creation for JRuby; replaces #create_war with Java version
245
- require 'warbler_war' if defined?(JRUBY_VERSION) && JRUBY_VERSION >= "1.5"
246
- end
247
- end
1
+ require 'warbler/jar'
data/lib/warbler.rb CHANGED
@@ -5,8 +5,8 @@
5
5
  # See the file LICENSE.txt for details.
6
6
  #++
7
7
 
8
- # Warbler is a lightweight, flexible, Rake-based system for packaging your Rails apps
9
- # into .war files.
8
+ # Warbler is a lightweight, flexible, Rake-based system for packaging
9
+ # your Ruby applications into .jar or .war files.
10
10
  module Warbler
11
11
  WARBLER_HOME = File.expand_path(File.dirname(__FILE__) + '/..') unless defined?(WARBLER_HOME)
12
12
 
@@ -29,8 +29,5 @@ module Warbler
29
29
  end
30
30
 
31
31
  require 'warbler/version'
32
- require 'warbler/gems'
33
- require 'warbler/config'
34
- require 'warbler/war'
35
32
  require 'warbler/task'
36
33
  require 'warbler/application'
Binary file
@@ -0,0 +1,6 @@
1
+ === 1.0.0 / 2010-11-03
2
+
3
+ * 1 major enhancement
4
+
5
+ * Birthday!
6
+
@@ -0,0 +1,8 @@
1
+ .autotest
2
+ History.txt
3
+ Manifest.txt
4
+ README.txt
5
+ Rakefile
6
+ bin/sample_jar
7
+ lib/sample_jar.rb
8
+ test/test_sample_jar.rb
@@ -0,0 +1,30 @@
1
+ = sample_jar
2
+
3
+ == DESCRIPTION:
4
+
5
+ Sample jar application for Warbler specs.
6
+
7
+ == LICENSE:
8
+
9
+ (The MIT License)
10
+
11
+ Copyright (c) 2010 Nick Sieger
12
+
13
+ Permission is hereby granted, free of charge, to any person obtaining
14
+ a copy of this software and associated documentation files (the
15
+ 'Software'), to deal in the Software without restriction, including
16
+ without limitation the rights to use, copy, modify, merge, publish,
17
+ distribute, sublicense, and/or sell copies of the Software, and to
18
+ permit persons to whom the Software is furnished to do so, subject to
19
+ the following conditions:
20
+
21
+ The above copyright notice and this permission notice shall be
22
+ included in all copies or substantial portions of the Software.
23
+
24
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
25
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
27
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
28
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
29
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
30
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,6 @@
1
+ class SampleJar
2
+ VERSION = '1.0.0'
3
+ def self.hello
4
+ puts "Hello World!"
5
+ end
6
+ end
@@ -0,0 +1,41 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{sample_jar}
5
+ s.version = "1.0.0"
6
+
7
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
+ s.authors = ["Nick Sieger"]
9
+ s.date = %q{2010-11-03}
10
+ s.default_executable = %q{sample_jar}
11
+ s.description = %q{Sample jar application for Warbler specs.}
12
+ s.email = ["nick@nicksieger.com"]
13
+ s.executables = ["sample_jar"]
14
+ s.extra_rdoc_files = ["History.txt", "Manifest.txt", "README.txt"]
15
+ s.files = ["History.txt", "Manifest.txt", "README.txt", "Rakefile", "bin/sample_jar", "lib/sample_jar.rb", "test/test_sample_jar.rb"]
16
+ s.rdoc_options = ["--main", "README.txt"]
17
+ s.require_paths = ["lib"]
18
+ s.rubyforge_project = %q{sample_jar}
19
+ s.rubygems_version = %q{1.3.7}
20
+ s.summary = %q{Sample jar application for Warbler specs.}
21
+ s.test_files = ["test/test_sample_jar.rb"]
22
+
23
+ if s.respond_to? :specification_version then
24
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
25
+ s.specification_version = 3
26
+
27
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
28
+ s.add_runtime_dependency(%q<rubyzip>, [">= 0"])
29
+ s.add_development_dependency(%q<rubyforge>, [">= 2.0.4"])
30
+ s.add_development_dependency(%q<hoe>, [">= 2.6.2"])
31
+ else
32
+ s.add_dependency(%q<rubyzip>, [">= 0"])
33
+ s.add_dependency(%q<rubyforge>, [">= 2.0.4"])
34
+ s.add_dependency(%q<hoe>, [">= 2.6.2"])
35
+ end
36
+ else
37
+ s.add_dependency(%q<rubyzip>, [">= 0"])
38
+ s.add_dependency(%q<rubyforge>, [">= 2.0.4"])
39
+ s.add_dependency(%q<hoe>, [">= 2.6.2"])
40
+ end
41
+ end
@@ -0,0 +1,8 @@
1
+ require "test/unit"
2
+ require "sample_jar"
3
+
4
+ class TestSampleJar < Test::Unit::TestCase
5
+ def test_sanity
6
+ SampleJar.hello
7
+ end
8
+ end
File without changes
File without changes
File without changes