Class: Swoop::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/swoop/project.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path, directory = 'Classes') ⇒ Project

Returns a new instance of Project.



9
10
11
12
# File 'lib/swoop/project.rb', line 9

def initialize(path, directory = 'Classes')
  @path = path
  @directory = directory
end

Instance Attribute Details

#directoryObject (readonly)

Returns the value of attribute directory.



7
8
9
# File 'lib/swoop/project.rb', line 7

def directory
  @directory
end

#pathObject (readonly)

Returns the value of attribute path.



7
8
9
# File 'lib/swoop/project.rb', line 7

def path
  @path
end

Instance Method Details

#filepathsObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/swoop/project.rb', line 14

def filepaths
  raise "Error: Project path is empty :(" if @path.empty?
  raise "Error: Can't find .xcodeproj project :(" unless File.exist? @path
  raise "Error: Invalid .xcodeproj file :(" unless File.extname(@path) == '.xcodeproj'

  project = Xcodeproj::Project.open @path
  project_dir = project[directory]

  raise "Error: Can't find directory :(" if project_dir.nil?

  filepaths = project_dir
    .recursive_children
    .select { |f| valid_file? f }
    .map(&:real_path)

  raise "Error: No files are found :(" if filepaths.empty?

  filepaths
end