Class: Makit::Show
- Inherits:
-
Object
- Object
- Makit::Show
- Defined in:
- lib/makit/show.rb
Instance Method Summary collapse
- #age(path) ⇒ Object
- #directory_symbol ⇒ Object
- #file(path) ⇒ Object
- #file_symbol ⇒ Object
- #files(path_array) ⇒ Object
- #git_branch ⇒ Object
- #git_branch_symbol ⇒ Object
- #info(text) ⇒ Object
- #modified(path) ⇒ Object
- #size(path) ⇒ Object
- #success(text) ⇒ Object
- #task(task) ⇒ Object
- #task_symbol ⇒ Object
- #version(path) ⇒ Object
- #versions(glob_pattern) ⇒ Object
Instance Method Details
#age(path) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/makit/show.rb', line 19 def age(path) if File.file?(path) modified = File.mtime(path) age = (Time.now - modified).to_f puts "#{path} age is ".colorize(:grey) + Makit::Humanize.get_humanized_duration(age).to_s.colorize(:cyan) elsif File.directory?(path) modified = Makit::Directory.modified(path) age = Time.now(-modified).to_f puts "#{path} age is ".colorize(:grey) + Makit::Humanize.get_humanized_duration(age).to_s.colorize(:cyan) else puts "#{path} does not exist" end end |
#directory_symbol ⇒ Object
57 58 59 60 |
# File 'lib/makit/show.rb', line 57 def directory_symbol # 📁 (U+1F4C1) – "File Folder" "\u{1F4C1}" end |
#file(path) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/makit/show.rb', line 33 def file(path) if File.file?(path) modified = File.mtime(path) (Time.now - modified).to_f humanized_size = Makit::Humanize.get_humanized_size(File.size(path)) # puts "#{file_symbol} ".colorize(:grey) + "#{humanized_size.rjust(10)} ".colorize(:cyan) + " #{path} ".colorize(:grey) puts "#{file_symbol} ".colorize(:grey) + "#{File.basename(path)} ".colorize(:green) + "#{humanized_size.rjust(10)} ".colorize(:cyan) + " #{path} ".colorize(:grey) # + "modified #{Makit::Humanize.get_humanized_timestamp(modified)}".colorize(:grey) + " age #{Makit::Humanize.get_humanized_duration(age)}".colorize(:grey) else puts "#{path} does not exist" end end |
#file_symbol ⇒ Object
51 52 53 54 55 |
# File 'lib/makit/show.rb', line 51 def file_symbol # 📄 (U+1F4C4) – "Page with Curl" # "\u{1F4C4}" "@" end |
#files(path_array) ⇒ Object
45 46 47 48 49 |
# File 'lib/makit/show.rb', line 45 def files(path_array) path_array.each do |path| file(path) end end |
#git_branch ⇒ Object
106 107 108 |
# File 'lib/makit/show.rb', line 106 def git_branch puts "#{git_branch_symbol} ".colorize(:grey) + Makit::Git::Repository.branch.to_s.colorize(:green) + " branch".colorize(:grey) end |
#git_branch_symbol ⇒ Object
67 68 69 70 |
# File 'lib/makit/show.rb', line 67 def git_branch_symbol # 🌱 (U+1F331) – "Seedling" "\u{1F331}" end |
#info(text) ⇒ Object
88 89 90 |
# File 'lib/makit/show.rb', line 88 def info(text) puts " ".colorize(:grey) + text.to_s.colorize(:cyan) end |
#modified(path) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/makit/show.rb', line 9 def modified(path) if File.file?(path) puts "#{path} modified ".colorize(:grey) + Makit::Humanize.(File.mtime(path)).to_s.colorize(:cyan) elsif File.directory?(path) puts "#{path} modified ".colorize(:grey) + Makit::Humanize.(Makit::Directory.modified(path)).to_s.colorize(:cyan) else puts "#{path} does not exist" end end |
#size(path) ⇒ Object
72 73 74 75 76 77 78 79 80 |
# File 'lib/makit/show.rb', line 72 def size(path) if File.file?(path) puts "#{path} size is ".colorize(:grey) + Makit::Humanize.get_humanized_size(File.size(path)).to_s.colorize(:cyan) elsif File.directory?(path) puts "#{path} size is ".colorize(:grey) + Makit::Humanize.get_humanized_size(Makit::Directory.get_size(path)).to_s.colorize(:cyan) else puts "#{path} does not exist" end end |
#success(text) ⇒ Object
92 93 94 |
# File 'lib/makit/show.rb', line 92 def success(text) puts " ".colorize(:grey) + text.to_s.colorize(:green) end |
#task(task) ⇒ Object
82 83 84 85 86 |
# File 'lib/makit/show.rb', line 82 def task(task) puts ("=" * 80).colorize(:grey) puts " ".colorize(:grey) + task.to_s.colorize(:green) # puts ("=" * 100).colorize(:grey) end |
#task_symbol ⇒ Object
62 63 64 65 |
# File 'lib/makit/show.rb', line 62 def task_symbol # 🛠️ (U+1F6E0) Hammer and Wrench – Represents tools, suitable for tasks and automation. "\u{1F6E0}" end |
#version(path) ⇒ Object
96 97 98 |
# File 'lib/makit/show.rb', line 96 def version(path) puts " #{Makit::Version.get_version_from_file(path)}".colorize(:green) + " found in #{path}".colorize(:grey) end |
#versions(glob_pattern) ⇒ Object
100 101 102 103 104 |
# File 'lib/makit/show.rb', line 100 def versions(glob_pattern) Dir.glob(glob_pattern).each do |filename| puts " #{Makit::Version.get_version_from_file(filename)}".colorize(:green) + " found in #{filename}".colorize(:grey) end end |