Sha256: 11e01bb19cc21a01952a9634df30dd8df233fda9aec9066e5be3cc92e10d44c4
Contents?: true
Size: 1.36 KB
Versions: 1
Compression:
Stored size: 1.36 KB
Contents
module Hse class Parse attr_accessor :app_dir, :document #, :config_path, :revision #attr_reader :config def initialize(app_dir) #, config_path = nil) self.app_dir = File.expand_path(app_dir) + '/' #load_couchapprc end def build fname document = {body:[]} path = File.expand_path(File.join(app_dir, fname)) #puts "path #{path}" uuid = UUIDTools::UUID.sha1_create UUIDTools::UUID_DNS_NAMESPACE, "#{fname}" document[:_id] = uuid.to_s lines = File.readlines path lines.each do |line| line.sub!("\n","").strip! next if line.empty? unless line.start_with? "#" document[:body].push line next end parts = line.split(":") key= parts.first mark = key.sub("#","").strip tail = line.sub("#{key}:", "").strip case mark when "title" document[:title] = tail document[:short] = tail.split(":").first when "en" document[:en] = tail document[:url] = tail.split(":").first.capitalize.gsub(" ", "-") when "de" document[:de] = tail when "author" document[:author] = tail when "tags" document[:tags] = tail.strip.split(/[[:punct:]]| /).reject!{|c|c.empty?} else end end document end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
hse-0.0.1 | lib/hse/parse.rb |