summaryrefslogtreecommitdiff
path: root/import/rubygems.to_chunk
diff options
context:
space:
mode:
Diffstat (limited to 'import/rubygems.to_chunk')
-rwxr-xr-ximport/rubygems.to_chunk21
1 files changed, 17 insertions, 4 deletions
diff --git a/import/rubygems.to_chunk b/import/rubygems.to_chunk
index fbf9de96..e1d24ec7 100755
--- a/import/rubygems.to_chunk
+++ b/import/rubygems.to_chunk
@@ -60,23 +60,30 @@ class RubyGemChunkMorphologyGenerator
# No options so far ..
opts = OptionParser.new
- opts.banner = "Usage: rubygems.to_chunk SOURCE_DIR GEM_NAME"
+ opts.banner = "Usage: rubygems.to_chunk SOURCE_DIR GEM_NAME [VERSION]"
opts.separator ""
opts.separator "This tool reads the Gemfile and optionally the " +
"Gemfile.lock from a Ruby project "
opts.separator "source tree in SOURCE_DIR. It outputs a chunk " +
"morphology for GEM_NAME on stdout."
+ opts.separator "If VERSION is supplied, it is used to check that " +
+ "the build instructions will"
+ opts.separator "produce the expected version of the Gem."
opts.separator ""
opts.separator "It is intended for use with the `baserock-import` tool."
parsed_arguments = opts.parse!(arguments)
- if parsed_arguments.length != 2
+ if parsed_arguments.length != 2 && parsed_arguments.length != 3
STDERR.puts opts.help
exit 1
end
- parsed_arguments
+ source_dir, gem_name, expected_version = parsed_arguments
+ if expected_version != nil
+ expected_version = Gem::Version.new(expected_version)
+ end
+ [source_dir, gem_name, expected_version]
end
def error(message)
@@ -225,7 +232,7 @@ class RubyGemChunkMorphologyGenerator
end
def run
- source_dir_name, gem_name = parse_options(ARGV)
+ source_dir_name, gem_name, expected_version = parse_options(ARGV)
Log.info("Creating chunk morph for #{gem_name} based on " +
"source code in #{source_dir_name}")
@@ -250,6 +257,12 @@ class RubyGemChunkMorphologyGenerator
exit 1
end
+ if expected_version != nil && spec.version != expected_version
+ error "Source in #{source_dir_name} produces #{spec.full_name}, but " +
+ "the expected version was #{expected_version}."
+ exit 1
+ end
+
morph = generate_chunk_morph_for_gem(spec)
# One might think that you could use the Bundler::Dependency.groups