Class: Bourdain::Helpers::UsageParser
- Inherits:
-
Object
- Object
- Bourdain::Helpers::UsageParser
- Defined in:
- lib/bourdain/helpers/parser.rb
Class Method Summary collapse
Class Method Details
.parse(spec) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/bourdain/helpers/parser.rb', line 6 def self.parse spec lines = spec.lines.map(&:strip) desc = lines.shift usage = lines.shift name = usage.split(' ').first args = lines.select { |l| l =~ /^--/ } resources = lines.select { |l| l =~ /^</ } resources = resources.map { |r| r.gsub(/\W/, '') } { name: name, usage: usage, desc: desc, resources: resources, opts: args.map { |a| parse_arg a } } end |