Class: Ankit::FindCommand

Inherits:
Command
  • Object
show all
Includes:
CardNaming
Defined in:
lib/ankit/find_command.rb

Constant Summary

Constants inherited from Command

Command::COMMANDS

Instance Attribute Summary

Attributes inherited from Command

#args, #options, #runtime

Instance Method Summary collapse

Methods included from CardNaming

#card_wildcard_for, #to_card_name, #to_card_path

Methods inherited from Command

available, by_name, command_name, define_options, #initialize, option_spec

Constructor Details

This class inherits a constructor from Ankit::Command

Instance Method Details

#each_path(&block) ⇒ Object



15
16
17
18
19
20
# File 'lib/ankit/find_command.rb', line 15

def each_path(&block)
  names.each do |n|
    found = path_for(n)
    block.call(found) if found
  end
end

#executeObject



11
12
13
# File 'lib/ankit/find_command.rb', line 11

def execute()
  each_path { |f| runtime.stdout.print("#{f}\n") }
end

#namesObject



30
# File 'lib/ankit/find_command.rb', line 30

def names; args; end

#path_for(name) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/ankit/find_command.rb', line 22

def path_for(name)
  found_in = runtime.config.card_search_paths.find do |p|
    File.file?(to_card_path(p, name))
  end

  found_in ? to_card_path(found_in, name) : nil
end