Class: XcodePristine::ProjectFinder
- Inherits:
-
Object
- Object
- XcodePristine::ProjectFinder
- Defined in:
- lib/xcode_pristine/project_finder.rb
Instance Attribute Summary collapse
-
#projects ⇒ Object
readonly
Returns the value of attribute projects.
Instance Method Summary collapse
-
#initialize(args) ⇒ ProjectFinder
constructor
A new instance of ProjectFinder.
- #project_from_file(project_file) ⇒ Object
- #projects_from_files(files) ⇒ Object
- #projects_from_workspace(workspace_file) ⇒ Object
- #projects_from_workspace_files(workspaces) ⇒ Object
Constructor Details
#initialize(args) ⇒ ProjectFinder
Returns a new instance of ProjectFinder.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/xcode_pristine/project_finder.rb', line 7 def initialize args @projects = args.map do |path| workspaces = Dir.glob(File.join(path, '*.xcworkspace')) projects = Dir.glob(File.join(path, '*.xcodeproj')) if path.end_with? "xcworkspace" projects_from_workspace path elsif path.end_with? "xcodeproj" project_from_file path elsif workspaces.empty? projects_from_files(projects) else projects_from_workspace_files(workspaces) end end.flatten end |
Instance Attribute Details
#projects ⇒ Object (readonly)
Returns the value of attribute projects.
5 6 7 |
# File 'lib/xcode_pristine/project_finder.rb', line 5 def projects @projects end |
Instance Method Details
#project_from_file(project_file) ⇒ Object
24 25 26 |
# File 'lib/xcode_pristine/project_finder.rb', line 24 def project_from_file project_file Xcodeproj::Project.open(project_file) end |
#projects_from_files(files) ⇒ Object
28 29 30 31 32 |
# File 'lib/xcode_pristine/project_finder.rb', line 28 def projects_from_files files files.map do |project_file| project_from_file(project_file) end end |
#projects_from_workspace(workspace_file) ⇒ Object
34 35 36 37 38 39 40 41 42 |
# File 'lib/xcode_pristine/project_finder.rb', line 34 def projects_from_workspace workspace_file workspace = Xcodeproj::Workspace.new_from_xcworkspace(workspace_file) workspace.file_references.select do |file_reference| file_reference.path.end_with? 'xcodeproj' end.map do |project_file_reference| project_file = File.join(workspace_file, '..', project_file_reference.path) project_from_file(project_file) end end |
#projects_from_workspace_files(workspaces) ⇒ Object
44 45 46 47 48 |
# File 'lib/xcode_pristine/project_finder.rb', line 44 def projects_from_workspace_files workspaces workspaces.map do |workspace_file| projects_from_workspace(workspace_file) end.flatten end |