lib/makit/show.rb in makit-0.0.40 vs lib/makit/show.rb in makit-0.0.41

- old
+ new

@@ -1,108 +1,108 @@ -# 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) - else - puts "#{path} does not exist" - 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) - #if(!File.exist?(path)) - # puts "file #{path}does not exist" - # return - #end - - #extension = File.extname(path) - #switch = extension.downcase - #case switch - #if extension == ".csproj" - # version = Makit::Version.detect_from_file(path, /<Version>([-\w\d.]+)</) - # if version.empty? - # puts "no version found in #{path}" - # else - # puts " #{version}".colorize(:green) + " found in #{path}".colorize(:grey) - # end - # else - ## puts "unrecognized file type" - #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) + else + puts "#{path} does not exist" + 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) + #if(!File.exist?(path)) + # puts "file #{path}does not exist" + # return + #end + + #extension = File.extname(path) + #switch = extension.downcase + #case switch + #if extension == ".csproj" + # version = Makit::Version.detect_from_file(path, /<Version>([-\w\d.]+)</) + # if version.empty? + # puts "no version found in #{path}" + # else + # puts " #{version}".colorize(:green) + " found in #{path}".colorize(:grey) + # end + # else + ## puts "unrecognized file type" + #end + end + end +end + +