Class: RubyNext::Commands::CoreExt
- Defined in:
- lib/ruby-next/commands/core_ext.rb
Instance Attribute Summary collapse
-
#filter ⇒ Object
readonly
Returns the value of attribute filter.
-
#list ⇒ Object
(also: #list?)
readonly
Returns the value of attribute list.
-
#min_version ⇒ Object
readonly
Returns the value of attribute min_version.
-
#names ⇒ Object
readonly
Returns the value of attribute names.
-
#original_command ⇒ Object
readonly
Returns the value of attribute original_command.
-
#out_path ⇒ Object
readonly
Returns the value of attribute out_path.
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
#base_parser, #initialize, #log, run
Constructor Details
This class inherits a constructor from RubyNext::Commands::Base
Instance Attribute Details
#filter ⇒ Object (readonly)
Returns the value of attribute filter.
11 12 13 |
# File 'lib/ruby-next/commands/core_ext.rb', line 11 def filter @filter end |
#list ⇒ Object (readonly) Also known as: list?
Returns the value of attribute list.
11 12 13 |
# File 'lib/ruby-next/commands/core_ext.rb', line 11 def list @list end |
#min_version ⇒ Object (readonly)
Returns the value of attribute min_version.
11 12 13 |
# File 'lib/ruby-next/commands/core_ext.rb', line 11 def min_version @min_version end |
#names ⇒ Object (readonly)
Returns the value of attribute names.
11 12 13 |
# File 'lib/ruby-next/commands/core_ext.rb', line 11 def names @names end |
#original_command ⇒ Object (readonly)
Returns the value of attribute original_command.
11 12 13 |
# File 'lib/ruby-next/commands/core_ext.rb', line 11 def original_command @original_command end |
#out_path ⇒ Object (readonly)
Returns the value of attribute out_path.
11 12 13 |
# File 'lib/ruby-next/commands/core_ext.rb', line 11 def out_path @out_path end |
Instance Method Details
#parse!(args) ⇒ Object
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 |
# File 'lib/ruby-next/commands/core_ext.rb', line 24 def parse!(args) print_help = false @min_version = MIN_SUPPORTED_VERSION @original_command = "ruby-next core_ext #{args.join(" ")}" @names = [] @list = false @out_path = File.join(Dir.pwd, "core_ext.rb") optparser = base_parser do |opts| opts. = "Usage: ruby-next core_ext [options]" opts.on("-o", "--output=OUTPUT", "Specify output file or stdout (default: ./core_ext.rb)") do |val| @out_path = val end opts.on("-l", "--list", "List all available extensions") do @list = true end opts.on("--min-version=VERSION", "Specify the minimum Ruby version to support") do |val| @min_version = Gem::Version.new(val) end opts.on("-n", "--name=NAME", "Filter extensions by name") do |val| names << val end opts.on("-h", "--help", "Print help") do print_help = true end end optparser.parse!(args) if print_help $stdout.puts optparser.help exit 0 end @filter = /(#{names.join("|")})/i unless names.empty? end |
#run ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/ruby-next/commands/core_ext.rb', line 14 def run log "Select core extensions for Ruby v#{min_version}" \ "#{filter ? " and matching #{filter.inspect}" : ""}" matching_patches.then do |patches| next print_list(patches) if list? generate_core_ext(patches) end end |