lib/Charu/ChangeLogMemo.rb in Charu-0.0.12 vs lib/Charu/ChangeLogMemo.rb in Charu-0.0.16

- old
+ new

@@ -1,6 +1,6 @@ -# -*- encoding: utf-8 -*- +# -*- encoding: utf-8 -*- module Charu class Category attr_accessor :category def initialize() @@ -92,15 +92,37 @@ @item_log.rstrip! # 文字列最後の空白削除 @item_log.strip! # 先頭と末尾の空白文字を除去 #@item_log.gsub!(/(\r\n|\r\f\n|\r|\n)/, "</p>\n<p>") - markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML) - html = markdown.render(@item_log) + html = @item_log - html.gsub!(/(\r\n|\r\f\n|\r|\n)/, "</p>\n<p>") - +=begin + options = { + filter_html: true, + hard_wrap: true, + space_after_headers: true, + } + + extensions = { + autolink: true, + no_intra_emphasis: true, + fenced_code_blocks: true, + } + + #markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML) + + renderer = Redcarpet::Render::HTML.new(options) + markdown = Redcarpet::Markdown.new(renderer, extensions) + + html = markdown.render(@item_log).html_safe +=end + + #html = RDiscount.new(@item_log, :smart, :filter_html) + + html.gsub!(/(\r\n|\r\f\n|\r|\n)/, "</p>\n<p>") + return html end return "" end @@ -125,14 +147,18 @@ def get_item_date_string() return @date.strftime("%Y-%m-%d") end + # 日付を取得する + def get_year() + return @date.strftime("%Y") + end end class Entry - attr_accessor :date, :item_title, :item_log, :category, :item_source_date + attr_accessor :item_title, :item_log, :category, :item_source_date def initialize(item_source) @item_source_date = "" @item_source_contents = "" @item_source_date = item_source[0] # 時間データ・ソース @item_source_contents = item_source[1] # 内容データ @@ -203,12 +229,12 @@ end end # プライベートと分ける module Charu - class ChangeLogPrivate < ChangeLog - def get_item_private() + class ChangeLogPublic < ChangeLog + def get_item() @item_list_private = Hash.new() # プライベート集計 @entrys.each{|entry| necessary = [] @@ -236,41 +262,50 @@ } return @item_list_private end end - class ChangeLogPublic < ChangeLog - def get_item_private() - @item_list_private = [] - @entrys.entrys.each{|entry| - i = [] - s = "" + class ChangeLogPrivate < ChangeLog + def get_item() + @item_list_private = Hash.new() + + @entrys.each{|entry| + necessary = [] + day_s = "" entry.get_items().each{|item| - s = item.get_item_date_string() - i << [item] + day_s = item.get_item_date_string() + + necessary << item + } - @item_list_private[s] = i + @item_list_private[day_s] = necessary } + + # 配列の[]のを集計 + delt = [] + @item_list_private.each{|key, item| + if item == [] then + delt << key + end + } + + # []を削除 + delt.each{|del| + @item_list_private.delete(del) + } return @item_list_private end end end module Charu class ChangeLogMemo - def initialize() + def initialize(item_list) @config = Charu::Config.new() - # ChangeLogMemoファイル - File.open(@config.change_log_path, 'r:utf-8'){|f| - @source = f.read # 全て読み込む - } + @item_list = item_list - @change_log_private = Charu::ChangeLogPrivate.new(@source) - - @item_list = @change_log_private.get_item_private() - # 全てのカテゴリーを取得 @all_category_list = [] @item_list.each{|key, items| #p "key " + key #p items @@ -350,8 +385,17 @@ # カテゴリーを取得する def get_category_list() return @all_category_list.uniq() end + + # 日付を取得する + def get_year() + year = [] + @item_list.each{|key, item| + year << item.date.strftime("%Y") + } + return year + end + end end -