Class: Yay::Lister
- Inherits:
-
Object
- Object
- Yay::Lister
- Defined in:
- lib/yay/lister.rb
Overview
Lists installed .yay files See also: Rimmer, Cat
Instance Method Summary collapse
-
#get_all_files ⇒ Object
returns {dir=>.
-
#get_files_in_dir(dir) ⇒ Object
returns [[name, path],..].
-
#print ⇒ Object
print all paths and files we find in them.
-
#print_files ⇒ Object
print the files we can use and the command that can be typed to use it.
-
#print_paths ⇒ Object
print the search paths we’ll use when looking for yay files.
Instance Method Details
#get_all_files ⇒ Object
returns {dir=>
23 24 25 26 27 28 29 30 |
# File 'lib/yay/lister.rb', line 23 def get_all_files paths = Yay::Paths.new result = {} paths.yay_paths.each { |path| result[path] = get_files_in_dir path } return result end |
#get_files_in_dir(dir) ⇒ Object
returns [[name, path],..]
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/yay/lister.rb', line 9 def get_files_in_dir dir results = [] Dir.glob("#{dir}/*.yay").each { |path| matches = /\/(\w*)?\.yay$/.match(path) if matches[1] results.unshift [matches[1], path] else puts "Eh.. #{path} isn't quite right" end } return results end |
#print ⇒ Object
print all paths and files we find in them
53 54 55 56 57 |
# File 'lib/yay/lister.rb', line 53 def print print_paths puts print_files end |
#print_files ⇒ Object
print the files we can use and the command that can be typed to use it
42 43 44 45 46 47 48 49 50 |
# File 'lib/yay/lister.rb', line 42 def print_files puts "Installed styles:" get_all_files.each_pair { |dir, files| #puts "#{dir}:" files.each { |file| puts "#{file[0]}#{' '*(20-file[0].length)}#{file[1]}" } } end |