gemjam 0.0.6 → 0.0.8
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/README.md +8 -14
- data/Rakefile +1 -1
- data/bin/gemjam +1 -2
- data/lib/gemjam.rb +51 -22
- data/lib/gemjam/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -16,6 +16,14 @@ Or install it yourself as:
|
|
16
16
|
|
17
17
|
$ gem install gemjam
|
18
18
|
|
19
|
+
|
20
|
+
## Dependencies
|
21
|
+
|
22
|
+
On fedora, for the java `jar` command:
|
23
|
+
|
24
|
+
yum install java-devel-openjdk
|
25
|
+
|
26
|
+
|
19
27
|
## Usage
|
20
28
|
|
21
29
|
Package up a specific version of one gem, and latest version of another
|
@@ -76,20 +84,6 @@ How this is used practically aftwards
|
|
76
84
|
23:36:22 up 133 days, 9:23, 0 users, load average: 0.06, 0.05, 0.05
|
77
85
|
|
78
86
|
|
79
|
-
or
|
80
|
-
|
81
|
-
$ gemjam -g warbler
|
82
|
-
{:jruby=>"jruby", :gems=>["warbler"]}
|
83
|
-
Successfully installed rake-10.1.0
|
84
|
-
Successfully installed jruby-jars-1.7.4
|
85
|
-
Successfully installed warbler-1.3.8
|
86
|
-
3 gems installed
|
87
|
-
Created d20130723-24956-4o39ld.jar
|
88
|
-
$ jruby -r ./d20130723-24956-4o39ld.jar -S warble
|
89
|
-
rm -f hurp.war
|
90
|
-
Creating hurp.war
|
91
|
-
|
92
|
-
|
93
87
|
## Contributing
|
94
88
|
|
95
89
|
1. Fork it
|
data/Rakefile
CHANGED
data/bin/gemjam
CHANGED
data/lib/gemjam.rb
CHANGED
@@ -11,6 +11,7 @@ require "optparse"
|
|
11
11
|
require "rbconfig"
|
12
12
|
require "tmpdir"
|
13
13
|
require "fileutils"
|
14
|
+
require "stringio"
|
14
15
|
|
15
16
|
module Gemjam
|
16
17
|
def parse_args(args)
|
@@ -24,6 +25,9 @@ module Gemjam
|
|
24
25
|
opts.on("-o", "--output FILENAME", "output to jar FILENAME") do |o|
|
25
26
|
options[:output] = o
|
26
27
|
end
|
28
|
+
opts.on("--keep", "preserve the temp working directory (for debugging)") do |o|
|
29
|
+
options[:keep] = o
|
30
|
+
end
|
27
31
|
opts.on("-c", "--cache", "preserve the cach/*.gem files in the jar") do |o|
|
28
32
|
options[:cache] = o
|
29
33
|
end
|
@@ -55,21 +59,23 @@ module Gemjam
|
|
55
59
|
end.parse!(args)
|
56
60
|
return options
|
57
61
|
end
|
62
|
+
module_function :parse_args
|
58
63
|
|
59
64
|
# runs +cmd+, and sets $? with that commands return value
|
60
|
-
def cmd(cmd_str, quiet = false)
|
65
|
+
def cmd(cmd_str, quiet = false, io = $stdout)
|
61
66
|
p cmd_str unless quiet
|
62
67
|
IO.popen(cmd_str) do |f|
|
63
68
|
loop do
|
64
69
|
buf = f.read(1)
|
65
70
|
break if buf.nil?
|
66
71
|
unless quiet
|
67
|
-
print buf
|
68
|
-
|
72
|
+
io.print buf
|
73
|
+
io.flush
|
69
74
|
end
|
70
75
|
end
|
71
76
|
end
|
72
77
|
end
|
78
|
+
module_function :cmd
|
73
79
|
|
74
80
|
# install rubygem +gemname+ to directory +basedir+ using jruby command +jruby+
|
75
81
|
#
|
@@ -82,6 +88,7 @@ module Gemjam
|
|
82
88
|
cmd("#{jruby} -S gem install -i #{basedir} #{gemname}", quiet)
|
83
89
|
end
|
84
90
|
end
|
91
|
+
module_function :gem_install
|
85
92
|
|
86
93
|
# pack up the installed gems in +dirname+, to jar file +jarname+
|
87
94
|
#
|
@@ -89,6 +96,7 @@ module Gemjam
|
|
89
96
|
def make_jar(jarname, dirname, quiet = false)
|
90
97
|
cmd("jar cf #{jarname} -C #{dirname} .", quiet)
|
91
98
|
end
|
99
|
+
module_function :make_jar
|
92
100
|
|
93
101
|
# install the bundle, using jruby command +jruby+
|
94
102
|
#
|
@@ -97,14 +105,20 @@ module Gemjam
|
|
97
105
|
ex_opts = opts.map {|k,v| [k,v] }.join(" ")
|
98
106
|
cmd("#{jruby} -S bundle install --path ./vendor/bundle/ #{ex_opts}", quiet)
|
99
107
|
end
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
108
|
+
module_function :bundle_install
|
109
|
+
|
110
|
+
def bundler_vendor_dir(jruby)
|
111
|
+
return @bundler_vendor_dir if @bundler_vendor_dir
|
112
|
+
sio = StringIO.new
|
113
|
+
cmd("#{jruby} -e \"print ['vendor/bundle',RbConfig::CONFIG['ruby_install_name'], RbConfig::CONFIG['ruby_version'] ].join('/')\"",
|
114
|
+
false,
|
115
|
+
sio)
|
116
|
+
sio.seek(0)
|
117
|
+
@bundler_vendor_dir = sio.read()
|
106
118
|
end
|
119
|
+
module_function :bundler_vendor_dir
|
107
120
|
|
121
|
+
# run(parse_args("-q","-o",jarname,"-b","Gemfile"))
|
108
122
|
def run(opts)
|
109
123
|
tmpdir = Dir.mktmpdir
|
110
124
|
begin
|
@@ -115,31 +129,44 @@ module Gemjam
|
|
115
129
|
b_opts["--with"] = opts[:bundle_with] if opts[:bundle_with]
|
116
130
|
b_opts["--without"] = opts[:bundle_without] if opts[:bundle_without]
|
117
131
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
132
|
+
begin
|
133
|
+
FileUtils.cd tmpdir, :verbose => !opts[:quiet]
|
134
|
+
FileUtils.cp opts[:bundle], "Gemfile"
|
135
|
+
|
136
|
+
# If there is a bundler lockfile, then use it too
|
137
|
+
if FileTest.file?("#{opts[:bundle]}.lock")
|
138
|
+
FileUtils.cp "#{opts[:bundle]}.lock", "Gemfile.lock"
|
139
|
+
|
140
|
+
# ensure these timestamps match the original
|
141
|
+
File.utime(File.atime(opts[:bundle]),
|
142
|
+
File.mtime(opts[:bundle]),
|
143
|
+
"Gemfile")
|
144
|
+
File.utime(File.atime("#{opts[:bundle]}.lock"),
|
145
|
+
File.mtime("#{opts[:bundle]}.lock"),
|
146
|
+
"Gemfile.lock")
|
147
|
+
|
148
|
+
b_opts["--deployment"] = ""
|
149
|
+
end
|
150
|
+
|
125
151
|
bundle_install(opts[:jruby], opts[:quiet], b_opts)
|
152
|
+
abort("FAIL: bundler returned: #{$?}") if $? != 0
|
153
|
+
ensure
|
154
|
+
FileUtils.cd cwd, :verbose => !opts[:quiet]
|
126
155
|
end
|
127
|
-
FileUtils.cd cwd
|
128
|
-
abort("FAIL: bundler returned: #{$?}") if $? != 0
|
129
156
|
end
|
130
157
|
|
131
158
|
opts[:gems].each do |gem|
|
132
|
-
gem_install(opts[:jruby], File.join(tmpdir, bundler_vendor_dir), gem, opts[:quiet])
|
159
|
+
gem_install(opts[:jruby], File.join(tmpdir, bundler_vendor_dir(opts[:jruby])), gem, opts[:quiet])
|
133
160
|
abort("FAIL: gem install returned: #{$?}") if $? != 0
|
134
161
|
end
|
135
162
|
|
136
163
|
# the ./cache/*.gems just duplicates the size of this jar
|
137
164
|
unless opts[:cache]
|
138
|
-
FileUtils.remove_entry_secure(File.join(tmpdir, bundler_vendor_dir, "cache"), true)
|
165
|
+
FileUtils.remove_entry_secure(File.join(tmpdir, bundler_vendor_dir(opts[:jruby]), "cache"), true)
|
139
166
|
end
|
140
167
|
|
141
168
|
jarname = opts[:output] ? opts[:output] : File.basename(tmpdir) + ".jar"
|
142
|
-
make_jar(jarname, File.join(tmpdir, bundler_vendor_dir), opts[:quiet])
|
169
|
+
make_jar(jarname, File.join(tmpdir, bundler_vendor_dir(opts[:jruby])), opts[:quiet])
|
143
170
|
abort("FAIL: jar packaging returned: #{$?}") if $? != 0
|
144
171
|
|
145
172
|
if opts[:quiet]
|
@@ -149,9 +176,10 @@ module Gemjam
|
|
149
176
|
end
|
150
177
|
ensure
|
151
178
|
# remove the directory.
|
152
|
-
FileUtils.remove_entry_secure(tmpdir, true)
|
179
|
+
FileUtils.remove_entry_secure(tmpdir, true) unless opts[:keep]
|
153
180
|
end
|
154
181
|
end
|
182
|
+
module_function :run
|
155
183
|
|
156
184
|
def main(args)
|
157
185
|
o = parse_args(args)
|
@@ -159,4 +187,5 @@ module Gemjam
|
|
159
187
|
|
160
188
|
run(o)
|
161
189
|
end
|
190
|
+
module_function :main
|
162
191
|
end
|
data/lib/gemjam/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gemjam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-08-13 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Create java jar, for jRuby, from gems or a bundler Gemfile
|
15
15
|
email:
|