Sha256: 2730223420878d8b0c4faa5483d7b13bcc1bd92a3ab792a3890515572d7b3b1c
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
module Gemsmith # Command Line Interface (CLI) helpers for the CLI class. module CLIHelpers def gem_name configuration.gem_name end def gem_class configuration.gem_class end def rails_version configuration.rails_version end module_function def print_gems gems say "Multiple versions found:\n\n" gems.each.with_index { |spec, index| say "#{index + 1}. #{spec.name} #{spec.version.version}" } say "q. Quit.\n\n" end def pick_gem gems, name answer = ask "Enter selection:" return if answer == "q" if (1..gems.size).include?(answer.to_i) spec_aid.find name, gems[answer.to_i - 1].version.version else error "Invalid option: #{answer}" end end def process_gem name, method specs = spec_aid.find_all name case when specs.size == 1 spec_aid.send method, specs.first when specs.size > 1 print_gems specs spec_aid.send method, pick_gem(specs, name) else error("Unable to find gem: #{name}.") && "" end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
gemsmith-6.2.0 | lib/gemsmith/cli_helpers.rb |
gemsmith-6.1.0 | lib/gemsmith/cli_helpers.rb |