Class: Pod::Target::Commands::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/pod/target/commands/resolve/parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(workspace_path, filter) ⇒ Parser

Returns a new instance of Parser.



9
10
11
12
13
14
15
16
17
18
# File 'lib/pod/target/commands/resolve/parser.rb', line 9

def initialize(workspace_path, filter)
    if workspace_path.nil?
        prompt = TTY::Prompt.new
        prompt.error("Error! Cannot find workspace path")
        exit 1
    end
    @workspace_dir = File.dirname(workspace_path)
    @workspace = Xcodeproj::Workspace.new_from_xcworkspace(workspace_path)
    @regex = filter
end

Instance Attribute Details

#regexObject (readonly)

Returns the value of attribute regex.



8
9
10
# File 'lib/pod/target/commands/resolve/parser.rb', line 8

def regex
  @regex
end

#workspaceObject (readonly)

Returns the value of attribute workspace.



8
9
10
# File 'lib/pod/target/commands/resolve/parser.rb', line 8

def workspace
  @workspace
end

#workspace_dirObject (readonly)

Returns the value of attribute workspace_dir.



8
9
10
# File 'lib/pod/target/commands/resolve/parser.rb', line 8

def workspace_dir
  @workspace_dir
end

Instance Method Details

#all_targetsObject



20
21
22
23
# File 'lib/pod/target/commands/resolve/parser.rb', line 20

def all_targets
    @projects ||= projects
    projects.flat_map(&:targets).select { |target| target.name =~ /#{regex}/ }
end

#projectsObject



25
26
27
28
29
30
# File 'lib/pod/target/commands/resolve/parser.rb', line 25

def projects
    all_project_paths = @workspace.file_references.map(&:path)
    all_project_paths.map do |project_path|
        Xcodeproj::Project.open(File.expand_path(project_path, @workspace_dir))
    end
end