class DirFriend::Command

Public Instance Methods

banner() click to toggle source
dot(path) click to toggle source
# File lib/dir_friend/command.rb, line 33
def dot(path)
  opt = options.to_keysym_hash
  save_path = opt.delete(:save)
  exclude = (ex=opt.delete(:exclude)) ? ex.split(',') : []
  opt = opt_parser(opt)

  dir = D.new(path, depth:options[:depth].to_i, exclude:exclude)
  dir.to_dot(opt).save(save_path)
  puts "'#{save_path}.dot' created in the current directory."

  if options[:with_open] && OS.mac?
    run(%Q{open "#{save_path}.dot"}, verbose: false)
  end
end
info(path) click to toggle source
# File lib/dir_friend/command.rb, line 9
def info(path)
  puts Any.new(path).info
end
opt_parser(opt) click to toggle source
# File lib/dir_friend/command.rb, line 66
def opt_parser(opt)
  %i(global nodes edges).each do |attr|
    if kv = opt.delete(attr)
      kv_arr = kv.split(/\s*,\s*/)
                 .map{ |kv| kv.split(/\s*:\s*/).map(&:strip) }
                 .map{ |k, v| [k.intern, v] }
      opt.update({attr => Hash[ kv_arr ]})
    end
  end
  if Config.enable
    theme = Config.read(opt.delete(:theme))
    theme.merge(opt)
  else
    opt
  end
end
version() click to toggle source
# File lib/dir_friend/command.rb, line 49
def version
  puts "DirFriend #{DirFriend::VERSION} (c) 2013 kyoendo"
end