/
rumpler
executable file
·128 lines (98 loc) · 3.21 KB
/
rumpler
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/usr/bin/env ruby
$: << File.join( File.dirname(__FILE__), '..', 'lib' )
require 'rubygems'
require 'bundler'
require 'optparse'
require 'rumpler/config'
require 'rumpler/gemfile_converter'
require 'rumpler/gemspec_converter'
require 'rumpler/root_specs_loader'
require 'rumpler/application_converter'
require 'rumpler/patches'
require 'ostruct'
batch = OpenStruct.new
batch.output_dir = './build'
batch.inhibit_exclusions = false
batch.version = '0.0.0-dev'
batch.force = false
batch.name = 'bundle'
batch.gem = nil
opts = OptionParser.new do |opts|
opts.banner = "Usage: rumpler [options]"
opts.separator ""
opts.separator "Specific options:"
opts.on( '-a', '--application' ) do
batch.mode = :application
end
opts.on( '-V version' ) do |version|
batch.version = version
end
opts.on( '-v version' ) do |version|
batch.version = version
end
opts.on( '-G', '--gemfile' ) do
batch.mode = :gemfile
end
opts.on( '-g', '--gem FQNAME' ) do |gem|
batch.mode = :gem
batch.gem = gem
end
opts.on( '-r', '--root ROOT' ) do |root|
batch.root = root
end
opts.on( '-n', '--name NAME' ) do |name|
batch.name = name
end
opts.on( '-f', '--force' ) do
batch.force = true
end
opts.on( '-o', '--output OUTPDIR' ) do |output_dir|
batch.output_dir = output_dir
end
opts.on('-i', '--inhibit-exclusions', 'Inhibit default exclusions' ) do
batch.inhibit_exclusions = true
end
opts.on( '-c', '--config CONFIG_FILE' ) do |config|
batch.config_file = config
end
opts.on_tail("-h", "--help", "Show this message") do
puts opts
exit
end
end
opts.parse!( ARGV )
config = Rumpler::Config.new(batch.config_file)
if config.ruby_abi.to_s.include?( 'java' )
puts "Using Gem::Platform::JAVA"
Gem.platforms.push( Gem::Platform::JAVA )
else
puts "Using MRI platform for gems"
end
case ( batch.mode )
when :application
exclusions = batch.root.nil? ? [] : Rumpler::RootSpecsLoader.new( nil, nil, batch.root, batch.force, config ).exclusions
if ( ARGV.empty? )
converter = Rumpler::ApplicationConverter.new( Dir.pwd, batch.version, batch.output_dir, config, exclusions ).dump
else
puts "Argument not accepted yet, complain to Bob"
end
when :gemfile
exclusions = batch.root.nil? ? [] : Rumpler::RootSpecsLoader.new( nil, nil, batch.root, batch.force, config ).exclusions
ARGV.each do |gemfile|
converter = Rumpler::GemfileConverter.new( gemfile, batch.output_dir, config, exclusions )
converter.dump
end
when :gem
exclusions = batch.root.nil? ? [] : Rumpler::RootSpecsLoader.new( nil, nil, batch.root, batch.force, config ).exclusions
gemfile_path = File.join( batch.output_dir, 'Gemfile' )
File.open( gemfile_path, 'w' ) do |f|
f.puts( "source 'http://rubygems.org/'" )
f.puts( "gem '#{batch.gem}', '#{batch.version}'" )
end
converter = Rumpler::GemfileConverter.new( gemfile_path, batch.output_dir, config, exclusions )
converter.dump
else
if ( ! batch.root.nil? )
Rumpler::RootSpecsLoader.new( batch.name, batch.version, batch.root, batch.force, config, batch.output_dir ).dump
end
end