lib/sifttter-redux/sifttter.rb in sifttter-redux-1.0.4 vs lib/sifttter-redux/sifttter.rb in sifttter-redux-1.0.5
- old
+ new
@@ -47,13 +47,13 @@
# @param [Date] date The date to search for
# @return [void]
def parse_sifttter_file(filepath, date)
title = File.basename(filepath).gsub(/^.*?\/([^\/]+)$/, "\\1") + "\n"
- date_regex = "(?:#{ date.strftime("%B") } 0?#{ date.strftime("%-d") }, #{ date.strftime("%Y") })"
- time_regex = "(?:\d{1,2}:\d{1,2}\s?[AaPpMm]{2})"
- entry_regex = /@begin\n@date\s#{ date_regex }(?: at (#{ time_regex }?)\n)?(.*?)@end/m
+ date_regex = /(?:#{ date.strftime("%B") } 0?#{ date.strftime("%-d") }, #{ date.strftime("%Y") })/
+ time_regex = /(?:\d{1,2}:\d{1,2}\s?[AaPpMm]{2})/
+ entry_regex = /@begin\n@date\s#{ date_regex }(?: at (#{ time_regex }?)\n)?(.*?)\n@end/m
contents = File.read(filepath)
cur_entries = contents.scan(entry_regex)
unless cur_entries.empty?
@entries.merge!(title => []) unless @entries.key?(title)
@@ -94,10 +94,10 @@
entrytext = "# Things done on #{ date_for_title }\n"
@entries.each do |key, value|
coder = HTMLEntities.new
entrytext += '### ' + key.gsub(/.txt/, '').gsub(/_/, ' ').upcase + "\n\n"
- value.each { |v| entrytext += "#{ coder.encode(v[1]) }\n" }
+ value.each { |v| entrytext += "#{ coder.encode(v[1].gsub(/%time%/, v[0])) }\n" }
entrytext += "\n"
end
template = generate_template(datestamp, entrytext, starred, uuid)
fh = File.new(File.expand_path("#{ output_dir }/#{ uuid }.doentry"), 'w+')