Sha256: 66aee0c5709dcb43b498dbcb05f1c5532f060bc1ee7848d192fd7560901f3e9a
Contents?: true
Size: 1.54 KB
Versions: 2
Compression:
Stored size: 1.54 KB
Contents
require 'date' require 'erb' require 'fileutils' require 'furik/cli' require 'active_support/time' module FurichanUtil private def get_wmonth Time.now().strftime('%Y-%m-') + week_of_month end 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 def weekend?(day) day.saturday? or day.sunday? end def write_reflection activity = capture_stdout { init_furik } activity.gsub!('7days Activities', '## 7days Activity') end 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 def capture_stdout out = StringIO.new $stdout = out yield return out.string ensure $stdout = STDOUT end def init_branch `git checkout -b #{get_wmonth}` end def init_file wmonth = get_wmonth FileUtils.mkdir("#{wmonth}") FileUtils.touch("#{wmonth}/README.md") end def create_template template = File.read(File.expand_path('../templates/template.md.erb', __FILE__)) ERB.new(template).result(binding) end def set_template(result) dest = Pathname("#{get_wmonth}/README.md") dest.open('a') { |f| f.puts result } end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
furichan-0.1.4 | lib/furichan/furichan_util.rb |
furichan-0.1.3 | lib/furichan/furichan_util.rb |