diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2014-10-01 17:27:48 +0100 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2014-10-01 17:27:48 +0100 |
commit | 9d5f171347b20d443436d0b2bf765a533969e6a2 (patch) | |
tree | d8ea4402c5e22e63b75713be2ac0687e3f6670af | |
parent | f6053fd4800c4607c6f09283431264f796d6cde1 (diff) | |
download | morph-9d5f171347b20d443436d0b2bf765a533969e6a2.tar.gz |
fixup! import: Put Ruby option parsing into base class
-rwxr-xr-x | import/rubygems.to_chunk | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/import/rubygems.to_chunk b/import/rubygems.to_chunk index cc21fb83..c90cda23 100755 --- a/import/rubygems.to_chunk +++ b/import/rubygems.to_chunk @@ -19,19 +19,8 @@ require 'bundler' -require 'optparse' - require_relative 'importer_base' -DESCRIPTION = <<-END -This tool reads the Gemfile and optionally the Gemfile.lock from a Ruby project -source tree in SOURCE_DIR. It outputs a chunk morphology for GEM_NAME on -stdout. If VERSION is supplied, it is used to check that the build instructions -will produce the expected version of the Gem. - -It is intended for use with the `baserock-import` tool. -END - class << Bundler def default_gemfile # This is a hack to make things not crash when there's no Gemfile @@ -44,6 +33,17 @@ def spec_is_from_current_source_tree(spec) spec.source.path.fnmatch?('.') end +BANNER = "Usage: rubygems.to_chunk SOURCE_DIR GEM_NAME [VERSION]" + +DESCRIPTION = <<-END +This tool reads the Gemfile and optionally the Gemfile.lock from a Ruby project +source tree in SOURCE_DIR. It outputs a chunk morphology for GEM_NAME on +stdout. If VERSION is supplied, it is used to check that the build instructions +will produce the expected version of the Gem. + +It is intended for use with the `baserock-import` tool. +END + class RubyGemChunkMorphologyGenerator < Importer::Base def initialize local_data = YAML.load_file("rubygems.yaml") @@ -51,15 +51,7 @@ class RubyGemChunkMorphologyGenerator < Importer::Base end def parse_options(arguments) - opts = OptionParser.new - - opts.banner = "Usage: rubygems.to_chunk SOURCE_DIR GEM_NAME [VERSION]" - - opts.on('-?', '--help', 'print this help') do - puts opts - print "\n", DESCRIPTION - exit 1 - end + opts = create_option_parser(BANNER, DESCRIPTION) parsed_arguments = opts.parse!(arguments) |