warbler 1.3.8 → 1.4.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (110) hide show
  1. data/.gitignore +1 -0
  2. data/.travis.yml +3 -0
  3. data/Gemfile +1 -1
  4. data/History.txt +14 -0
  5. data/README.rdoc +13 -0
  6. data/ext/WarMain.java +34 -17
  7. data/ext/WarblerJar.java +3 -2
  8. data/integration/gem-initializer/pom.xml +39 -0
  9. data/integration/pom.xml +134 -0
  10. data/integration/rails4_test/pom.xml +57 -0
  11. data/integration/rails4_test/src/main/ruby/Gemfile +44 -0
  12. data/integration/rails4_test/src/main/ruby/README.rdoc +28 -0
  13. data/integration/rails4_test/src/main/ruby/Rakefile +6 -0
  14. data/integration/rails4_test/src/main/ruby/app/assets/javascripts/application.js +16 -0
  15. data/integration/rails4_test/src/main/ruby/app/assets/javascripts/posts.js.coffee +3 -0
  16. data/integration/rails4_test/src/main/ruby/app/assets/stylesheets/application.css +13 -0
  17. data/integration/rails4_test/src/main/ruby/app/assets/stylesheets/posts.css.scss +3 -0
  18. data/integration/rails4_test/src/main/ruby/app/assets/stylesheets/scaffolds.css.scss +69 -0
  19. data/integration/rails4_test/src/main/ruby/app/controllers/application_controller.rb +5 -0
  20. data/integration/rails4_test/src/main/ruby/app/controllers/concerns/.keep +0 -0
  21. data/integration/rails4_test/src/main/ruby/app/controllers/posts_controller.rb +74 -0
  22. data/integration/rails4_test/src/main/ruby/app/helpers/application_helper.rb +2 -0
  23. data/integration/rails4_test/src/main/ruby/app/helpers/posts_helper.rb +2 -0
  24. data/integration/rails4_test/src/main/ruby/app/mailers/.keep +0 -0
  25. data/integration/rails4_test/src/main/ruby/app/models/.keep +0 -0
  26. data/integration/rails4_test/src/main/ruby/app/models/concerns/.keep +0 -0
  27. data/integration/rails4_test/src/main/ruby/app/models/post.rb +2 -0
  28. data/integration/rails4_test/src/main/ruby/app/views/layouts/application.html.erb +14 -0
  29. data/integration/rails4_test/src/main/ruby/app/views/posts/_form.html.erb +29 -0
  30. data/integration/rails4_test/src/main/ruby/app/views/posts/edit.html.erb +6 -0
  31. data/integration/rails4_test/src/main/ruby/app/views/posts/index.html.erb +31 -0
  32. data/integration/rails4_test/src/main/ruby/app/views/posts/index.json.jbuilder +4 -0
  33. data/integration/rails4_test/src/main/ruby/app/views/posts/new.html.erb +5 -0
  34. data/integration/rails4_test/src/main/ruby/app/views/posts/show.html.erb +19 -0
  35. data/integration/rails4_test/src/main/ruby/app/views/posts/show.json.jbuilder +1 -0
  36. data/integration/rails4_test/src/main/ruby/config.ru +4 -0
  37. data/integration/rails4_test/src/main/ruby/config/application.rb +23 -0
  38. data/integration/rails4_test/src/main/ruby/config/boot.rb +4 -0
  39. data/integration/rails4_test/src/main/ruby/config/database.yml +20 -0
  40. data/integration/rails4_test/src/main/ruby/config/environment.rb +5 -0
  41. data/integration/rails4_test/src/main/ruby/config/environments/development.rb +29 -0
  42. data/integration/rails4_test/src/main/ruby/config/environments/production.rb +80 -0
  43. data/integration/rails4_test/src/main/ruby/config/environments/test.rb +36 -0
  44. data/integration/rails4_test/src/main/ruby/config/initializers/backtrace_silencers.rb +7 -0
  45. data/integration/rails4_test/src/main/ruby/config/initializers/filter_parameter_logging.rb +4 -0
  46. data/integration/rails4_test/src/main/ruby/config/initializers/inflections.rb +16 -0
  47. data/integration/rails4_test/src/main/ruby/config/initializers/mime_types.rb +5 -0
  48. data/integration/rails4_test/src/main/ruby/config/initializers/secret_token.rb +12 -0
  49. data/integration/rails4_test/src/main/ruby/config/initializers/session_store.rb +3 -0
  50. data/integration/rails4_test/src/main/ruby/config/initializers/wrap_parameters.rb +14 -0
  51. data/integration/rails4_test/src/main/ruby/config/locales/en.yml +23 -0
  52. data/integration/rails4_test/src/main/ruby/config/routes.rb +51 -0
  53. data/integration/rails4_test/src/main/ruby/config/warble.rb +4 -0
  54. data/integration/rails4_test/src/main/ruby/db/development.sqlite3 +0 -0
  55. data/integration/rails4_test/src/main/ruby/db/migrate/20130502003552_create_posts.rb +11 -0
  56. data/integration/rails4_test/src/main/ruby/db/production.sqlite3 +0 -0
  57. data/integration/rails4_test/src/main/ruby/db/schema.rb +24 -0
  58. data/integration/rails4_test/src/main/ruby/db/seeds.rb +7 -0
  59. data/integration/rails4_test/src/main/ruby/lib/assets/.keep +0 -0
  60. data/integration/rails4_test/src/main/ruby/lib/tasks/.keep +0 -0
  61. data/integration/rails4_test/src/main/ruby/public/404.html +58 -0
  62. data/integration/rails4_test/src/main/ruby/public/422.html +58 -0
  63. data/integration/rails4_test/src/main/ruby/public/500.html +57 -0
  64. data/integration/rails4_test/src/main/ruby/public/favicon.ico +0 -0
  65. data/integration/rails4_test/src/main/ruby/public/robots.txt +5 -0
  66. data/integration/rails4_test/src/main/ruby/test/controllers/.keep +0 -0
  67. data/integration/rails4_test/src/main/ruby/test/controllers/posts_controller_test.rb +49 -0
  68. data/integration/rails4_test/src/main/ruby/test/fixtures/.keep +0 -0
  69. data/integration/rails4_test/src/main/ruby/test/fixtures/posts.yml +11 -0
  70. data/integration/rails4_test/src/main/ruby/test/helpers/.keep +0 -0
  71. data/integration/rails4_test/src/main/ruby/test/helpers/posts_helper_test.rb +4 -0
  72. data/integration/rails4_test/src/main/ruby/test/integration/.keep +0 -0
  73. data/integration/rails4_test/src/main/ruby/test/mailers/.keep +0 -0
  74. data/integration/rails4_test/src/main/ruby/test/models/.keep +0 -0
  75. data/integration/rails4_test/src/main/ruby/test/models/post_test.rb +7 -0
  76. data/integration/rails4_test/src/main/ruby/test/test_helper.rb +15 -0
  77. data/integration/rails4_test/src/main/ruby/vendor/assets/javascripts/.keep +0 -0
  78. data/integration/rails4_test/src/main/ruby/vendor/assets/stylesheets/.keep +0 -0
  79. data/integration/rails4_test/src/test/java/org/jruby/warbler/Rails4AppTestIT.java +37 -0
  80. data/integration/runnable_test/pom.xml +105 -0
  81. data/integration/runnable_test/src/main/ruby/Rakefile +4 -0
  82. data/integration/runnable_test/src/main/ruby/config.ru +1 -0
  83. data/integration/runnable_test/src/main/ruby/config/warble.rb +9 -0
  84. data/integration/runnable_test/src/test/java/org/jruby/warbler/RunnableWarTestIT.java +22 -0
  85. data/integration/simple_rack_test/pom.xml +56 -0
  86. data/integration/simple_rack_test/src/main/ruby/config.ru +1 -0
  87. data/integration/simple_rack_test/src/main/ruby/config/warble.rb +4 -0
  88. data/integration/simple_rack_test/src/test/java/org/jruby/warbler/AppTestIT.java +36 -0
  89. data/lib/warbler.rb +2 -1
  90. data/lib/warbler/application.rb +5 -1
  91. data/lib/warbler/config.rb +15 -2
  92. data/lib/warbler/executable_helper.rb +25 -0
  93. data/lib/warbler/gems.rb +39 -0
  94. data/lib/warbler/jar.rb +11 -25
  95. data/lib/warbler/scripts/rails.rb +11 -0
  96. data/lib/warbler/templates/war.erb +10 -2
  97. data/lib/warbler/traits.rb +5 -2
  98. data/lib/warbler/traits/gemspec.rb +13 -4
  99. data/lib/warbler/traits/nogemspec.rb +2 -1
  100. data/lib/warbler/traits/rails.rb +25 -7
  101. data/lib/warbler/version.rb +1 -1
  102. data/lib/warbler_jar.jar +0 -0
  103. data/spec/sample_jar/bin/another_jar +5 -0
  104. data/spec/spec_helper.rb +2 -2
  105. data/spec/warbler/bundler_spec.rb +18 -33
  106. data/spec/warbler/config_spec.rb +2 -2
  107. data/spec/warbler/jar_spec.rb +176 -40
  108. data/warble.rb +9 -2
  109. data/warbler.gemspec +2 -2
  110. metadata +175 -9
