module FurichanUtil
Private Instance Methods
capture_stdout() { || ... }
click to toggle source
# File lib/furichan/furichan_util.rb, line 49 def capture_stdout out = StringIO.new $stdout = out yield return out.string ensure $stdout = STDOUT end
create_template()
click to toggle source
# File lib/furichan/furichan_util.rb, line 68 def create_template template = File.read(File.expand_path('../templates/template.md.erb', __FILE__)) ERB.new(template).result(binding) end
get_wmonth()
click to toggle source
# File lib/furichan/furichan_util.rb, line 10 def get_wmonth Time.now().strftime('%Y-%m-') + week_of_month end
init_branch()
click to toggle source
# File lib/furichan/furichan_util.rb, line 58 def init_branch `git checkout -b #{get_wmonth}` end
init_file()
click to toggle source
# File lib/furichan/furichan_util.rb, line 62 def init_file wmonth = get_wmonth FileUtils.mkdir("#{wmonth}") FileUtils.touch("#{wmonth}/README.md") end
init_furik()
click to toggle source
# File lib/furichan/furichan_util.rb, line 36 def init_furik week = Date.today.beginning_of_week furik = Furik::Cli.new furik.options = { gh: true, ghe: true, from: week.to_s, to: week.end_of_week.to_s, since: 0, } furik.activity end
set_template(result)
click to toggle source
# File lib/furichan/furichan_util.rb, line 73 def set_template(result) dest = Pathname("#{get_wmonth}/README.md") dest.open('a') { |f| f.puts result } end
week_of_month()
click to toggle source
# File lib/furichan/furichan_util.rb, line 14 def week_of_month today = Date.today() beginning_of_month = today.beginning_of_month cweek = today.cweek - beginning_of_month.cweek # It should be first week. # Don't add when begining of month is saturday or sunday # ex 2017/07/07(Fri) -> 1 cweek += 1 unless weekend?(beginning_of_month) cweek.to_s end
weekend?(day)
click to toggle source
# File lib/furichan/furichan_util.rb, line 27 def weekend?(day) day.saturday? or day.sunday? end
write_reflection()
click to toggle source
# File lib/furichan/furichan_util.rb, line 31 def write_reflection activity = capture_stdout { init_furik } activity.gsub!('7days Activities', '## 7days Activity') end