Class: Fui::Finder
- Inherits:
-
Object
- Object
- Fui::Finder
- Defined in:
- lib/fui/finder.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #headers ⇒ Object
-
#initialize(path, options = {}) ⇒ Finder
constructor
A new instance of Finder.
- #references(&block) ⇒ Object
- #unused_references(&block) ⇒ Object
Constructor Details
#initialize(path, options = {}) ⇒ Finder
Returns a new instance of Finder.
5 6 7 8 9 |
# File 'lib/fui/finder.rb', line 5 def initialize(path, = {}) @path = File.(path) = raise Errno::ENOENT, path unless Dir.exist?(@path) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/fui/finder.rb', line 3 def end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
3 4 5 |
# File 'lib/fui/finder.rb', line 3 def path @path end |
Instance Method Details
#headers ⇒ Object
11 12 13 |
# File 'lib/fui/finder.rb', line 11 def headers @headers ||= Finder.find(path) { |path| Header.header?(path) }.collect { |path| Header.new(path) } end |
#references(&block) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/fui/finder.rb', line 15 def references(&block) @references ||= begin references = {} headers.each do |header| references[header] = [] end Find.find(path) do |path| next unless File.ftype(path) == 'file' if ['.m', '.h', '.pch'].include?(File.extname(path)) process_code references, path, &block elsif ['.storyboard', '.xib'].include?(File.extname(path)) process_xml references, path, &block end end references end end |
#unused_references(&block) ⇒ Object
33 34 35 |
# File 'lib/fui/finder.rb', line 33 def unused_references(&block) @unused_references ||= references(&block).select { |_k, v| v.count == 0 } end |