data/lib/warbler.rb CHANGED
@@ -10,7 +10,7 @@
10
10
  module Warbler
11
11
  WARBLER_HOME = File.expand_path(File.dirname(__FILE__) + '/..') unless defined?(WARBLER_HOME)
12
12
  WARBLER_JAR = "#{WARBLER_HOME}/lib/warbler_jar.jar" unless defined?(WARBLER_JAR)
13
-
13
+
14
14
  class << self
15
15
  # An instance of Warbler::Application used by the +warble+ command.
16
16
  attr_accessor :application
@@ -30,6 +30,7 @@ module Warbler
30
30
  end
31
31
 
32
32
  require 'warbler/version'
33
+ require 'warbler/executable_helper'
33
34
  require 'warbler/rake_helper'
34
35
  require 'warbler/pathmap_helper'
35
36
  require 'warbler/task'
@@ -58,7 +58,11 @@ class Warbler::Application < Rake::Application
58
58
  Rake.application = app
59
59
  Rake::Application::DEFAULT_RAKEFILES.each do |rf|
60
60
  if File.exist?(rf)
61
- load rf
61
+ begin
62
+ load rf
63
+ rescue LoadError => e
64
+ load File.join(Dir.getwd, rf)
65
+ end
62
66
  break
63
67
  end
