Class: Locca::ProjectFactory
- Inherits:
-
Object
- Object
- Locca::ProjectFactory
- Defined in:
- lib/locca/projects/project_factory.rb
Instance Method Summary collapse
- #all_projects(project_dir) ⇒ Object
-
#initialize(project_dir_locator, config_reader) ⇒ ProjectFactory
constructor
A new instance of ProjectFactory.
Constructor Details
#initialize(project_dir_locator, config_reader) ⇒ ProjectFactory
Returns a new instance of ProjectFactory.
39 40 41 42 |
# File 'lib/locca/projects/project_factory.rb', line 39 def initialize(project_dir_locator, config_reader) @project_dir_locator = project_dir_locator @config_reader = config_reader end |
Instance Method Details
#all_projects(project_dir) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/locca/projects/project_factory.rb', line 44 def all_projects(project_dir) project_dir = @project_dir_locator.locate(project_dir) if not project_dir raise ProjectNotFoundError, 'Can\'t find .locca dir (also checked parent dirs)' end config = @config_reader.read(@project_dir_locator.config_path(project_dir)) if not config raise ConfigNotFoundError, 'Can\'t find .locca/config' end results = Array.new() if config["project_file"] project = Xcodeproj::Project.open(File.join(project_dir, config["project_file"])) config["targets"].each { |target_name, target_config| project.native_targets().each { |target| if target.name == target_name merged_config = config.merge(target_config) results.push(XcodeProject.new(project_dir, target, merged_config)) end } } else results.push(AndroidProject.new(project_dir, config)) end return results end |