Module: DailyProgress
- Includes:
- OS
- Defined in:
- lib/daily_progress.rb,
lib/DailyProgress/version.rb
Overview
The main module for the gem implementation.
Defined Under Namespace
Classes: Error
Constant Summary
collapse
- VERSION =
'1.2.0'
- WSL_VERSION_PATH =
'/proc/version'
Instance Method Summary
collapse
Methods included from OS
jruby?, linux?, mac?, unix?, windows?, wsl?
Instance Method Details
11
12
13
14
|
# 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 ⇒ Object
41
42
43
44
45
46
47
|
# 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) ⇒ Object
56
57
58
59
60
61
|
# 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 ⇒ Object
28
29
30
|
# File 'lib/daily_progress.rb', line 28
def list_files
Dir["#{@path}*"]
end
|
#morning_progress(content) ⇒ Object
49
50
51
52
53
54
|
# File 'lib/daily_progress.rb', line 49
def morning_progress(content)
content.gsub!('[X]', '')
content.gsub!('[-]', '')
content.gsub!('[ ]', '')
content
end
|
#progress ⇒ Object
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/daily_progress.rb', line 16
def progress
time_now = Time.new
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) ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
74
75
|
# 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? ⇒ Boolean
37
38
39
|
# File 'lib/daily_progress.rb', line 37
def today_file_exists?
File.file?(today_filename)
end
|
#today_filename ⇒ Object
32
33
34
35
|
# File 'lib/daily_progress.rb', line 32
def today_filename
time = Time.new
"#{@path}#{time.strftime('%Y-%m-%d.wiki')}"
end
|