64
68
  end
@@ -78,6 +78,12 @@ module Warbler
78
78
  # entries in this structure).
79
79
  attr_accessor :pathmaps
80
80
 
81
+ # Executable of the jar
82
+ attr_accessor :executable
83
+
84
+ # parameters to pass to the executable
85
+ attr_accessor :executable_params
86
+
81
87
  # Name of jar or war file (without the extension), defaults to the
82
88
  # directory name containing the application.
83
89
  attr_accessor :jar_name
@@ -118,7 +124,7 @@ module Warbler
118
124
  # Override GEM_HOME environment variable at runtime. When false, gems in
119
125
  # GEM_HOME will be loaded in preference to those packaged within the jar
120
126
  # file. When true, only gems packaged in the jar file will be loaded.
121
- # Defaults to false
127
+ # Defaults to true
122
128
  attr_accessor :override_gem_home
123
129
 
124
130
  # Extra configuration for web.xml. Controls how the dynamically-generated web.xml
@@ -155,7 +161,12 @@ module Warbler
155
161
  # * <tt>jetty</tt> - Embedded Jetty from Eclipse
156
162
  attr_accessor :webserver
157
163
 
164
+ # These file will be placed in the META-INF directory of the jar or war that warbler
165
+ # produces. They are primarily used as launchers by the runnable feature.
166
+ attr_accessor :script_files
167
+
158
168
  attr_reader :warbler_templates
169
+ attr_reader :warbler_scripts
159
170
 
