Sha256: f43e38600144609b38eddd1791123c7fa3d1a0051bb20e15aa8af97604fe1ce4
Contents?: true
Size: 954 Bytes
Versions: 2
Compression:
Stored size: 954 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.to_s short = "-#{head[0]}" { short: short, long: "--#{head}", desc: desc } 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 $PROGRAM_NAME == __FILE__ helps = OrgToYaml.new(ARGV[0]) pp helps.help_cont end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
my_help-0.7.1 | before_gli/lib/my_help/org2yml.rb |
my_help-0.7.0 | before_gli/lib/my_help/org2yml.rb |