Sha256: 75a00fd0d00a038071f06e1db03c44ae7be8b92fa9ca130df9cac08b190b10be
Contents?: true
Size: 924 Bytes
Versions: 3
Compression:
Stored size: 924 Bytes
Contents
# -*- coding: utf-8 -*- require 'yaml' require 'pp' class OrgToYaml attr_accessor :help_cont def initialize(file) @help_cont = {} #{ head: [File.basename(file, '.org')] } @head_sym = nil @conts = '' org_to_yaml(File.readlines(file)) end def make_options(line) head, desc = line.split(':') desc ||= head { short: "-#{head[0]}", long: "--#{head}", desc: desc.to_s } end def next_cont(head) @help_cont[@head_sym][:cont] = @conts if @head_sym return if head == 'EOF' @conts = '' @head_sym = head.to_sym @help_cont[@head_sym] = { opts: make_options(head), title: head, cont: '' } end def org_to_yaml(lines) lines.each do |line| if m = line.match(/^\* (.+)/) next_cont m[1] else @conts << line end end next_cont 'EOF' end end if __FILE__ == $1 helps = OrgToYaml.new(ARGV[0]) pp helps.help_cont end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
my_help-0.5.2 | lib/my_help/org2yml.rb |
my_help-0.5.1 | lib/my_help/org2yml.rb |
my_help-0.5.0 | lib/my_help/org2yml.rb |