160
171
  def initialize(warbler_home = WARBLER_HOME)
161
172
  super()
@@ -178,7 +189,9 @@ module Warbler
178
189
  @webinf_files = FileList[]
179
190
  @init_filename = 'META-INF/init.rb'
180
191
  @init_contents = ["#{@warbler_templates}/config.erb"]
181
- @override_gem_home = false
192
+ @override_gem_home = true
193
+ @script_files = []
194
+ @warbler_scripts = "#{WARBLER_HOME}/lib/warbler/scripts"
182
195
 
183
196
  before_configure
184
197
  yield self if block_given?
@@ -0,0 +1,25 @@
1
+ #--
2
+ # Copyright (c) 2013 Michal Papis.
3
+ # This source code is available under the MIT license.
4
+ # See the file LICENSE.txt for details.
5
+ #++
6
+
7
+ module Warbler
8
+ module ExecutableHelper
9
+ def update_archive_add_executable(jar)
10
+ case executable
11
+ when Array
12
+ gem_name, executable_path = executable
13
+ gem_with_version = config.gems.full_name_for(gem_name, config.gem_dependencies)
14
+ bin_path = apply_pathmaps(config, File.join(gem_with_version, executable_path), :gems)
15
+ else
16
+ bin_path = apply_pathmaps(config, executable, :application)
17
+ end
18
+ add_main_rb(jar, bin_path, config.executable_params)
19
+ end
20
+
21
+ def executable
22
+ config.executable ||= default_executable
23
+ end
24
+ end
25
+ end
data/lib/warbler/gems.rb CHANGED
@@ -21,17 +21,56 @@ module Warbler
21
21
  end
22
22
 
23
23
  def <<(gem)
24
+ @specs = nil
24
25
  self[gem] ||= ANY_VERSION
25
26
  end
26
27
 
27
28
  def +(other)
29
+ @specs = nil
28
30
  other.each {|g| self[g] ||= ANY_VERSION }
29
31
  self
30
32
  end
31
33
 
32
34
  def -(other)
35
+ @specs = nil
33
36
  other.each {|g| self.delete(g)}
34
37
  self
35
38
  end
39
+
40
+ def full_name_for(name, gem_dependencies)
41
+ spec = specs(gem_dependencies).detect{ |spec| spec.name == name }
42
+ spec.nil? ? name : spec.full_name
43
+ end
44
+
45
+ def specs(gem_dependencies)
46
+ @specs ||= map{|gem, version| find_single_gem_files(gem_dependencies, gem, version) }.flatten.compact
47
+ end
48
+
49
+ private
50
+
51
+ # Add a single gem to WEB-INF/gems
52
+ def find_single_gem_files(gem_dependencies, gem_pattern, version = nil)
53
+ case gem_pattern
54
+ when Gem::Specification
55
+ return gem_pattern
56
+ when Gem::Dependency
57
+ gem = gem_pattern
58
+ else
59
+ gem = Gem::Dependency.new(gem_pattern, Gem::Requirement.create(version))
60
+ end
61
+ # skip development dependencies
62
+ return nil if gem.respond_to?(:type) and gem.type != :runtime
63
+
64
+ # Deal with deprecated Gem.source_index and #search
65
+ matched = gem.respond_to?(:to_spec) ? [gem.to_spec] : Gem.source_index.search(gem)
66
+ fail "gem '#{gem}' not installed" if matched.empty?
67
+ spec = matched.last
68
+ if gem_dependencies
69
+ [spec] + spec.dependencies.map{|gem| find_single_gem_files(gem_dependencies, gem) }
70
+ else
71
+ spec
72
+ end
73
+ end
74
+
36
75
  end
37
76
  end
data/lib/warbler/jar.rb CHANGED
@@ -72,6 +72,7 @@ module Warbler
72
72
  find_gems_files(config)
73
73
  add_manifest(config)
74
74
  add_init_file(config)
75
+ add_script_files(config)
75
76
  apply_traits(config)
76
77
  end
77
78
 
@@ -120,30 +121,11 @@ module Warbler
120
121
 
121
122
  # Add gems to WEB-INF/gems
