Class: Fui::Finder
- Inherits:
-
Object
- Object
- Fui::Finder
- Defined in:
- lib/fui/finder.rb
Overview
A class to find various things in an Objective C project.
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
- #bridging_headers ⇒ Object
- #headers ⇒ Object
- #ignores ⇒ 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.
6 7 8 9 10 |
# File 'lib/fui/finder.rb', line 6 def initialize(path, = {}) @path = File.(path) @options = raise Errno::ENOENT, path unless Dir.exist?(@path) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
4 5 6 |
# File 'lib/fui/finder.rb', line 4 def @options end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
4 5 6 |
# File 'lib/fui/finder.rb', line 4 def path @path end |
Instance Method Details
#bridging_headers ⇒ Object
16 17 18 |
# File 'lib/fui/finder.rb', line 16 def bridging_headers @bridging_headers ||= find(path) { |path| Project.project?(path) }.collect { |path| Project.new(path).bridging_headers([:verbose]) } end |
#headers ⇒ Object
12 13 14 |
# File 'lib/fui/finder.rb', line 12 def headers @headers ||= find(path) { |path| Header.header?(path) }.collect { |path| Header.new(path) } end |
#ignores ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/fui/finder.rb', line 20 def ignores return unless ['ignore-path'] @ignores ||= ['ignore-path'].map do |i| raise Errno::ENOENT, i unless Dir.exist?(i) Pathname(i) end end |
#references(&block) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/fui/finder.rb', line 30 def references(&block) @references ||= begin references = {} headers.each do |header| references[header] = [] end Find.find(path) do |path| if ['.m', '.mm', '.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
47 48 49 |
# File 'lib/fui/finder.rb', line 47 def unused_references(&block) @unused_references ||= references(&block).select { |k, v| v.count.zero? && !bridging_headers.include?(k.filename) } end |