Class: Fus::Finder

Inherits:
Object
  • Object
show all
Defined in:
lib/fus/finder.rb

Overview

The thing that finds the stuff

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Finder

Returns a new instance of Finder.

Raises:

  • (Errno::ENOENT)


6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fus/finder.rb', line 6

def initialize(path)
  raise Errno::ENOENT.new(path) unless Dir.exists?(path)
  path = File.expand_path(path)
  @swift_paths = Dir
      .glob("#{path}/**/*.swift")
      .select {|path| path.scan(/\/Pods\//).empty? }
      .select {|path| path.scan(/\/Carthage\//).empty? }
  @obj_c_paths = Dir.glob("#{path}/**/*.m") + Dir.glob("#{path}/**/*.h")
    .select {|path| path.scan(/-Swift.h/).empty? }
  @ib_paths = (Dir.glob("#{path}/**/*.xib") + 
              Dir.glob("#{path}/**/*.storyboard"))
end

Instance Attribute Details

#swift_pathsObject (readonly)

Returns the value of attribute swift_paths.



4
5
6
# File 'lib/fus/finder.rb', line 4

def swift_paths
  @swift_paths
end

Instance Method Details

#swift_classnamesObject

A list of names of all Swift classes



25
26
27
# File 'lib/fus/finder.rb', line 25

def swift_classnames
  swift_classes.map(&:name)
end

#unused_classnamesObject

A list of names of unused classes



20
21
22
# File 'lib/fus/finder.rb', line 20

def unused_classnames
  unused_classes.map(&:name)
end