122
123
  def find_gems_files(config)
123
- config.gems.each {|gem, version| find_single_gem_files(config, gem, version) }
124
+ config.gems.specs(config.gem_dependencies).each {|spec| find_single_gem_files(config, spec) }
124
125
  end
125
126
 
126
127
  # Add a single gem to WEB-INF/gems
127
- def find_single_gem_files(config, gem_pattern, version = nil)
128
- if Gem::Specification === gem_pattern
129
- spec = gem_pattern
130
- else
131
- gem = case gem_pattern
132
- when Gem::Dependency
133
- gem_pattern
134
- else
135
- Gem::Dependency.new(gem_pattern, Gem::Requirement.create(version))
136
- end
137
-
138
- # skip development dependencies
139
- return if gem.respond_to?(:type) and gem.type != :runtime
140
-
141
- # Deal with deprecated Gem.source_index and #search
142
- matched = gem.respond_to?(:to_spec) ? [gem.to_spec] : Gem.source_index.search(gem)
143
- fail "gem '#{gem}' not installed" if matched.empty?
144
- spec = matched.last
145
- end
146
-
128
+ def find_single_gem_files(config, spec)
147
129
  full_gem_path = Pathname.new(spec.full_gem_path)
148
130
 
149
131
  # skip gems whose full_gem_path does not exist
@@ -155,8 +137,6 @@ module Warbler
155
137
  next if config.gem_excludes && config.gem_excludes.any? {|rx| f =~ rx }
156
138
  @files[apply_pathmaps(config, File.join(spec.full_name, f), :gems)] = src
157
139
  end
158
-
159
- spec.dependencies.each {|dep| find_single_gem_files(config, dep) } if config.gem_dependencies
160
140
  end
161
141
 
162
142
  # Add all application directories and files to the archive.
@@ -191,6 +171,12 @@ module Warbler
191
171
  end
192
172
  end
193
173
 
174
+ def add_script_files(config)
175
+ config.script_files.each do |file|
176
+ @files["META-INF/#{File.basename(file)}"] = StringIO.new(File.read(file))
177
+ end
178
+ end
179
+
194
180
  def add_with_pathmaps(config, f, map_type)
195
181
  @files[apply_pathmaps(config, f, map_type)] = f
196
182
  end
@@ -224,8 +210,8 @@ module Warbler
224
210
  zipfile.get_output_stream(entry) {|f| f << src.read }
225
211
  elsif src.nil? || File.directory?(src)
226
212
  if File.symlink?(entry) && ! defined?(JRUBY_VERSION)
227
- $stderr.puts "directory symlinks are not followed unless using JRuby; " +
228
- "#{entry.inspect} contents not in archive"
213
+ $stderr.puts "directory symlinks are not followed unless using JRuby; " +
214
+ "#{entry.inspect} contents not in archive"
229
215
  end
230
216
  zipfile.mkdir(entry.dup) # in case it's frozen rubyzip 0.9.6.1 workaround
231
217
  elsif File.symlink?(src)
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ if RUBY_VERSION =~ /^1.8/
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
7
+ else
8
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
9
+ require_relative '../config/boot'
10
+ require 'rails/commands'
11
+ end
@@ -1,4 +1,12 @@
1
- ENV['GEM_HOME'] ||= $servlet_context.getRealPath('<%= config.gem_path %>')
1
+ <% assignment_operator = config.override_gem_home ? "=" : "||=" %>
2
+ if $servlet_context.nil?
3
+ ENV['GEM_HOME'] <%= assignment_operator %> File.expand_path('../../WEB-INF', __FILE__)
2
4
  <% if config.bundler && config.bundler[:gemfile_path] %>
3
- ENV['BUNDLE_GEMFILE'] ||= $servlet_context.getRealPath('/<%= config.bundler[:gemfile_path] %>')
5
+ ENV['BUNDLE_GEMFILE'] = File.expand_path('../../<%= config.bundler[:gemfile_path] %>', __FILE__)
4
6
  <% end %>
