lib/makit/show.rb in makit-0.0.56 vs lib/makit/show.rb in makit-0.0.57
- old
+ new
@@ -1,101 +1,111 @@
-# frozen_string_literal: true
-
-require "find"
-require "pathname"
-
-# This module provides classes for the Makit gem.
-module Makit
- class Show
- def modified(path)
- if File.file?(path)
- puts "#{path} modified ".colorize(:grey) + "#{Makit::Humanize.get_humanized_timestamp(File.mtime(path))}".colorize(:cyan)
- elsif File.directory?(path)
- puts "#{path} modified ".colorize(:grey) + "#{Makit::Humanize.get_humanized_timestamp(Makit::Directory.modified(path))}".colorize(:cyan)
- else
- puts "#{path} does not exist"
- end
- end
-
- 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)}".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)}".colorize(:cyan)
- else
- puts "#{path} does not exist"
- end
- end
-
- def file(path)
- if File.file?(path)
- modified = File.mtime(path)
- age = (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
-
- def files(path_array)
- path_array.each do |path|
- file(path)
- end
- end
-
- def file_symbol
- #📄 (U+1F4C4) – "Page with Curl"
- #"\u{1F4C4}"
- "@"
- end
-
- def directory_symbol
- # 📁 (U+1F4C1) – "File Folder"
- "\u{1F4C1}"
- end
-
- def task_symbol
- # 🛠️ (U+1F6E0) Hammer and Wrench – Represents tools, suitable for tasks and automation.
- "\u{1F6E0}"
- end
-
- def size(path)
- if File.file?(path)
- puts "#{path} size is ".colorize(:grey) + "#{Makit::Humanize.get_humanized_size(File.size(path))}".colorize(:cyan)
- elsif File.directory?(path)
- puts "#{path} size is ".colorize(:grey) + "#{Makit::Humanize.get_humanized_size(Makit::Directory.get_size(path))}".colorize(:cyan)
- else
- puts "#{path} does not exist"
- end
- end
-
- def task(task)
- puts ("=" * 80).colorize(:grey)
- puts " ".colorize(:grey) + "#{task}".colorize(:green)
- #puts ("=" * 100).colorize(:grey)
- end
-
- def info(text)
- puts " ".colorize(:grey) + "#{text}".colorize(:cyan)
- end
-
- def success(text)
- puts " ".colorize(:grey) + "#{text}".colorize(:green)
- end
-
- def version(path)
- puts " #{Makit::Version.get_version_from_file(path)}".colorize(:green) + " found in #{path}".colorize(:grey)
- end
-
- 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
- end
-end
+# frozen_string_literal: true
+
+require "find"
+require "pathname"
+
+# This module provides classes for the Makit gem.
+module Makit
+ class Show
+ def modified(path)
+ if File.file?(path)
+ puts "#{path} modified ".colorize(:grey) + "#{Makit::Humanize.get_humanized_timestamp(File.mtime(path))}".colorize(:cyan)
+ elsif File.directory?(path)
+ puts "#{path} modified ".colorize(:grey) + "#{Makit::Humanize.get_humanized_timestamp(Makit::Directory.modified(path))}".colorize(:cyan)
+ else
+ puts "#{path} does not exist"
+ end
+ end
+
+ 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)}".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)}".colorize(:cyan)
+ else
+ puts "#{path} does not exist"
+ end
+ end
+
+ def file(path)
+ if File.file?(path)
+ modified = File.mtime(path)
+ age = (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
+
+ def files(path_array)
+ path_array.each do |path|
+ file(path)
+ end
+ end
+
+ def file_symbol
+ #📄 (U+1F4C4) – "Page with Curl"
+ #"\u{1F4C4}"
+ "@"
+ end
+
+ def directory_symbol
+ # 📁 (U+1F4C1) – "File Folder"
+ "\u{1F4C1}"
+ end
+
+ def task_symbol
+ # 🛠️ (U+1F6E0) Hammer and Wrench – Represents tools, suitable for tasks and automation.
+ "\u{1F6E0}"
+ end
+
+ def git_branch_symbol
+ # 🌱 (U+1F331) – "Seedling"
+ "\u{1F331}"
+ end
+
+ def size(path)
+ if File.file?(path)
+ puts "#{path} size is ".colorize(:grey) + "#{Makit::Humanize.get_humanized_size(File.size(path))}".colorize(:cyan)
+ elsif File.directory?(path)
+ puts "#{path} size is ".colorize(:grey) + "#{Makit::Humanize.get_humanized_size(Makit::Directory.get_size(path))}".colorize(:cyan)
+ else
+ puts "#{path} does not exist"
+ end
+ end
+
+ def task(task)
+ puts ("=" * 80).colorize(:grey)
+ puts " ".colorize(:grey) + "#{task}".colorize(:green)
+ #puts ("=" * 100).colorize(:grey)
+ end
+
+ def info(text)
+ puts " ".colorize(:grey) + "#{text}".colorize(:cyan)
+ end
+
+ def success(text)
+ puts " ".colorize(:grey) + "#{text}".colorize(:green)
+ end
+
+ def version(path)
+ puts " #{Makit::Version.get_version_from_file(path)}".colorize(:green) + " found in #{path}".colorize(:grey)
+ end
+
+ 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
+
+ def git_branch
+ puts "#{git_branch_symbol} ".colorize(:grey) + "#{Makit::Git.branch}".colorize(:green) + " branch".colorize(:grey)
+ end
+ end
+end
+