module DailyProgress
The main module for the gem implementation.
Constants
- VERSION
- WSL_VERSION_PATH
Public Instance Methods
configure(path)
click to toggle source
# File lib/daily_progress.rb, line 11 def configure(path) @path = path abort("[FATAL] Today's vimwiki entry not created yet!") unless today_file_exists? end
content()
click to toggle source
# File lib/daily_progress.rb, line 41 def content filename = today_filename file = File.open(filename) file_data = file.read file.close file_data end
evening_progress(content)
click to toggle source
# File lib/daily_progress.rb, line 56 def evening_progress(content) content.gsub!('[X]', '[Completed]') content.gsub!('[-]', '[On Hold]') content.gsub!('[ ]', '[In Progress]') content end
list_files()
click to toggle source
# File lib/daily_progress.rb, line 28 def list_files Dir["#{@path}*"] end
morning_progress(content)
click to toggle source
# File lib/daily_progress.rb, line 49 def morning_progress(content) content.gsub!('[X]', '') content.gsub!('[-]', '') content.gsub!('[ ]', '') content end
progress()
click to toggle source
# File lib/daily_progress.rb, line 16 def progress time_now = Time.new # Threshold time currently 7 PM time_th = Time.new(time_now.year, time_now.month, time_now.day, 19, 0, 0, '+05:30') text = content if time_now < time_th morning_progress(text) else evening_progress(text) end end
to_clipboard(content)
click to toggle source
# File lib/daily_progress.rb, line 63 def to_clipboard(content) success_msg = "Content copied to clipboard successfully!" if OS.windows? IO.popen('clip', 'w') { |f| f << content.to_s } puts success_msg elsif OS.wsl? puts "Clipboard not implemented for WSL." puts content else OS.linux? IO.popen('xclip -selection clipboard', 'r+') { |f| f.puts content.to_s } puts success_msg end end
today_file_exists?()
click to toggle source
# File lib/daily_progress.rb, line 37 def today_file_exists? File.file?(today_filename) end
today_filename()
click to toggle source
# File lib/daily_progress.rb, line 32 def today_filename time = Time.new "#{@path}#{time.strftime('%Y-%m-%d.wiki')}" end