7
+ else
8
+ ENV['GEM_HOME'] <%= assignment_operator %> $servlet_context.getRealPath('<%= config.gem_path %>')
9
+ <% if config.bundler && config.bundler[:gemfile_path] %>
10
+ ENV['BUNDLE_GEMFILE'] ||= $servlet_context.getRealPath('/<%= config.bundler[:gemfile_path] %>')
11
+ <% end %>
12
+ end
@@ -80,8 +80,11 @@ module Warbler
80
80
  config.init_contents << StringIO.new("$LOAD_PATH.unshift __FILE__.sub(/!.*/, '!/#{path}')\n")
81
81
  end
82
82
 
83
- def add_main_rb(jar, bin_path)
84
- jar.files['META-INF/main.rb'] = StringIO.new("load '#{bin_path}'")
83
+ def add_main_rb(jar, bin_path, params = nil)
84
+ binary = ""
85
+ binary << "ARGV.unshift('#{params}')\n" if params
86
+ binary << "load '#{bin_path}'"
87
+ jar.files['META-INF/main.rb'] = StringIO.new(binary)
85
88
  end
86
89
 
87
90
  def update_gem_path(default_gem_path)
@@ -12,6 +12,7 @@ module Warbler
12
12
  class Gemspec
13
13
  include Trait
14
14
  include PathmapHelper
15
+ include ExecutableHelper
15
16
 
16
17
  def self.detect?
17
18
  !Dir['*.gemspec'].empty?
@@ -33,16 +34,23 @@ module Warbler
33
34
  end
34
35
 
35
36
  def update_archive(jar)
36
- (Dir['**/*'] - config.compiled_ruby_files).each do |f|
37
- jar.files[apply_pathmaps(config, f, :application)] = f
37
+ @spec.files.each do |f|
38
+ unless File.exist?(f)
39
+ warn "update your gemspec; skipping missing file #{f}"
40
+ next
41
+ end
42
+ file_key = jar.apply_pathmaps(config, f, :application)
43
+ next if jar.files[file_key]
44
+ jar.files[file_key] = f
38
45
  end
46
+
39
47
  config.compiled_ruby_files.each do |f|
40
48
  f = f.sub(/\.rb$/, '.class')
41
49
  next unless File.exist?(f)
42
50
  jar.files[apply_pathmaps(config, f, :application)] = f
43
51
  end
44
- bin_path = apply_pathmaps(config, default_executable, :application)
45
- add_main_rb(jar, bin_path)
52
+
53
+ update_archive_add_executable(jar)
46
54
  end
47
55
 
48
56
  def default_executable
@@ -55,6 +63,7 @@ module Warbler
55
63
  exe
56
64
  end
57
65
  end
66
+
58
67
  end
59
68
  end
60
69
  end
@@ -13,6 +13,7 @@ module Warbler
13
13
  class NoGemspec
14
14
  include Trait
15
15
  include PathmapHelper
16
+ include ExecutableHelper
16
17
 
17
18
  def self.detect?
18
19
  Jar.detect? && !Gemspec.detect?
@@ -29,7 +30,7 @@ module Warbler
29
30
  end
30
31
 
31
32
  def update_archive(jar)
32
- add_main_rb(jar, apply_pathmaps(config, default_executable, :application))
33
+ update_archive_add_executable(jar)
33
34
  end
34
35
 
35
36
  def default_executable
@@ -39,24 +39,42 @@ module Warbler
39
39
  config.gems << Gem::Dependency.new(g.name, g.requirement) if Dir["vendor/gems/#{g.name}*"].empty?
40
40
  end
41
41
  end
42
+ config.script_files << "#{config.warbler_scripts}/rails.rb"
42
43
  end
43
44
 
44
45
  def after_configure
45
46
  config.init_contents << "#{config.warbler_templates}/rails.erb"
