warbler-exec 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ warbler-exec*.gem
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # warbler-exec
2
+
3
+ This gem allows you to run commands within the context of a Warbler created WAR file. It will use the JRuby runtime packaged with the WAR file even when this tool is executed from a different runtime.
4
+
5
+ ## How to Use
6
+
7
+ This tool provides the `warbler-exec` command that takes this form:
8
+
9
+ $ warbler-exec <war-file> <command> <arguments>
10
+
11
+ But it will only run with the JRuby runtime, so you will need to include everything that's needed in your WAR file. For example, let's say you want to run Rails migrations from your WAR file. First, you'll need something like this in your `warble.rb`:
12
+
13
+ Warbler::Config.new do |config|
14
+ config.dirs << "bin"
15
+ config.includes = FileList["Rakefile"]
16
+ config.bundle_without = [] # bundler will get fussy if we leave out dev and test
17
+ end
18
+
19
+ Then run Bundler the with `--binstubs` option, and use `warbler-exec` to run the Rake task:
20
+
21
+ $ bundle --binstubs
22
+ $ warble war
23
+ $ gem install warbler-exec
24
+ $ warbler-exec myapp.war bin/rake db:migrate
25
+
26
+ Every time that `warbler-exec` runs, it extracts the WAR file. Don't expect it to be fast.
27
+
28
+ # Roadmap
29
+
30
+ It would be a lot easier if we didn't have to run Bundler with the `--binstubs` option. Eventually, someone (probably the person writing this) will submit a patch to Warbler that gets around this.
31
+
data/bin/warbler-exec ADDED
@@ -0,0 +1,35 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'zip/zip'
4
+ require 'tmpdir'
5
+
6
+ path_to_war = ARGV.shift
7
+
8
+ destination = Dir.mktmpdir
9
+ Zip::ZipFile.open(path_to_war) do |zipfile|
10
+ zipfile.each do |f|
11
+ f_path = File.join(destination, f.name)
12
+ FileUtils.mkdir_p(File.dirname(f_path))
13
+ zipfile.extract(f, f_path)
14
+ end
15
+ end
16
+
17
+ Dir.chdir(File.join(destination, "WEB-INF"))
18
+ ENV["CLASSPATH"] = Dir["#{Dir.pwd}/lib/*.jar"].join(":")
19
+ ENV["GEM_PATH"] = "#{Dir.pwd}/gems"
20
+ ENV["GEM_HOME"] = "#{Dir.pwd}/gems"
21
+
22
+ begin
23
+ Kernel.exec("java -Xmx512m -cp $CLASSPATH org.jruby.Main #{ARGV.join(" ")}")
24
+ rescue Errno::EACCES
25
+ puts "warbler-exec: not executable: #{ARGV.first}"
26
+ exit 126
27
+ rescue Errno::ENOENT
28
+ puts "warbler-exec: command not found: #{ARGV.first}"
29
+ exit 127
30
+ rescue ArgumentError
31
+ puts "warbler-exec: exec needs a command to run"
32
+ exit 128
33
+ end
34
+
35
+
@@ -0,0 +1,22 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+
4
+ Gem::Specification.new do |s|
5
+ s.name = "warbler-exec"
6
+ s.version = "0.1.0"
7
+ s.platform = Gem::Platform::RUBY
8
+ s.authors = ["Joe Kutner"]
9
+ s.email = ["jpkutner@gmail.com"]
10
+ s.homepage = "https://github.com/jkutner/warbler-exec"
11
+ s.summary = %q{Allows execution of commands from a Warbler WAR file}
12
+ s.description = %q{This utility allows you to execute commands with the context of a Warbler WAR file}
13
+
14
+ s.rubyforge_project = "warbler-exec"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.add_runtime_dependency(%q<rubyzip>, [">= 0.9.4"])
22
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: warbler-exec
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - Joe Kutner
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2012-03-26 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: rubyzip
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: 0.9.4
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ description: This utility allows you to execute commands with the context of a Warbler WAR file
27
+ email:
28
+ - jpkutner@gmail.com
29
+ executables:
30
+ - warbler-exec
31
+ extensions: []
32
+
33
+ extra_rdoc_files: []
34
+
35
+ files:
36
+ - .gitignore
37
+ - README.md
38
+ - bin/warbler-exec
39
+ - warbler-exec.gemspec
40
+ homepage: https://github.com/jkutner/warbler-exec
41
+ licenses: []
42
+
43
+ post_install_message:
44
+ rdoc_options: []
45
+
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ version: "0"
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ version: "0"
60
+ requirements: []
61
+
62
+ rubyforge_project: warbler-exec
63
+ rubygems_version: 1.8.15
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: Allows execution of commands from a Warbler WAR file
67
+ test_files: []
68
+