47
+
48
+ if threadsafe_enabled? or rails_4?
49
+ config.webxml.jruby.min.runtimes = 1 unless Integer === config.webxml.jruby.min.runtimes
50
+ config.webxml.jruby.max.runtimes = 1 unless Integer === config.webxml.jruby.max.runtimes
51
+ end
52
+ end
53
+
54
+
55
+ def default_app_name
56
+ File.basename(File.expand_path(defined?(::Rails.root) ? ::Rails.root : (defined?(RAILS_ROOT) ? RAILS_ROOT : Dir.getwd)))
57
+ end
58
+
59
+ def threadsafe_enabled?
60
+ rails_env = config.webxml.rails.env
46
61
  begin
47
- rails_env = config.webxml.rails.env
48
62
  unless IO.readlines("config/environments/#{rails_env}.rb").grep(/^\s*config\.threadsafe!/).empty? &&
49
- IO.readlines("config/environment.rb").grep(/^\s*config\.threadsafe!/).empty?
50
- config.webxml.jruby.min.runtimes = 1 unless Integer === config.webxml.jruby.min.runtimes
51
- config.webxml.jruby.max.runtimes = 1 unless Integer === config.webxml.jruby.max.runtimes
63
+ IO.readlines("config/environment.rb").grep(/^\s*config\.threadsafe!/).empty?
64
+ return true
52
65
  end
53
66
  rescue
54
67
  end
55
68
  end
56
69
 
57
-
58
- def default_app_name
59
- File.basename(File.expand_path(defined?(::Rails.root) ? ::Rails.root : (defined?(RAILS_ROOT) ? RAILS_ROOT : Dir.getwd)))
70
+ def rails_4?
71
+ begin
72
+ unless IO.readlines("Gemfile").grep(/^\s*gem\s('|")rails('|"),\s('|")4\.\d+\.\d+/).empty? &&
73
+ IO.readlines("Gemfile.lock").grep(/^\s*rails\s\([=~><]*\s*4\.(\d+)\.(\d+).*\)$/).empty?
74
+ return true
75
+ end
76
+ rescue
77
+ end
60
78
  end
61
79
  end
62
80
  end
@@ -6,5 +6,5 @@
6
6
  #++
7
7
 
8
8
  module Warbler
9
- VERSION = "1.3.8"
9
+ VERSION = "1.4.0.beta1"
10
10
  end
data/lib/warbler_jar.jar CHANGED
Binary file
@@ -0,0 +1,5 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'sample_jar'
4
+
5
+ SampleJar.hello
data/spec/spec_helper.rb CHANGED
@@ -132,8 +132,8 @@ module ExampleGroupHelpers
132
132
  def use_test_webserver
133
133
  before :each do
134
134
  webserver = double('server').as_null_object
135
- webserver.stub!(:main_class).and_return 'WarMain.class'
136
- webserver.stub!(:add).and_return do |jar|
135
+ webserver.stub(:main_class).and_return 'WarMain.class'
136
+ webserver.stub(:add).and_return do |jar|
137
137
  jar.files['WEB-INF/webserver.jar'] = StringIO.new
138
138
  end
139
139
  Warbler::WEB_SERVERS['test'] = webserver
@@ -20,15 +20,6 @@ describe Warbler::Jar, "with Bundler" do
20
20
  @extra_config = block
21
21
  end
22
22
 
23
- def hide_shallow_git_clone
24
- git_shallow_marker = File.join(Warbler::WARBLER_HOME, ".git/shallow")
25
- tmp_marker = File.join(Warbler::WARBLER_HOME, ".git/shallow.tmp")
26
- File.rename(git_shallow_marker, tmp_marker) if File.exists?(git_shallow_marker)
27
- yield
28
- ensure
29
- File.rename(tmp_marker, git_shallow_marker) if File.exist?(tmp_marker)
30
- end
31
-
32
23
  let(:config) { drbclient.config(@extra_config) }
33
24
  let(:jar) { drbclient.jar }
34
25
 
@@ -70,23 +61,19 @@ describe Warbler::Jar, "with Bundler" do
70
61
  end
71
62
 
72
63
  it "works with :git entries in Gemfiles" do
73
- hide_shallow_git_clone do
74
- File.open("Gemfile", "w") {|f| f << "gem 'warbler', :git => '#{Warbler::WARBLER_HOME}'\n"}
75
- `#{RUBY_EXE} -S bundle install --local`
76
- jar.apply(config)
77
- file_list(%r{WEB-INF/gems/bundler/gems/warbler[^/]*/lib/warbler/version\.rb}).should_not be_empty
78
- file_list(%r{WEB-INF/gems/bundler/gems/warbler[^/]*/warbler.gemspec}).should_not be_empty
79
- end
64
+ File.open("Gemfile", "w") {|f| f << "gem 'warbler', :git => '#{Warbler::WARBLER_HOME}'\n"}
65
+ `#{RUBY_EXE} -S bundle install --local`
66
+ jar.apply(config)
67
+ file_list(%r{WEB-INF/gems/bundler/gems/warbler[^/]*/lib/warbler/version\.rb}).should_not be_empty
68
+ file_list(%r{WEB-INF/gems/bundler/gems/warbler[^/]*/warbler.gemspec}).should_not be_empty
80
69
  end
81
70
 
82
71
  it "bundles only the gemspec for :git entries that are excluded" do
83
- hide_shallow_git_clone do
84
- File.open("Gemfile", "w") {|f| f << "gem 'rake'\ngroup :test do\ngem 'warbler', :git => '#{Warbler::WARBLER_HOME}'\nend\n"}
85
- `#{RUBY_EXE} -S bundle install --local`
86
- jar.apply(config)
87
- file_list(%r{WEB-INF/gems/bundler/gems/warbler[^/]*/lib/warbler/version\.rb}).should be_empty
88
- file_list(%r{WEB-INF/gems/bundler/gems/warbler[^/]*/warbler.gemspec}).should_not be_empty
89
- end
72
+ File.open("Gemfile", "w") {|f| f << "gem 'rake'\ngroup :test do\ngem 'warbler', :git => '#{Warbler::WARBLER_HOME}'\nend\n"}
73
+ `#{RUBY_EXE} -S bundle install --local`
74
+ jar.apply(config)
75
+ file_list(%r{WEB-INF/gems/bundler/gems/warbler[^/]*/lib/warbler/version\.rb}).should be_empty
76
+ file_list(%r{WEB-INF/gems/bundler/gems/warbler[^/]*/warbler.gemspec}).should_not be_empty
90
77
  end
91
78
 
92
79
  it "does not work with :path entries in Gemfiles" do
@@ -130,16 +117,14 @@ describe Warbler::Jar, "with Bundler" do
130
117
  cleanup_temp_files
131
118
 
132
119
  it "works with :git entries in Gemfiles" do
133
- hide_shallow_git_clone do
134
- File.open("Gemfile", "w") {|f| f << "gem 'warbler', :git => '#{Warbler::WARBLER_HOME}'\n"}
135
- `#{RUBY_EXE} -S bundle install --local`
136
- jar.apply(config)
137
- file_list(%r{^bundler/gems/warbler[^/]*/lib/warbler/version\.rb}).should_not be_empty
138
- file_list(%r{^bundler/gems/warbler[^/]*/warbler.gemspec}).should_not be_empty
139
- jar.add_init_file(config)
140
- contents = jar.contents('META-INF/init.rb')
141
- contents.should =~ /ENV\['BUNDLE_GEMFILE'\] = File.expand_path(.*, __FILE__)/
142
- end
120
+ File.open("Gemfile", "w") {|f| f << "gem 'warbler', :git => '#{Warbler::WARBLER_HOME}'\n"}
121
+ `#{RUBY_EXE} -S bundle install --local`
122
+ jar.apply(config)
123
+ file_list(%r{^bundler/gems/warbler[^/]*/lib/warbler/version\.rb}).should_not be_empty
124
+ file_list(%r{^bundler/gems/warbler[^/]*/warbler.gemspec}).should_not be_empty
125
+ jar.add_init_file(config)
126
+ contents = jar.contents('META-INF/init.rb')
127
+ contents.should =~ /ENV\['BUNDLE_GEMFILE'\] = File.expand_path(.*, __FILE__)/
143
128
  end
144
129
 
145
130
  it "adds BUNDLE_GEMFILE to init.rb" do